K 40 minimum number of immediately solving
Problem-solving ideas
K is the minimum size of the heap
Complexity: O (NlogK) + O (K)
Particularly suitable for handling mass data
You should be used to maintain the minimum heap big top heap, not to create a small top and set up a direct heap size, attempting to make the top of the heap of small elements are the smallest elements.
Maintaining a minimum size for the heap process K as follows: after the addition of an element, if a large size is larger than the top of the heap K, then the top of the stack needs to be big top element of the stack is removed.
Code
41.1 median data stream immediately solving
Title Description
How to get the median of a data stream? If the numerical value is read from the odd data stream, then the median value is located in the middle of all values after sorting. If an even number value is read out from the data stream, then the median is the average of two numbers after all intermediate values of order.
Code
41.2 the first character stream will not be repeated character immediately Solving
Title Description
Please implement a function to find the character stream for the first time a character appears only. For example, when the character stream reads only the first two characters "go", the first character only occurs once a "g". When reading out the first six characters "google" from the character stream, first appears only one character is "l".
Code
42 and the maximum continuous subarray immediately Solving
Title Description
{6, -3, -2, 7, -15, 1, 2, 2}, and the maximum continuous subarray 8 (beginning from 0, up to the third).
Code
43. The number appearing in an integer of from 1 to n 1 once solving Leetcode: 233. Number of Digit One
Code
Reproduced in: https: //www.jianshu.com/p/75a8dbe28c4e