摘要:
186. Reverse Words in a String II 先反转整个字符串,再反转每个单词(调整顺序也可以) 反转单词的时候:当 j 指到最后一个字符的时候,或者 j 的下一个指向空格,则反转该单词。 class Solution { public void reverseWords(ch 阅读全文
摘要:
277. Find the Celebrity knows(i, j): By comparing a pair(i, j), we are able to discard one of them 1. True: i 必定不是Celebrity, 因为Celebrity不认识任何人 2. Fals 阅读全文
摘要:
179. Largest Number 冒泡排序,每一轮都把最小的数字选出放在最后。 class Solution { public String largestNumber(int[] nums) { for(int i = 0; i < nums.length; i++){ for(int j 阅读全文
摘要:
212. Word Search II class TrieNode{ char val; TrieNode[] children; String word; public TrieNode(char x){ children = new TrieNode[26]; word = null; } } 阅读全文
摘要:
150. Evaluate Reverse Polish Notation class Solution { public int evalRPN(String[] tokens) { Stack<Integer> stack = new Stack<Integer>(); for(int i = 阅读全文