Skip to content

Instantly share code, notes, and snippets.

@gsathya
gsathya / issues.md
Last active February 15, 2017 06:33
Node prev_node = node;
Node next_node = node.next;
Node new_node = new Node(element, next_node);
prev_node.next = new_node;
abstract class Foo {
String item;
}
class Bar extends Foo {
@override
String item;
Bar() { item = "yolo"; }
}
def find(h, string_so_far):
if len(string_so_far) == 9:
return string_so_far[::-1]
for j, char in enumerate(letters):
if (h - j) % 37 == 0:
h = (h-j)/37
string_so_far += letters[j]
return find(h, string_so_far)
print find(956446786872726, '')
def _word_pattern(pattern, pattern_index, input, input_index, hashmap):
if (pattern_index == len(pattern) and input_index == len(input)):
return True;
if (pattern_index == len(pattern) or input_index == len(input)):
return False
char = pattern[pattern_index]
if char in hashmap:
➜ src rustc queue.rs
queue.rs:4:8: 4:15 error: wrong number of type arguments: expected 1, found 0
queue.rs:4 q: RingBuf,
^~~~~~~
from collections import defaultdict
n_test_words = int(raw_input())
string_set = defaultdict(set)
substring_set = defaultdict(set)
for x in range(n_test_words):
line = raw_input()
for start in range(len(line)):
@gsathya
gsathya / homebrew.patch
Last active August 29, 2015 14:04
This patch removes the annoying audible-bell on emacs. Apply the homebrew patch and install with `brew install emacs --HEAD --use-git-head`
From 604821b954478b1b10725de9f625682e97080b01 Mon Sep 17 00:00:00 2001
From: Sathyanarayanan Gunasekaran <gsathya.ceg@gmail.com>
Date: Tue, 29 Jul 2014 17:26:51 -0700
Subject: [PATCH 1/1] Add patch to disable Emacs audible bell on osx
---
Library/Formula/emacs.rb | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Library/Formula/emacs.rb b/Library/Formula/emacs.rb
def find_min_list2(lists):
i = 0
n = len(lists)
try:
while True:
for x in range(n):
_ = lists[x][i]
i += 1
except IndexError:
# usage - $python k_frequent.py log_file k
import sys
import heapq
freq = {}
# running time is O(n)
with open(sys.argv[1]) as fh:
for line in fh.readlines():
freq[line] = freq.get(line.strip(), 0) + 1