CodeSnatch Logo
 ██████╗ ██████╗ ██████╗ ███████╗    ███████╗███╗   ██╗ █████╗ ████████╗ ██████╗██╗  ██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝    ██╔════╝████╗  ██║██╔══██╗╚══██╔══╝██╔════╝██║  ██║██║     ██║   ██║██║  ██║█████╗      ███████╗██╔██╗ ██║███████║   ██║   ██║     ███████║██║     ██║   ██║██║  ██║██╔══╝      ╚════██║██║╚██╗██║██╔══██║   ██║   ██║     ██╔══██║╚██████╗╚██████╔╝██████╔╝███████╗    ███████║██║ ╚████║██║  ██║   ██║   ╚██████╗██║  ██║ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝    ╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝   ╚═╝    ╚═════╝╚═╝  ╚═╝
 ██████╗ ██████╗ ██████╗ ███████╗    ███████╗███╗   ██╗ █████╗ ████████╗ ██████╗██╗  ██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝    ██╔════╝████╗  ██║██╔══██╗╚══██╔══╝██╔════╝██║  ██║██║     ██║   ██║██║  ██║█████╗      ███████╗██╔██╗ ██║███████║   ██║   ██║     ███████║██║     ██║   ██║██║  ██║██╔══╝      ╚════██║██║╚██╗██║██╔══██║   ██║   ██║     ██╔══██║╚██████╗╚██████╔╝██████╔╝███████╗    ███████║██║ ╚████║██║  ██║   ██║   ╚██████╗██║  ██║ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝    ╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝   ╚═╝    ╚═════╝╚═╝  ╚═╝

Learn · Earn · Connect

FeaturesCurriculumAI EngineeringPracticeResourcesCommunityAI HelpEarnPlans

Interview prep for every round.

Guided lessons, step-by-step visualizations, practice problems, and timed mock interviews for coding, system design, behavioral, and AI engineering, from your first Big-O to an AI system design round.

  • No account needed
  • Runs in your browser
  • AI hints with your own key
two-pointers-intro
Try a lesson

Two Pointers (Intro)

Algorithms, lesson 7 of 40

Put one pointer at each end of a sorted array. If the pair adds up to too much, move the right pointer left. Too little, move the left pointer right. Repeat until they meet.

Same 7 numbers, target 12
Check every pair21 checks
Two pointers5 steps
O(n²) pair checks become O(n) steps, with O(1) extra space.
  • Sorted order is what makes each move safe.
  • Each pointer only moves inward, so no pair is checked twice.
  • The same idea solves pair-sum and palindrome questions.
target = 12l = 0r = 6sum = 14

1 + 13 = 14 is larger than 12, so move R one step left.

function pairSum(nums, target) {
let l = 0, r = nums.length - 1;
while (l < r) {
const sum = nums[l] + nums[r];
if (sum === target) return [l, r];
if (sum > target) r--;
else l++;
}
return [];
}
Step 1 of 5

Write it, then run the tests

pairSum.js
function pairSum(nums, target) {
let l = 0, r = nums.length - 1;
while (l < r) {
const sum = nums[l] + nums[r];
if (sum === target) return [l, r];
if (sum > target) r--;
else l++;
}
return [];
}
  • pairSum([1, 3, 4, 6, 8, 10, 13], 12)not run
  • pairSum([2, 7, 11, 15], 9)not run
  • pairSum([1, 2, 3], 7)not run
Not run yet
Checkpoint question

In the pair-sum algorithm on a sorted array, the current sum is less than the target. Which pointer moves, and which way?

The Ecosystem

Precision Engineered Learning

DSA Curriculum

Work through Foundations, Data Structures, and Algorithms in a guided sequence with visualizations and interactive labs.

System Design and Behavioral

Design systems the way interviewers probe them, and structure behavioral stories with the STAR method.

AI Engineering

Prepare for AI engineering interviews on LLMs, RAG, agents, and evaluation, with rubrics and timed mock interviews.

Practice Problems

Solve real coding challenges in-browser with difficulty filters, progress tracking, and instant feedback.

Code References

Official code snippets and curated question banks. Production grade templates for interviews, learning, and quick reference.

Community

Explore articles, interview experiences, and problems shared by a global network of engineers.

Learning Path

The Architectural Journey

A structured roadmap from core logic and data structures to system design, behavioral rounds, and AI engineering.

01. Foundations

Master the underlying mechanics of computational logic and efficiency.

BIG-O ANALYSISMEMORY MGMTRECURSION

02. Data Structures

Build and manipulate the blueprints that organize digital information.

ARRAYS & LISTSTREES & GRAPHSHASH MAPS

03. Algorithms

Apply high-level strategies to solve complex computational problems.

DP & GREEDYGRAPH TRAVERSALSEARCH/SORT

04. Practice Problems

Solve real coding challenges filtered by difficulty, topic, and status with instant feedback.

EASY / MEDIUM / HARDIN-BROWSER EXECPROGRESS TRACKING

05. System Design

Learn to architect scalable, reliable systems from load balancing to database sharding and beyond.

SCALABILITYDISTRIBUTED SYSDESIGN PATTERNS

06. Behavioral Interviews

Master the STAR method, leadership principles, and common behavioral questions at top tech companies.

STAR METHODLEADERSHIPCONFLICT RESOLUTION
07. AI Engineering

Prepare for AI engineering interviews: build with LLMs, ground answers with retrieval, and evaluate and ship AI features you can trust.

LLMS & RAGAGENTS & TOOLSEVALUATION
AI Engineering

Interview Prep for AI Engineers

Prepare for interviews for roles that build with large language models: prompting and structured output, embeddings and retrieval, RAG, tool calling and agents, evaluation, security, and running AI features in production.

66 questions in 17 topics

Each with a study guide, hints, a reference answer, and a rubric to score yourself.

7 interview rounds

From the technical screen to AI system design, each with a timed mock interview.

Hands-on exercises

Predict outputs, diagnose failures, and solve linked practice problems in Python or JavaScript.

A track for team and tech leads

Plan an AI rollout, review a team-built automation, and lead the response when AI errors reach customers.

Immersion

Hands-on Problem Solving

Solve real coding challenges in-browser. Web-based execution works instantly for guests. Write, run, and refine your logic without ever touching a terminal.

Instant Web Runtime

Vanilla JS/TS, React, and Vue playgrounds run directly in-browser for zero-friction exploration.

Multi-Language Lab

Unlock Python, Java, C, C++, Go, Ruby, and PHP execution with a free account.

solve_problem.js
RUNNING
01
02
03
04
05
06
07
08
09
10
function findMaxSubarray(arr) {
    let maxSoFar = arr[0];
    let currentMax = arr[0];

    for (let i = 1; i < arr.length; i++) {
        currentMax = Math.max(arr[i], currentMax + arr[i]);
        maxSoFar = Math.max(maxSoFar, currentMax);
    }
    return maxSoFar;
}
Runtime Metrics

Execution

12ms

Memory

4.2MB

Test Passed

Solution optimized for time complexity O(n).

Visual Learning

Data Structures & Algorithms, Animated

Static code hides what's actually happening. Step through pushes, swaps, and traversals frame by frame to see the state changes that build real intuition.

View all visualizations

Compare BFS and DFS traversal strategies

Stack frames track function calls

Traverse nodes pointer by pointer

Euclidean algorithm computes GCD step by step

Self-balancing rotations in action

Evict the least recently used entry

Reference Library

Beyond the Curriculum

Access production-grade code snippets and curated question banks for immediate use in your projects and interviews.

Connect

Learn from the Community

Join engineers sharing real-world insights. Discover interview experiences, solve community problems, and eventually contribute your own knowledge.

DS
AK
MR
+
Explore Community

Developer Insights

Read articles on algorithms, system design, and real-world engineering challenges.

Interview Experiences

Learn from real interview stories shared by developers at top companies.

Creator Monetization

Grow from a learner to a contributor. Share content and sell bundles on the same platform.

AI Help

AI Help While You Learn

AI-powered guidance built into your learning workflow: hints, explanations, and support without leaving the platform. Bring your own Anthropic, OpenAI, or Google API key. Your key is stored only in your browser, and you pay the provider directly with no markup.

Ask AI for Hints

Get contextual explanations and nudges when you're stuck on a problem or lesson concept.

On-Demand Guidance

AI support is embedded in lessons and problems. No context switching to external tools.

Bring Your Own Key

Plug in your personal Anthropic, OpenAI, or Google API key once. It is stored only in your browser, sent encrypted with each AI request, and never saved on our servers.

Pay Providers Directly

No markup. AI calls run through your own API key and bill straight to your Anthropic, OpenAI, or Google account.

Earn

Your Knowledge Has Value

Go from learning to earning on the same platform. Share what you know, build your reputation, and monetize your expertise.

1

Create Content

Write articles, build coding problems, share code snippets, publish question bundles, or share interview experiences.

2

Grow Your Audience

Your content is discoverable by the entire community. Build credibility and a following around your expertise.

3

Monetize Your Work

Set your price on eligible content. Earn revenue directly when other users purchase your problems or question bundles.

4

Track & Withdraw

Monitor your earnings in real-time from your wallet dashboard. Request payouts when you reach the minimum threshold.

Plans

Elevate Your Experience

Start exploring for free. Create an account to unlock more. Go Premium for the full experience.

No account needed

Explorer

Browse all free lessons

Easy & Medium AI Engineering questions

View practice problems

Read community content

Web playgrounds (JS/TS, React, Vue)

Code snippets & question bank

Tag-based content discovery

Free forever

Member

Everything in Explorer

Save progress & dashboard

AI Engineering scores & mock history saved

Multi-language code execution

Personalized analytics

Review queue (spaced repetition)

AI-assisted hints (bring your own API key)

Publish community content

Onyx Code Pro: 30% member discount

BEST VALUE

$100

USD · one-time

Premium

Everything in Member

All premium lessons & problems

Every AI Engineering question, Hard included

Problem solutions & all hints

Unlimited community contributions

Create & sell paid content

Earn revenue from your content

Premium avatars & badge

Free compiler tokens

Onyx Code Pro: included free

FAQ

Frequently Asked Questions

Yes! Explore lessons, problems, snippets, and community content for free without creating an account. Create a free account to save progress, track analytics, and unlock additional features. Premium is a one-time payment for full access.

Start Building Your Advantage

Structured prep for coding, system design, behavioral, and AI engineering interviews, with real problems and a community of engineers. Everything you need for your next interview.

No account needed, just start learning.

CodeSnatch: Coding and AI Engineering Interview Prep