Segment Tree and Fenwick Tree (BIT) Interview Patterns: Range Queries and Updates (2025)
5 min read When to Use Advanced Range Data Structures A plain array supports point updates in O(1) and range queries (sum, min, […] Read article
5 min read When to Use Advanced Range Data Structures A plain array supports point updates in O(1) and range queries (sum, min, […] Read article
5 min read Requirements A location service has two core functions: proximity search (find entities near a given coordinate — restaurants, drivers, friends) Read article
5 min read Core Entities Cinema: cinema_id, name, address, timezone. Hall: hall_id, cinema_id, name, total_rows, total_cols, layout_type (STANDARD, IMAX, VIP). Seat: seat_id, hall_id, Read article
5 min read Why DP on Strings? String DP problems have a recognizable structure: two strings of lengths m and n, where the Read article
5 min read Requirements A gaming backend handles player authentication, matchmaking (pairing players of similar skill), real-time game state synchronization, leaderboards, and player Read article
5 min read Core Entities Product: product_id, sku (unique stock keeping unit), name, description, category_id, unit_cost, unit_price, weight_kg, dimensions_cm (JSON), is_active. Warehouse: warehouse_id, Read article
5 min read Backtracking Framework Backtracking = DFS + pruning. The general framework: choose a candidate for the next position, recurse, undo the Read article
5 min read Why Multi-Region? A single-region architecture has three critical weaknesses: latency (a user in Tokyo hitting servers in us-east-1 has ~150ms Read article
5 min read Core Entities Driver: driver_id, user_id, vehicle_id, license_number, status (OFFLINE, AVAILABLE, ON_TRIP), current_lat, current_lng, last_location_update, rating, total_trips, acceptance_rate. Vehicle: vehicle_id, driver_id, Read article
5 min read Matrix as a Graph A 2D matrix is an implicit graph: each cell (r, c) is a node; edges connect Read article
5 min read Requirements A media storage and delivery system stores uploaded videos or images and delivers them efficiently to users worldwide. Think Read article
8 min read Core Entities Hotel: hotel_id, name, address, star_rating, amenities (JSON array), check_in_time, check_out_time. RoomType: type_id, hotel_id, name (STANDARD, DELUXE, SUITE, PENTHOUSE), Read article
8 min read Trie Recap and When to Use A Trie (prefix tree) stores strings character by character. Insert and search are both Read article
7 min read Requirements A typeahead service returns query suggestions as the user types. Google Search autocomplete, Twitter’s hashtag completion, and Stripe’s dashboard Read article
8 min read Core Entities User: user_id, username (unique, URL-safe), email, password_hash, display_name, bio, avatar_url, role (READER, AUTHOR, EDITOR, ADMIN), created_at. Post: post_id, Read article