摘要:
There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary i 阅读全文
摘要:
public static int repeatedStringMatch(String A, String B) { //判断字符串a重复几次可以包含另外一个字符串b,就是不断叠加字符串a直到长度大于等于b,叠加一次计数+1 //看现在的字符串是否包含b,包含就返回,不会包含就再叠加一次,因为可能有半截的在后边,再判断,再没有就返回-1 int ... 阅读全文
摘要:
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文
摘要:
public boolean canIWin(int maxChoosableInteger, int desiredTotal) { //两种特殊情况,一是目标比最大值小,二是把所有可能取值加起来都没有目标大 if (desiredTotal map = new HashMap(); //为了处理方便,这里下标从1开始,正好和数字对应 ... 阅读全文