Skip to content

Instantly share code, notes, and snippets.

# minimum in stack
class Node:
value = None
next = None
def __init__(self, value, next=None):
self.value = value
self.next = next
-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){
/*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>
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){
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)
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:
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):
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 ])
# 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())
@joxer
joxer / gist:f1dc636a97b555c2bc6f45747897f90d
Last active February 20, 2019 16:13
Objdump inotify code example
~$ objdump -d -S a.out
a.out: file format elf64-x86-64
Disassembly of section .init:
00000000000006e0 <_init>:
6e0: 48 83 ec 08 sub $0x8,%rsp
6e4: 48 8b 05 fd 18 20 00 mov 0x2018fd(%rip),%rax # 201fe8 <__gmon_start__>