Data Structures

1.2) Binary Tree

A Binary Tree is a type of data structure where each node can have at most two children. It's like a branching structure where each node has the potential to…

Find K Pairs with Smallest Sum

You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and two integers k and target. Find k pairs (a, b) from the arrays such that a…

Merge K Sorted Lists

You are given an array of k linked lists, each linked list is sorted in ascending order. Merge all the linked lists into one sorted linked list and return it.

3.3) N-ary Tree Level Order Traversal

Given the root of an N-ary tree, return the level order traversal of its nodes' values. Level order traversal means visiting all nodes at each level from left to right…

3.2) Minimum Depth of Binary Tree

Given a binary tree, find the minimum depth of the tree. The minimum depth is defined as the minimum distance from the root node to the nearest leaf node. A…

2.9) Find All The Lonely Nodes

Given the root of a binary tree, a lonely node is a node that has no siblings (i.e., it's the only child of its parent). Return an array containing the…

Range Sum of BST

Given the root of a binary search tree (BST), and integers low and high, find the sum of all node values in the BST that are within the range .

2.7) Diameter of Binary Tree

Given a binary tree, find the length of the longest path between any two nodes in the tree. This path may or may not pass through the root.

3.1) Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.