Coin Change Problem: Finding Minimum Coins Using Dynamic Programming

Problem Statement Given a integer array coins representing different coin denominations and an integer amount representing the target total, find the minimum number of coins needed to make up that amount. If it's impossible to form the amount with the given coins, return -1. You have an unlimited supply of each coin denomination. Examples Examp ...

Posted on Wed, 14 Oct 2026 16:25:54 +0000 by remlabm

Zigzag Pattern String Conversion Algorithm

Problem Description Given a string s and a positive integer numRows, arrange the characters of s in a zigzag pattern across numRows rows, then read the result row by row to produce the final string. Constraints s contains English letters (both lowercase and uppercase), commas, and periods 1 <= numRows <= 1000 Solution Approaches Approac ...

Posted on Mon, 12 Oct 2026 16:37:04 +0000 by XxDeadmanxX

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

Given a rectangular cake of height h and width w, and two integer arrays horizontalCuts and verticalCuts where horizontalCuts[i] is the distance from the top of the cake to the i-th horizontal cut and verticalCuts[j] is the distance from the left side of the cake to the j-th veritcal cut, return the maximum area of a peice of cake after you cut ...

Posted on Sun, 11 Oct 2026 16:56:14 +0000 by froggie81

Finding the Longest Common Prefix in an Array of Strings Using C++

Determine the longest common prefix among a collection of strings. If no common prefix exists, return an emppty string "". Examples: Example 1: Input: strings = ["flower","flow","flight"] Output: "fl" Example 2: Input: strings = ["dog","racecar","car"] Output: &quo ...

Posted on Sun, 11 Oct 2026 16:42:31 +0000 by ganeshasri

Array Concatenation - LeetCode 1929 Solution

Problem Description Given a integer array nums of length n, create a new array ans of length 2 * n that satisfies the following conditions for all indices 0 ≤ i < n: ans[i] equals nums[i] ans[i + n] equals nums[i] In other words, the resulting array ans is formed by concatenating two copies of the original nums array. Constraints n = nums ...

Posted on Sun, 11 Oct 2026 16:23:58 +0000 by AliceG

Implementing a Word Search Algorithm in a 2D Grid

This problem can be efficiently solved using a depth-first search (DFS) algorithm with backtracking. The core idea is to traverse each cell of the grid and check if it can start a valid path that forms the target word. Key Concepts The grid trvaersal here is a variation of binary tree DFS, where each cell (node) has four possible adjacent direc ...

Posted on Sun, 11 Oct 2026 16:19:13 +0000 by sebajom

Solving LeetCode 977: Squares of a Sorted Array Using Two Pointers

LeetCode 977 – Squares of a Sorted Array Algorithm: Two‑pointers After squaring, the largest numbers are at the two ends of the array, while the smallest numbers gather in the middle. This naturally suggests using a pointer at the start and a pointer at the end. Modifying the original array in place can accidentally overrwite elements that hav ...

Posted on Wed, 07 Oct 2026 16:07:39 +0000 by vandalite

Solutions for N-ary Tree Traversals, Valid Parentheses, Binary Tree Inorder, and Subsequence Counting

N-ary Tree Preorder Traversal Given the root of an n-ary tree, return the preorder traversal of its nodes' values. /* class Node { public: int val; vector<Node*> children; Node() {} Node(int _val) { val = _val; } Node(int _val, vector<Node*> _children) { val = _val; children = _children; } }; ...

Posted on Tue, 06 Oct 2026 16:32:48 +0000 by mechamecha

Backtracking Algorithm Fundamentals and LeetCode 77. Combinations

Backtracking Algorithm Fundamentals Backtracking is essentially an exhaustive search approach optimized to avoid writing nested loops of variable depths, which becomes impractical for large datasets. Key problem types backtracking solves: Combination problems: Find all valid k-element subsets from an n-element set Permutation problems: Determi ...

Posted on Tue, 06 Oct 2026 16:18:15 +0000 by undecided name 01

Frequently Asked SQL Problems on Leetcode

1757. Products With High Fat and Recylcable Flag Initial attempt: SELECT product_id FROM Products WHERE low_fats == 'Y' AND recyclable == 'Y' Corrected version: SELECT product_id FROM Products WHERE low_fats = 'Y' AND recyclable = 'Y' 584. Find Customer Referee Initial attempt: SELECT DISTINCT name FROM Customer WHERE referee_id != 2 Revised ...

Posted on Mon, 05 Oct 2026 16:52:36 +0000 by elacdude