Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Problem – Scramble String LeetCode Solution We can scramble a string s to get a string t using the following algorithm: If the length of the string is 1, stop. If the length of the string is > 1, do…
Problem – Gray Code LeetCode Solution An n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n – 1], The first integer is 0, An integer appears no more than once in the sequence, The binary representation of every pair of adjacent integers…
Problem – Subsets II LeetCode Solution Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Example 2: Constraints: 1 <= nums.length <= 10…
Problem – Reverse Linked List II LeetCode Solution Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list. Example 1: Example 2: Constraints: The number of…
Problem – Restore IP Addresses LeetCode Solution A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. For example, “0.1.2.201” and “192.168.1.1” are valid IP addresses, but “0.011.255.245”, “192.168.1.312” and “192.168@1.1” are invalid IP addresses. Given a string s containing only digits, return all possible valid…
Problem – Unique Binary Search Trees LeetCode Solution Given an integer n, return the number of structurally unique BST’s (binary search trees) which has exactly n nodes of unique values from 1 to n. Example 1: Example 2: Constraints: 1 <= n <= 19 Unique Binary Search Trees…
Problem – Interleaving String LeetCode Solution Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2. An interleaving of two strings s and t is a configuration where s and t are divided into n and m non-empty substrings respectively, such that: s = s1 + s2 + … + sn t = t1 + t2 + … + tm |n…
Problem – Recover Binary Search Tree LeetCode Solution You are given the root of a binary search tree (BST), where the values of exactly two nodes of the tree were swapped by mistake. Recover the tree without changing its structure. Example 1: Example 2: Constraints:…
Problem – Binary Tree Level Order Traversal II LeetCode Solution Given the root of a binary tree, return the bottom-up level order traversal of its nodes’ values. (i.e., from left to right, level by level from leaf to root). Example 1: Example 2:…
Problem – Convert Sorted List to Binary Search Tree LeetCode Solution Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as…