摘要:
Use one queue + size variable 1 public class Solution { 2 public ArrayList> levelOrder(TreeNode root) { 3 ArrayList result = new ArrayList... 阅读全文
摘要:
QuestionGivennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in th... 阅读全文
摘要:
对于此类问题:对于元素nums[i],找出往左/右走第一个比它小/大的数字我们常常用递增栈/递减栈实现。递增栈实现第一个比它小递减栈实现第一个比它大Example: 2 1 5 6 2 3stack: 保证栈是递增的顺序,因此每个数进来之前先删除栈里比它大的数字。 因此每个数,当它被... 阅读全文
摘要:
Linear data structure.First In Last Out.push: O(1) pop: O(1) peek: O(1)In Java, there is aStackclass.A more complete and consistent set of LIFO stac... 阅读全文
摘要:
OutlineLinear Data StructureQueueStackHashTree Data StructureHeapDefinitionData Structure is a way to organize data. It provides some methods to handl... 阅读全文
摘要:
QuestionGiven an array of non-negative integers. Find the largest multiple of 3 that can be formed from array elements.For example, if the input array... 阅读全文
摘要:
QuestionAcomplete binary treeis a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as p... 阅读全文
摘要:
QuestionGiven an array of n integer with duplicate number, and a moving window(size k), move the window at each iteration from the start of the array,... 阅读全文
摘要:
QuestionGiven an unsorted arraynums, reorder itin-placesuch thatnums[0] = nums[2] = nums[2] nums[i - 1])11 swap(nums, i, i - 1);1... 阅读全文
摘要:
QuestionGiven two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 = [3, 4, 5, 6... 阅读全文