Skip to content

Instantly share code, notes, and snippets.

View blindchaser's full-sized avatar

yirenz blindchaser

View GitHub Profile
@blindchaser
blindchaser / LeetCode 50 Pow(x,y)
Created March 10, 2015 04:19
LeetCode 50 Pow(x,y)
public class PowXY {
public static void main(String[] args) {
double x = pow(2,5);
System.out.println(x);
}
public static double pow(double x, int n) {
if (n == 0)
@blindchaser
blindchaser / Rotate Array
Created March 10, 2015 03:25
LeetCode 189 Rotate Array
public class Solution {
public void rotate(int[] nums, int k) {
int length = nums.length;
// if k > length, deal with circulation situation
k = k % length;
if (length == 1)
return;
@blindchaser
blindchaser / CC150 8.1 findKth.java
Created January 16, 2015 02:37
Design the data structures for a generic deck of cards. Explain how you would subclass the data structures to implement blackjack.
/* Title: CC150 8.1 findKth.java
* Time: 20140112
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 抄抄更健康
*
*
@blindchaser
blindchaser / CC150 8.2 callCenter.java
Created January 16, 2015 02:36
8.2 Imagine you have a call center with three levels of employees: respondent, manager, and director. An incoming telephone call must be first allocated to a respondent who is free. If the respondent can't handle the call, he or she must escalate the call to a manager. If the manager is not free or not able to handle it, then the call should be …
/* Title: CC150 8.2 callCenter
* Time: 20140115
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 可以跑
*
*
@blindchaser
blindchaser / CC150 7.7 findKth.java
Created January 13, 2015 01:32
Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7.
/* Title: CC150 7.7 findKth
* Time: 20140112
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 引用了一百个包,引用成马
*
*
@blindchaser
blindchaser / CC150 7.5 twoSquares.java
Created January 12, 2015 05:54
Given two squares on a two-dimensional plane, find a line that would cut these two squares in half. Assume that the top and the bottom sides of the square run parallel to the x-axis.
/* Title: CC150 7.5 twoSquares
* Time: 20140111
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 第六章有点好玩
*
*
@blindchaser
blindchaser / CC150 7.4 Operations.java
Created January 12, 2015 05:54
7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only the add operator.
/* Title: CC150 7.4 Operations
* Time: 20140111
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 第六章有点好玩
*
*
@blindchaser
blindchaser / CC150 6.6 Lockers.java
Created January 12, 2015 05:52
There are 100 closed lockers in a hallway. A man begins by opening all 100 lockers. Next, he closes every second locker. Then, on his third pass, he toggles every third locker (closes it if it is open or opens it if it is closed). This process continues for 100passes, such that on each pass i, the man toggles every ith locker. After his 100th pa…
/* Title: CC150 6.6 Lockers
* Time: 20140111
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 第六章有点好玩
*
*
@blindchaser
blindchaser / CC150 6.3 fourQuart.java
Created January 12, 2015 05:50
You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly"half"of the jug would be impossible.
/* Title: CC150 6.3 fourQuart
* Time: 20140111
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 第六章有点好玩
*
*
@blindchaser
blindchaser / CC150 6.2 colorProblem.java
Created January 12, 2015 05:50
There is an 8x8 chess board in which two diagonally opposite corners have been cut off. You are given 31 dominos(多米诺骨牌), and a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board? Prove your answer (by providing an example or showing why it's impossible).
/* Title: CC150 6.2 colorProblem
* Time: 20140111
* Creator: blindchaser
* Time Complexity:
* Space Complexity:
* 优空间解法
* 优时间解法:
* 心得: 看了书里的答案,不可能。 单复数上色问题
*
*