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
public class Solution { | |
private static int M; | |
private static int N; | |
public void solve(char[][] board) { | |
M = board.length; | |
N = board[0].length; | |
//graph = new Node[M, N]; | |
for (int i = 0; i < M; i++) | |
for (int j = 0; j < N; j++) |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
namespace SCC | |
{ | |
class Node | |
{ | |
public Node(int label) { Label = label; Descendents = new List<Node>(); Antecedents = new List<Node>(); Visited = false; } | |
public int Label { get; private set; } |
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
#-- Algorithm--- | |
# recurse thru all albums | |
# delete albums that have 0 photos | |
#----------------- | |
import os | |
import sys | |
import gdata.photos.service | |
import gdata.media |
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
using System; | |
using System.Collections.Generic; | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.WriteLine(CutPalidrome("bananadad")); | |
} | |
static int CutPalidrome(string s) |
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 construct_fault_table(pattern): | |
fault_table = [] | |
fault_table.extend((0,0) # indexes 0 & 1 are always '0' | |
j=0 # poniter to the prefix | |
for i in xrange(2,len(pattern),1): | |
if pattern[i] == pattern[j]: | |
fault_table.append(fault_table[i-1]+1) | |
j+=1 | |
else: | |
j=0 # reset j to the start of the pattern if it breaks |
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
''' | |
Question: | |
Assume you want to shard big SQL user table. How will you obtain the same shard even after increasing the sql boxes. | |
Answer: | |
Same shard number can be obtained if the current system state is preserved before adding new boxes. | |
NOTE: Code below requires python 2.6 or 2.7 | |
''' |
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
using System; | |
using System.Collections.Generic; | |
class Solution | |
{ | |
//Get N | |
// Read N sequences into an array | |
// scan N array | |
//read q | |
// read each operation and perform action. |
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
using System; | |
using System.Collections.Generic; | |
class Solution | |
{ | |
//Get N and K | |
// Read N and split. | |
// scan N array | |
//create a bucket | |
//count =0 |
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
/* | |
Testing Sort algorithms -Insertion & Quicksort . Tested with Sorted,ReverseSorted and Random suites of n=2^3 to 2^8. Results show that insertionsort beats quicksort for lower n and things change between n = 64 to 256 | |
---Testing with n=8--- | |
QuickSort(sorted,reversesorted,random): 5322 11 6 | |
InsertionSort(sorted,reversesorted,random): 1745 4 3 | |
---Testing with n=16--- | |
QuickSort(sorted,reversesorted,random): 30 19 19 | |
InsertionSort(sorted,reversesorted,random): 13 11 8 |
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
using System; | |
using System.Collections.Generic; | |
namespace RandomMusings | |
{ | |
public class UnOrderedSet:IEnumerable<int> | |
{ | |
Dictionary<int,int> _set = null; | |
public UnOrderedSet () |
NewerOlder