Easy

106 articles

dsa1 min read

Reverse Bits — 32-Bit Reversal

Reverse bits of a 32-bit unsigned integer. Shift result left and input right 32 times, taking last bit each time.

Read →
dsa1 min read

Climbing Stairs — Fibonacci DP

Count ways to climb n stairs taking 1 or 2 steps. Classic Fibonacci DP — dp[n] = dp[n-1] + dp[n-2] with O(1) space.

Read →
dsa1 min read

Maximum Subarray — Kadane's Algorithm

Find the contiguous subarray with the largest sum. Kadane's algorithm: either extend previous subarray or start fresh at current element.

Read →
dsa2 min read

Last Stone Weight

Simulate stone smashing by repeatedly extracting the two heaviest stones using a max-heap.

Read →
dsa2 min read

Relative Ranks

Assign gold/silver/bronze or rank numbers to athletes based on their scores using sorted ordering.

Read →
dsa2 min read

Cousins in Binary Tree

Determine if two nodes are cousins (same depth, different parents) using BFS to track depth and parent.

Read →