LC23 Merge k Sorted Lists

Main idea: instead of loop through K lists and find the minimun val, use D&C to merge per 2 lists first so k lists turn into k/2 with avg length N/(k/2), then into k/4 and so on; time complexity: each time we traverse almost N nodes, but repeat this procedure... [Read More]

1021. Remove Outermost Parentheses

key question to solving this problem: how to identify if parentheses is outermost?? here we can see nested parentheses and seperate several nested parentheses. One feature of a parentheses is it always appear in pairs. So we may think of using counter to increment when encounting open parentheses and decrement... [Read More]
Tags: Stack

88. Merge Sorted Array

main idea: there are two thoughts to start inserting number with correct order - 1. start with smallest 2. start with largest; but the problem with start with smallest is that once number from nums2 need to occupy non-empty position in nums1, it’s hard to reposition original number in nums1;... [Read More]