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
#!/usr/bin/env python | |
import csv | |
import Queue | |
import threading | |
import ystockquote as ys | |
def gen_info_list(tickers, start, 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
Source: http://www.ardendertat.com/2012/01/09/programming-interview-questions/ | |
The complete list of all my programming interview question articles with pointers to original posts. There are 28 questions in total, and since 28 is a perfect number (as Donald Knuth also mentioned) I decided that’s a good place to stop. | |
1. Array Pair Sum | |
Given an integer array, output all pairs that sum up to a specific value k. | |
2. Matrix Region Sum | |
Given a matrix of integers and coordinates of a rectangular region within the matrix, find the sum of numbers falling inside the rectangle. Our program will be called multiple times with different rectangular regions from the same matrix. |
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
package cccc; | |
public class PatternInMatrix { | |
static boolean used[][]; | |
public static boolean findPattern(char[][] matrix, int nRow, int nCol, char[] pattern) { | |
used = new boolean[nRow][nCol]; | |
for (int i = 0; i < nRow; i++) | |
for (int j = 0; j < nCol; 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
public class TripleT { | |
enum State{Blank, X, O}; | |
int n = 3; | |
State[][] board = new State[n][n]; | |
int moveCount; | |
void Move(int x, int y, State s){ | |
if(board[x][y] == State.Blank){ |
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
//Following test case assumes you have express js server running at port 5000 and has api /api/login | |
var should = require('should'); | |
var assert = require('assert'); | |
var request = require('supertest'); | |
var winston = require('winston'); | |
describe('Routing', function() { | |
var url = 'http://localhost:5000'; |
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 static int distance(String s1, String s2){ | |
int edits[][]=new int[s1.length()+1][s2.length()+1]; | |
for(int i=0;i<=s1.length();i++) | |
edits[i][0]=i; | |
for(int j=1;j<=s2.length();j++) | |
edits[0][j]=j; | |
for(int i=1;i<=s1.length();i++){ | |
for(int j=1;j<=s2.length();j++){ | |
int u=(s1.charAt(i-1)==s2.charAt(j-1)?0:1); | |
edits[i][j]=Math.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
public class LongtCompoundWord { | |
public static void main(String[] args) { | |
String words[] = { "cat", "cats", "catsdogcats", "catxdogcatsrat", "dog", "dogcatsdog", "hippopotamuses", | |
"rat", "ratcat", "ratcatdog", "ratcatdogcat" }; | |
// ratcatdogcat | |
System.out.println("Longest Compound word : " + longestCompundWord(words)); | |
} | |
private static String longestCompundWord(String[] words) { |
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
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML. | |
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/ | |
export DOCKER_USER=Type your dockerhub username, same as when you `docker login` | |
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login` | |
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login` | |
kubectl create secret docker-registry myregistrykey \ | |
--docker-server=$DOCKER_REGISTRY_SERVER \ | |
--docker-username=$DOCKER_USER \ |
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 LinkedList { | |
private ListNode firstNode; | |
private ListNode lastNode; | |
private int size; | |
/** | |
* For the no-args constructor, the data and next will be null (empty list) | |
*/ | |
public LinkedList() { |
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
package com.interview.graph; | |
import java.util.HashSet; | |
import java.util.Set; | |
/** | |
* http://www.careercup.com/question?id=14942063 | |
*/ | |
public class Boggle { |
NewerOlder