Solutions with approach notes, complexity, and final code.
Given an integer array nums of unique elements, return all possible subsets (the power set).
Serialize and deserialize the binary tree
A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root.The path sum of a path is the sum of the node's values in the path. Given the root of a binary tree, return the maximum path sum of any non-empty path.
Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.
Given root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.
Given the root of a binary tree, determine if it is a valid binary search tree (BST).
Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.Return the number of good nodes in the binary tree.
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right level by level).
Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.
Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value
Given a binary tree, determine if it is height-balanced.
Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.The length of a path between two nodes is represented by the number of edges between them.
Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Invert binary tree
Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is. You may not alter the values in the list's nodes, only nodes themselves may be changed.
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. You must solve the problem without modifying the array nums and using only constant extra space.
Given an array find the maximum find the maximum of k elements in the array while sliding the array to right.
Given 2 strings check if the second string is a substring of first string with a minimum window
given 2 arrays find the median of it
Given 2 strings check if they are anagrams
Set approach to find if the array contains duplicate
Group Anagrams
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.
given 2 reviersed linked list add provide the result
given 2 reviersed linked list add provide the result
Implementation of Browser history in a single tab
Sentinel-node + contract-driven subsystems for a clean linked list implementation.
O(1) extra space deep copy by weaving clones into the original list.
Given a discription create a binary tree.
One-pass hash map approach to find the complement.