Mastering Core Linked List Operations: Removing Elements, Custom Implementation, and Reversal
203. Remove Linked List Elements
This problem requires removing all nodes from a singly linked list that have a specific value. Two common approaches demonstrate key linked list operation patterns: using the original head node directly, and using a dummy head node to unify handling of all nodes.
Aproach 1: Without Dummy Head
When operating with ...
Posted on Tue, 23 Jun 2026 17:06:43 +0000 by murpe
Hash Table Algorithms: Solving Multi-Sum Problems
Hash Table Algorithms: Solving Multi-Sum Problems
4Sum II (LeetCode 454)
Problem Description
Given four integer arrays nums1, nums2, nums3, and nums4, all of length n, return the number of tuples (i, j, k, l) such that:
0 <= i, j, k, l < n
nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0
Example 1:
Input: nums1 = [1,2], nums2 = [-2,-1 ...
Posted on Mon, 22 Jun 2026 16:42:09 +0000 by sanlove
Solving the Two Sum Problem with Python
The objective is to identify two numbers within an integer array that sum up to a specific target value and return their indices. It is assumed that there is exactly one valid solution per input and that an element cannot be used twice.
For example, given the array nums = [2, 7, 11, 15] and target = 9, the function should return [0, 1] becuase ...
Posted on Tue, 16 Jun 2026 17:01:38 +0000 by ciaranmg
Find the Tournament Champion and Rearrange a Binary Grid
Find the Champion in an Array Game
Given a distinct-integer array arr and an integer k, simulate a game where the first two elements compete in each round. The larger value wins, stays at index 0, and the smaller one is moved to the end. The game ends as soon as any value wins k consecutive rounds; that value is the champion.
Examples
arr = [2 ...
Posted on Sun, 14 Jun 2026 16:51:33 +0000 by adders
LeetCode 54: Spiral Matrix and 445: Add Two Numbers II
LeetCode 54: Spiral Matrix
Problem
Given an m x n matrix, return all elements of the matrix in spiral order.
Example 1
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,2,3,6,9,8,7,4,5]
Example 2
Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
Output: [1,2,3,4,8,12,11,10,9,5,6,7]
Approach
Traverse from left to right along the top r ...
Posted on Sun, 14 Jun 2026 16:12:36 +0000 by thebusinesslad
Minimum Adjacent Swaps to Balance Bracket Sequences
A bracket string of even length consists of exactly n/2 opening [ and n/2 closing ] characters. The goal is to determine fewest number of arbitrary index swaps required to transform the string into a valid bracket sequence (one where every closing bracket has a matching opening bracket earlier in the string).
Pairs of matched brackets can be t ...
Posted on Fri, 12 Jun 2026 18:11:11 +0000 by razorsedgeuk
Mastering Two-Pointer Patterns for Algorithmic Problems
283. Move Zeroes
The objective is to reorganize an array such that all non-zero elements are positioned before any zeros. This operation must be performed in-place without allocating additional space for another array.
Instead of using a secondary buffer, we can utilize a tracking pointer to mark the position where the next non-zero element sho ...
Posted on Thu, 11 Jun 2026 17:56:17 +0000 by coldfused
Minimum Money for Guaranteed Win in Guessing Game
Problem Description We're playing a number guessing game with the following rules:
I pick a number between 1 and n.
You guess which number I picked.
Each time you guess wrong, I tell you whether my number is higher or lower.
When you guess a number x and it's wrong, you pay $x.
You win when you guess the correct number. Given n ≥ 1, determine ...
Posted on Tue, 09 Jun 2026 16:59:45 +0000 by void
Binary Search Techniques and Applications
This week's practice focuses on mastering binary search algorithms through LeetCode problems.
The first problem is Binary Search. Below is the implementation:
int search(int* nums, int numsSize, int target) {
int left = 0;
int right = numsSize - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if ( ...
Posted on Mon, 08 Jun 2026 18:45:49 +0000 by canabatz
Understanding and Implementing Stacks for Algorithmic Problem Solving
Stack Fundamentals
A stack is a linear data structure that adheres to the Last-In, First-Out (LIFO) principle. This means the last element added to the stack is the first one to be removed. Operations on a stack are restricted to a single end, known as the top. The other end is called the bottom.
Think of a stack like a stack of plates. You ...
Posted on Sat, 06 Jun 2026 17:34:57 +0000 by Tobeon