241. Different Ways to Add Parentheses Leetcode Solution

Different Ways to Add Parentheses Difficulty: Medium Topics: Math, String, Dynamic Programming, Recursion, Memoization Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return the answer in any order. The test cases are generated such that the output […]
237. Delete Node in a Linked List Leetcode Solution

Delete Node in a Linked List Difficulty: Medium Topics: Linked List There is a singly-linked list head and we want to delete a node node in it. You are given the node to be deleted node. You will not be given access to the first node of head. All the values of the linked list […]
214. Shortest Palindrome Leetcode Solution

Shortest Palindrome leetcode Solution Difficulty: Hard Topics: String, Rolling Hash, String Matching, Hash Function You are given a string s. You can convert s to a palindrome[^1] by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation. Example 1: Input: s = “aacecaaa” Output: “aaacecaaa” Example 2: […]
205. Isomorphic Strings leetcode Solution

Isomorphic Strings Difficulty: Easy Topics: Hash Table, String Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No […]
200. Number of Islands Leetcode Solution

Number of Islands Difficulty: Medium Topics: Array, Depth-First Search, Breadth-First Search, Union Find, Matrix Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You […]
179. Largest Number Leetcode Solution

179. Largest Number Leetcode Solution Difficulty: Medium Topics: Array, String, Greedy, Sorting Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an integer. Example 1: Input: nums = [10,2] […]
165. Compare Version Numbers Leetcode Solution

Compare Version Numbers Leetcode Solution Difficulty: Medium Topics: Two Pointers, String Given two version numbers, version1 and version2, compare them. Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revisions are 0-indexed from left […]
145. Binary Tree Postorder Traversal Leetcode Solution

Binary Tree Postorder Traversal Leetcode Solution: Difficulty: Easy Topics: Stack, Tree, Depth-First Search, Binary Tree Given the root of a binary tree, return the postorder traversal of its nodes’ values. Example 1: Input: root = [1,null,2,3] Output: [3,2,1] Example 2: Input: root = [] Output: [] Example 3: Input: root = [1] Output: [1] Constraints: […]
140. Word Break II Leetcode Solution

Word Break II Difficulty: Hard Topics: Array, Hash Table, String, Dynamic Programming, Backtracking, Trie, Memoization Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note that the same word in […]
131- Palindrome Partitioning Leetcode Solution

Palindrome Partitioning Leetcode Solution Difficulty: Medium Topics: String, Dynamic Programming, Backtracking Given a string s, partition s such that every substring[^1] of the partition is a palindrome[^2]. Return all possible palindrome partitioning of s. Example 1: Input: s = “aab” Output: [[“a”,”a”,”b”],[“aa”,”b”]] Example 2: Input: s = “a” Output: [[“a”]] Constraints: 1 <= s.length <= […]