Feb 6 · 2 min read · 🧠 Brute Force Approach (Not Optimal) A simple way is: Convert linked list into an array Check if array is palindrome But this uses extra memory: Time: O(n) Space: O(n) ❌ 🧠Optimal Approach 1. Find the Middle of the Linked List We use two poi...
Join discussion
Jan 7 · 4 min read · After solving the “find maximum number in an array” problem yesterday, I didn’t want to jump into something new immediately. I wanted to stay with the same concept and really let it sink in. So today, I picked the opposite version of the same problem...
Join discussion
Jan 25, 2025 · 8 min read · Introduction Divide and conquer is a well-known recursion technique for solving problems. It solves a problem by breaking it into smaller, easier-to-solve problems, solving each problem separately and combining their solutions to address the original...
Join discussion
Jan 20, 2025 · 3 min read · In JavaScript, handling 2D matrices (also known as 2D arrays) is a common requirement when working with grids, tables, or spatial data. A 2D matrix is essentially an array of arrays, where each inner array represents a row of elements. Initializing a...
Join discussionNov 17, 2024 · 20 min read · Have you ever poured your heart and soul into writing what you believed to be the pinnacle of code excellence, only to have your confidence shattered by your colleague having much better code? Then, during the code review, the senior trashes you and ...
Join discussion
Sep 15, 2024 · 3 min read · for...of from MDN The for...of statement runs a loop that works on a sequence of values from an iterable object. Iterable objects include instances of built-ins such as Array, String, Type Array, Map, Set, NodeList, etc syntax for…of for (let variab...
Join discussion
Jul 27, 2024 · 3 min read · Question Description: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Examples: Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output: ["...
Join discussionJun 14, 2024 · 2 min read · I recently interviewed for Shopflo, and here is all the information that I can provide. Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to ...
Join discussionJun 7, 2024 · 1 min read · Now I will explain the solve of Rotate sting leetcode easy problem solve in javascript. The question is Given two strings s and goal, return trueif and only ifscan becomegoalafter some number ofshiftsons. A shift on s consists of moving the leftmost ...
Join discussion