text stringlengths 1.76k 50k | token_count int64 435 12.1k |
|---|---|
I’m working on a routing service for a huge city.
The city map is given as a weighted directed graph – every road goes from one intersection to another and has a positive travel time.
I have to answer many “what’s the shortest travel time from *X* to *Y*?” queries.
I wrote a simple Dijkstra for each query, but w... | 4,042 |
---
### 🎯 Learning Objectives
* Understand the definition of a **Hamiltonian cycle** in an undirected graph.
* Design a **back‑tracking** algorithm that systematically explores possibilities and prunes dead ends.
* Reason about the exponential worst‑case behaviour of the problem and why small limits ( |V| ≤ 15... | 3,550 |
I’m working on a collaborative editor that records every character a user types.
When two users edit the same document at the same time the server stores **one** final
log – just a plain string that contains all keystrokes from both users, in the order
they actually arrived.
Later I get the two original per‑user l... | 3,749 |
---
### Problem description (in the voice of the requester)
I’m building a tiny data‑processing tool that has to sort a **single list** of numbers that can be as large as *10⁵* items.
I heard that the *intro sort* algorithm (quick‑sort + heap‑sort + insertion‑sort) is a good compromise between speed and worst‑case ... | 4,684 |
---
### What you (the “client”) want
I have a huge list of distinct integers that is already sorted in **strictly increasing** order.
I need to turn this list into a **height‑balanced binary search tree (BST)** – the classic *array‑to‑BST* construction where the middle element becomes the root, the left half buil... | 3,837 |
I’m building a backend for an online Sudoku tournament. Players upload their completed puzzles as a single file, and before we award any points we have to make sure each submitted board is a *real* solution.
The file contains many Sudoku boards, one after another. Each board is represented by 9 lines, each line hold... | 3,219 |
I have a robot that writes its activity to a binary log file. The file is just a stream of *events* one after another – there is no overall header or index. I need to read those logs, extract the data in a Python‑friendly form, and also be able to generate new logs from Python data structures.
The log format is delibe... | 5,581 |
I’ve got a list of `N` integers (they can be as big as a million) and I want to know the **largest possible greatest‑common‑divisor** (GCD) that can be obtained from any *pair* of distinct numbers in the list.
I tried writing a quick solution that just checks every pair, but it’s hopelessly slow when `N` is big (e.g... | 2,455 |
I’m trying to write a little Game‑of‑Life simulator, but the thing is I want to know what the board looks like after an *enormous* number of steps – think 10⁹, 10¹² or even larger.
The board is a rectangular grid with **periodic (toroidal) boundary conditions**: the cell on the far right is a neighbour of the cell o... | 3,969 |
I’m trying to solve the classic egg‑drop puzzle, but my current solution is far too slow for the input sizes I need. I have a piece of code below that works for tiny cases, but it blows up in both time and memory when the building has many floors.
Can you write a program that reads several test cases and prints the ... | 3,595 |
I have a small library of mathematically‑interesting functions (they involve exponentials, trigonometry, etc.).
For many independent queries I must locate a real root of one of those functions inside a given interval.
I know the Secant method converges faster than the plain bisection method, but I’m not sure how to... | 4,396 |
I have a lot of points in a low‑dimensional space (the dimension is at most 5) and I need to answer many “what’s the closest point to this query?” questions.
A naïve O(N) scan per query is too slow – N can be tens of thousands and the number of queries can be just as large.
I heard that a *KD‑Tree* built from a si... | 3,409 |
Hey there!
I’m trying to figure out how many different ways I can climb a staircase. The stair‑case has `N` steps, and I’m allowed to take either **1 step** or **2 steps** at a time.
There’s a catch, though – some of the steps are broken and I can’t step on them. I’m given a string that marks which steps are usab... | 2,407 |
End of preview. Expand in Data Studio
build by mushfiqur
- Downloads last month
- -