CODEBUG.AI
5d
Lvl 4
450
Sign In
Personal Knowledge Base & DSA Cheatsheets

My Study Notes & Code Snippets

Save algorithm cheat sheets, interview revision notes, and code snippets in your secure cloud workspace.

Algorithms2026-07-20

Two Pointers Pattern for Array Problems

Use left and right pointers when working on sorted arrays or searching pair sums to reduce O(N^2) brute force to O(N).

Linked List2026-07-21

Fast & Slow Pointer (Floyd Cycle Detection)

Advance slow pointer 1 step and fast pointer 2 steps. If there is a cycle, fast will eventually meet slow inside the loop.

System Design2026-07-22

System Design: Consistency vs Availability (CAP Theorem)

In distributed systems under network partition (P), you must choose between Consistency (all nodes see same data) or Availability (every request gets a response).

Algorithms Note

Two Pointers Pattern for Array Problems

Use left and right pointers when working on sorted arrays or searching pair sums to reduce O(N^2) brute force to O(N).

Attached Code Snippet
def two_sum(nums, target):
    left, right = 0, len(nums) - 1
    while left < right:
        curr = nums[left] + nums[right]
        if curr == target: return [left, right]
        elif curr < target: left += 1
        else: right -= 1