摘要:
Tips: Tried to use a private method to simplize the code. But found that object is passed by reference. So even if you have ListNode as l, and l = l.n 阅读全文
摘要:
FOLLOW UPS: What if the input is coming streaming and you cannot even store the window? But you can store the checked String. I purposed this algorith 阅读全文
摘要:
Tips : 1. Need to new array list since it is passed by reference. All the values will be cleaned up the original data is used. 2. For iteraive, no nee 阅读全文
摘要:
1 public class Solution { 2 public String alienOrder(String[] words) { 3 if (words.length == 0) { 4 return ""; 5 } 6 StringBuilder result = new StringBui... 阅读全文
摘要:
1 public class Solution { 2 public int kthSmallest(int[][] matrix, int k) { 3 if (matrix.length == 0 || matrix[0].length == 0 || k queue = new PriorityQueue(); 7 for (int i =... 阅读全文
摘要:
1 public class PhoneDirectory { 2 private boolean[] nums; 3 private Queue queue; 4 /** Initialize your data structure here 5 @param maxNumbers - The maximum numbers that can ... 阅读全文
摘要:
1 public class Solution { 2 public int[][] multiply(int[][] A, int[][] B) { 3 int aM = A.length, aN = A[0].length, bN = B[0].length; 4 int [][] result = new int[aM][bN]; 5 ... 阅读全文