LeetCode 62: Unique Paths (Dynamic Programming, Combinatorics)
Problem Description
A robot is located at the top - left corner of an m x n grid (marked 'Start'). The robot can only move either down or right at any point. The goal is to reach the bottom - right corner (marked 'Finish'). We need to determine the number of unique paths possible.
Examples
Example 1:
Input: rows = 3, cols = 7
Output: 28
Exampl ...
Posted on Sat, 16 May 2026 05:47:43 +0000 by ansarka
LeetCode Problem Solutions: Sliding Window and Hash Table Techniques
Trpaping Rain Water Problem
Given an array representing elevation maps, this problem calculates how much water can be trapped between bars after raining.
vector<int> leftMax(n, 0);
vector<int> rightMax(n, 0);
if (n == 0) return 0;
leftMax[0] = height[0];
rightMax[n-1] = height[n-1];
for (int i = 1; i < n; ++i) {
leftMax[i] = ...
Posted on Fri, 15 May 2026 23:00:45 +0000 by jck
Ambiguous Coordinate Generation Algorithm
Problem Analysis
Given a string containing only digits within parentheses, the task is to generate all valid coordinate pairs that could have produced the original string when punctuation was removed. The coordinates must adhere to specific formatting rules: no leading or trailing zeros in decimal components, and decimal points must be preceded ...
Posted on Wed, 13 May 2026 14:32:49 +0000 by nevynev
Hash Table Applications in LeetCode Top Interview Questions
Hash table are primarily used to store key-value mappings, enabling efficient lookups. They exemplify a time-space tradeoff—using extra memory to reduce time complexity for search operations.
Two Sum
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Because nums[0] + nums[1] == 9.
A naive approach uses nested loops, resulting in O(n²) time co ...
Posted on Wed, 13 May 2026 11:27:49 +0000 by vipul73
Finding the Maximum Number of Vowels in a Fixed-Length Substring
Given a string s and an integer k, the objective is to determine the highest possible count of vowel letters within any contiguous substring of length k. Vowel letters are defined as 'a', 'e', 'i', 'o', 'u'.
A sliding window approach provides an efficient solution. The algorithm first calculates the vowel count in the initial window of size k. ...
Posted on Wed, 13 May 2026 10:20:16 +0000 by invictive
Understanding Dynamic Programming Fundamentals with Practical Examples
Core Concept of Dynamic Programming
Dynamic Programming (DP) is an algorithmic technique used when a problem exhibits overlapping subproblems and optimal substructure. Unlike greedy algorithms—which make locally optimal choices without considering previous states—DP builds solutions incrementally, where each state is derived from one or more pr ...
Posted on Mon, 11 May 2026 06:57:52 +0000 by PeeJay
Dynamic Programming Solutions for House Robber Problems
House Robber I - Linear Array Problem
The classic House Robber problem involves maximizing the amount of money that can be stolen from a line of houses, where adjacent houses cannot be robbed on the same night.
class Solution {
public:
int maxLoot(vector<int>& values) {
int houseCount = values.size();
if (houseCoun ...
Posted on Sun, 10 May 2026 23:26:35 +0000 by AL-Kateb
Backtracking for Combination Sum, Combination Sum II, and Palindrome Partitioning
39. Combination Sum
Problem: https://leetcode.cn/problems/combination-sum/description/
Find all unique combinations of candidates where the chosen numbers sum to target. The same number may be used a unlimited number of times.
class Solution {
public:
vector<vector<int>> combinationSum(vector<int>& candidates, int targ ...
Posted on Sun, 10 May 2026 15:26:59 +0000 by Jedi Legend
LeetCode Daily Challenge: Convert to 2D Array
Given an integer array nums, construct a 2D array that satisfies the following conditions:
The 2D array should contain only elements from the array nums.
Each row of the 2D array must consist of distinct itnegers.
The number of rows should be minimized.
Return any valid result. If multiple solutions exist, any one is acceptable.
Note: Rows in ...
Posted on Sun, 10 May 2026 15:14:55 +0000 by songwind
Merging Sorted Linked Lists Efficiently
Given two singly-linked lists that are already sorted in ascending order, produce a single sorted linked list that interleaves all node from both input lists.
Examples
Input: list1 = [1, 2, 4], list2 = [1, 3, 4]
Output: [1, 1, 2, 3, 4, 4]
Input: list1 = [], list2 = []
Output: []
Input: list1 = [], list2 = [0]
Output: [0]
Implementation strate ...
Posted on Sat, 09 May 2026 16:57:09 +0000 by quercus