摘要:
public boolean isValid(String s){ Stack<Character> stack = new Stack<>(); Map<Character, Character> map = new HashMap<>(); map.put('{', '}'); map.put( 阅读全文
摘要:
class MinStack{ private Stack<Integer> dataStack = new Stack<Integer>(); private Stack<Integer> minStack = new Stack<Integer>(); public void push(int 阅读全文
摘要:
class MyStack{ private Queue<Integer> queue = new LinkedList<>(); public void push(int x){ queue.add(x); int cnt = queue.size(); while(cnt-->1){ queue 阅读全文
摘要:
class MyQueue{ private Stack<Integer> in = new Stack<>(); private Stack<Integer> out = new Stack<>(); public void push(int x){ in.push(x); } public in 阅读全文
摘要:
Input: [[1,1,0], [1,1,0], [0,0,1]] Output: 2 Explanation:The 0th and 1st students are direct friends, so they are in a friend circle. The 2nd student 阅读全文
摘要:
Input: 11000 11000 00100 00011 Output: 3 public int numIslands(char[][] grid){ if(grid==null || grid.length==0){ return 0; } int islandNum = 0; for(in 阅读全文
摘要:
[[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,1,1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,1,0,0,1,0,1,0,0], [0,1,0,0,1,1,0,0,1,1,1,0,0], [0,0 阅读全文
摘要:
Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"] Output: 5 Explanation: As one shortest transformation is " 阅读全文
摘要:
For example, Given board = [ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E'] ] word = "ABCCED", -> returns true, word = "SEE", -> returns true 阅读全文
摘要:
private static final String[] KEYS = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; public List<String> letterCombinations(String digits){ 阅读全文