This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# minimum in stack | |
class Node: | |
value = None | |
next = None | |
def __init__(self, value, next=None): | |
self.value = value | |
self.next = next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-UUU:----F1 merge_sort.c Bot L63 [(C/l Abbrev)] -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
File Edit Options Buffers Tools C Help | |
#include <stdio.h> | |
#include <stdlib.h> | |
int sort(int array[], int size, int start, int m, int end){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it holds a field named both, which is\ | |
an XOR of the next node and the previous node. Implement an XOR linked list; it has an add(element) which adds the element to the end, and a get(index) whi\ | |
ch returns the node at index. | |
If using a language that has no pointers (such as Python), you can assume you have access to get_pointer and dereference_pointer functions that converts bet\ | |
ween nodes and memory addresses. | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Node { | |
int value; | |
unsigned int pnx; | |
}; | |
unsigned int XOR(struct Node* a, struct Node* b){ | |
return (unsigned int)a ^ (unsigned int)b; | |
} | |
struct Node* insert_first(int value, struct Node* next){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def shift_array(array): | |
array.insert(0,0) | |
return array | |
def unshift_array(array): | |
array.pop(0) | |
return array | |
def increase(input): | |
if input[0] == 9 : | |
input = shift_array(input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def move_left(array): | |
idx = 0 | |
ri = len(array)-1 | |
while(idx < ri): | |
if(array[idx] <= 0): | |
array[idx], array[ri] = array[ri], array[idx] | |
ri -=1 | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_lowest_not_exists(array): | |
max_len = len(array)-1 | |
min = 0 | |
ri = max_len | |
while(ri > 0): | |
idx = 0 | |
while(idx < ri): | |
if(array[idx] <= min): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
class Node: | |
def __init__(self, value, left, right): | |
self.value = value | |
self.left = left | |
self.right = right | |
def __str__(self): | |
return str([str(self.value), str(self.left) if self.left != None else None, str(self.right) if self.right != None else None ]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# queue using two stacks | |
class MyQueue: | |
_stack1 = list() | |
_stack2 = list() | |
def push(self, value): | |
while( len(self._stack2) != 0): | |
self._stack1.append(self._stack2.pop()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cat /usr/include/asm-generic/unistd.h | |
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
#include <asm/bitsperlong.h> | |
/* | |
* This file contains the system call numbers, based on the | |
* layout of the x86-64 architecture, which embeds the | |
* pointer to the syscall in the table. | |
* | |
* As a basic principle, no duplication of functionality |
NewerOlder