Complete-Preparation

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

View the Project on GitHub

Leetcode Problem 600-699

605. Can Place Flowers 🌟


617. Merge Two Binary Trees 🌟

DFS - Recursive

Time complexity: O(n). A total of n nodes need to be traversed. Here, n represents the minimum number of nodes from the two given trees. Space complexity: O(n). The depth of the recursion tree can go upto n in the case of a skewed tree. In average case, depth will be O(log n).

BFS - Iterative

Time complexity: O(n). A total of n nodes need to be traversed. Here, n represents the minimum number of nodes from the two given trees. Space complexity: O(n). The size of queue can go upto n in the case of a skewed tree.

MUST READ:


637. Average of Levels in Binary Tree 🌟

This question is in continuation with A general approach to level order traversal questions series.

Previous Questions

  1. Binary tree level order traversal
  2. Binary tree level order traversal - II
  3. Binary tree zig-zag level order traversal

Recursive Solution

Iterative Solution

Iterative Solution


653. Two Sum IV - Input is a BST 🌟

O(N) Time and O(N) space

O(N) Time and O(N) space

O(hn) Time and O(h) space


662. Maximum Width of Binary Tree 🌟🌟

BFS

DFS


668. Kth Smallest Number in Multiplication Table 🌟🌟🌟

Brute Force

Brute force with reduced space


682. Baseball Game 🌟🌟

Stack Solution


695. Max Area of Island 🌟🌟

DFS - Recursive

BFS - Iterative