新农上路
- 积分
- 95
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2016-4-7
- 最后登录
- 1970-1-1
|
2/18:
Reading:
http://wiki.c2.com/?TailRecursion
AWS - intro to db service
LC:
993. Cousins in Binary Tree
988. Smallest String Starting From Leaf
100. same tree
160. Intersection of Two Linked Lists
69. Sqrt(x)
70. Climbing Stairs
746. Min Cost Climbing Stairs
educative.io
Binary Search
Sum of Two Values
Reverse a singly linked list
Intersection Point of Two Lists
Check if two binary trees are identical
Fibonacci Numbers
Boggle: cannot pass test case but the print result is the same(different order)
- class boggle {
- char[][] mGrid;
- HashSet<String> mDic;
- boggle(char[][] grid, HashSet<String> dictionary){
- mGrid = grid;
- mDic = dictionary;
- }
-
- public HashSet<String> find_all_words(){
- //TODO: Write - Your - Code
- HashSet<String> result = new HashSet<String>();
- for (String word: mDic) {
- for (int i = 0; i < mGrid.length; i++) {
- for (int j = 0; j < mGrid[0].length; j++) {
- if (found(word, new boolean[mGrid.length][mGrid[0].length], i, j, 0)) result.add(word);
- }
- }
- }
- return result;
- }
-
- public boolean found(String word, boolean[][] used, int i, int j, int k) {
- if (i < 0 || i >= mGrid.length || j < 0 || j >= mGrid[0].length || used[i][j]) return false;
- if (k == word.length()) return true;
- if (mGrid[i][j] == word.charAt(k)) {
- used[i][j] = true;
- for (int m = -1; m < 2; m++) {
- for (int n = -1; n < 2; n++) {
- if (found(word, used, i + m, j + n, k + 1)) return true;
- }
- }
- used[i][j] = false;
- }
- return false;
- }
- }
复制代码
Result Input Expected Output Actual Output Reason
find_all_words(c,a,t,r,r,e,t,o,n) art,ton,not,cater,cat, art,not,ton,cater,cat, Incorrect Output |
|