Complete-Preparation

πŸŽ‰ One-stop destination for all your technical interview Preparation πŸŽ‰

View the Project on GitHub

Leetcode Problem 800-899

832. Flipping an Image 🌟

O(N^2) Time and O(1) Space


856. Score of Parentheses 🌟🌟

Using stack

Leetcode Approach 3: Count Cores

Intuition

Algorithm

kkzeng’s explanation:

The key idea is that:

  1. the balance tells you what β€œdepth” you are at since with each β€˜(β€˜ we are increasing the depth by 1 (kind of similar to the concept in Solution 2).
  2. the β€œcores” () are the only structure that provides value, the outer parentheses just add some multiplier to the cores. So we only need to be concerned with those. With those 2 ideas in mind, we are able to calculate how much the β€œcore” is worth directly without having to calculate substructures recursively and then apply multipliers.

E.g. For the example of ( ( ) ( ( ) ) ), with the stack method, we are calculating the inner structure ( ) ( ( ) ) first and then multiplying the score by 2. With the 3rd method, by knowing the depth of the core, we are actually performing this calculation ( ( ) ) + ( ( ( ) ) ).


867. Transpose Matrix 🌟

O(N*M) Time and O(N*M) space


875. Koko Eating Bananas 🌟🌟

Brute force (TLE)

Binary Search (AC)


876. Middle of the Linked List 🌟

O(N) Time solution

O(N) Slow and Fast pointer


881. Boats to Save People 🌟🌟

Greedy Two pointer