Merge Two/K Sorted List

  Merge Two Sorted Lists Iterative Walk through two lists and append the smaller node to the end of the final list. If exhaust one list, append the other list directly to the final list. Note that append a node to the end of the list is a common operation. Implement a helper method does […]

Skyline Problem

Given an array of buildings in the form of [L, R, H], return the skyline in the form of change points. Digitizing Approach (Performs worse if building is very wide) The idea is to find the left-most and right-most point of all the buildings. And create an array of that length representing current skyline. Then […]

Move Zeros

Given an array. Move all the zeros to the right end. Try to minimize number of operations. Naive Solution The is the naive solution. Walk through the array while maintain a pointer points to the position to insert the 0 (initialize to len – 1). For each element, if not zero, move to the next. […]