摘要:
This problem can be solved by using two PriorityQueue(s), which is just the same solution as 295. Find Median from Data Stream. PriorityQueue<Integer> 阅读全文
摘要:
So easy! public void merge(int[] nums1, int m, int[] nums2, int n) { int i = m-1, j = n-1, index = nums1.length-1; while(i>=0 && j>=0){ if(nums2[j]>=n 阅读全文
摘要:
This problem can be solved by bicket sorting. Although the problem only requires the number is 1~9, but my solution can be extended to any number sent 阅读全文
摘要:
This is a super easy problem. Time Compexity O(n), Space Complexity O(n) int res = 0; public int getDecimalValue(ListNode head) { if(head==null) retur 阅读全文
摘要:
This problem has three kinds of situations: 1. [0,0,1,1,1,] -> 0s start from i=0, the plant count = zeroNumber/2. 2.[1,0,0,0,1] -> 0s are in between 1 阅读全文
摘要:
My PriorityQueue solution, the time complexity is O(n+klog(k)) = O(nlog(n)). class IndexDistance{ int index; int distance; public IndexDistance(int a, 阅读全文