Generate Parentheses Leetcode Solution

Problem Statement The Generate Parentheses LeetCode Solution – “Generate Parentheses” states that given the value of n. We need to generate all combinations of n pairs of parentheses. Return the answer in the form of a vector of strings of well-formed parentheses. Example: Input: n = 3 Output: [“((()))”,”(()())”,”(())()”,”()(())”,”()()()”] Explanation: …

Read more

Longest Substring Without Repeating Characters Leetcode Solution

Problem Statement The Longest Substring Without Repeating Characters LeetCode Solution –  states that given the string s. We need to find the longest substring without repeating characters. Example: Input: s = “abcabcbb” Output: 3 Explanation: The longest substring with no characters being repeated is of length 3. The string is: “abc”. Input: s = “bbbbb” …

Read more

Merge k Sorted Lists Leetcode Solution

Problem Statement The Merge k Sorted Lists LeetCode Solution – “Merge k Sorted Lists” states that given the array of k linked lists, where each linked list has its values sorted in ascending order. We need to merge all the k-linked lists into one single linked list and return the …

Read more

Trapping Rain Water Leetcode Solution

Problem Statement The Trapping Rain Water LeetCode Solution – “Trapping Rain Water” states that given an array of heights which represents an elevation map where the width of each bar is 1. We need to find the amount of water trapped after rain. Example: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: Check …

Read more

Valid Palindrome II Leetcode Solution

Problem Statement The Valid Palindrome II LeetCode Solution – “Valid Palindrome II” states that given the string s, we need to return true if s can be a palindrome string after deleting at most one character. Example: Input: s = “aba” Output: true Explanation: The input string is already palindrome, so there’s …

Read more

Closest Binary Search Tree Value Leetcode Solution

Problem Statement : Closest Binary Search Tree Value Leetcode Solution – Given the root of a binary search tree and a target value, return the value in the BST that is closest to the target. Example : Example 1 Input: root = [4,2,5,1,3], target = 3.714286 Output: 4 Example 2 Input: root = [1], target …

Read more

Binary Tree Right Side View LeetCode Solution

Problem Statement Binary Tree Right Side View LeetCode Solution – Given the root of a binary tree, imagine yourself standing on the right side of it, and return the values of the nodes you can see ordered from top to bottom. Example Test Case 1: Input: root = [1, 2, 3, null, 5, null, …

Read more

Find Median from Data Stream LeetCode Solution

Problem Statement Find Median from Data Stream LeetCode Solution – The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. For example, for arr = [2,3,4], the median …

Read more

Reformat Date LeetCode Solution

Problem Statement Reformat Date LeetCode Solution – Given a date string in the form Day Month Year, where: Day is in the set {“1st”, “2nd”, “3rd”, “4th”, …, “30th”, “31st”}. Month is in the set {“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”}. Year is in the range [1900, 2100]. Convert the date string …

Read more

Serialize and Deserialize Binary Tree LeetCode Solution

Problem Statement Serialize and Deserialize Binary Tree LeetCode Solution – Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in …

Read more

Translate »