Sunday, December 4, 2016

  1. Find the maximum rectangle under a histogram 
Initialize the return value 
For each histogram top as the top left of the rectangle, 
Find the span it has across the histogram 
If this area is greater than max, update max 
Return max 
  1.  Sort n colored objects which are red, white and blue 
First pass put all the reds together by exchanging contiguous positions with red only 
Second pass put all the whites together. 
  1. Largest subarray sum - Kadane’s algorithm 
Initialize  
max_so_far = 0 
max_ending_here = 0 
For each element of the array 
                max_ending_here = max(0, max_ending_here+ A[i]) 
                max_so_far  = max(max_so_far, max_ending_here) 
Alternatively
Initialize and maintain the following variables
x = sum of elements
y = minimum of sum encountered
z = maximum of sum encountered
For each element of the array
           y = min(x, y)
           z = max(z, x-y)
                 
  1. Get CRC 
                Pad a message buffer to length n 
                Initialize last to the index of the first element of the excess from given polynomial 
                For each character at index from 0 to last 
                                Xor the message with the polynomial at this char if the message has value 
                Return the excess portion of the xor result.

More here : https://1drv.ms/w/s!Ashlm-Nw-wnWljrS9T48GT29eGu0 

No comments:

Post a Comment