Coding
C# coding problems
Write C# in the browser. Real tests mark your code.
112 problems
Your plan
How long do you want to prepare?
30 problems, easy to medium. About one a day, 15 to 25 minutes each.
- 1Does any value repeat?Hashing15 minLearn it first
- 2Two positions that add up to a targetHashing15 minLearn it first
- 3Count each characterDictionaries15 minLearn it first
- 4Reverse the words in a sentenceStrings15 minLearn it first
- 5Run-length codeStrings15 minLearn it first
- 6Balanced bracketsStacks15 minLearn it first
- 7The missing numberArrays15 minLearn it first
- 8A queue made of two stacksQueues15 minLearn it first
- 9Sort students by marks, then nameLINQ15 minLearn it first
- 10Is it a prime number?Loops15 minLearn it first
Checkpoint after problem 10. Solve 2 earlier problems again, without hints:
1. Does any value repeat?2. Two positions that add up to a target
Tracks
40 problems, easy to hard.
- 1Sort students by marks, then nameLINQ15 minLearn it first
- 2Active customers, newest firstBuild a readable LINQ report15 minLearn it first
- 3The three most expensive productsOrderBy Under the Hood15 minLearn it first
- 4Number the invoice linesStreaming Operators15 minLearn it first
- 5A summary line for each orderBuild a readable LINQ report15 minLearn it first
- 6The cities our customers live inHidden Buffers15 minLearn it first
- 7Race results, with non-finishers lastLINQ Edge Cases Interviewers Test15 minLearn it first
- 8The log lines between START and ENDSkip, Take and Paging15 minLearn it first
- 9The last five errorsSkip, Take and Paging15 minLearn it first
- 10Can the parcels be shipped?Contains, Any and Count15 minLearn it first
Checkpoint after problem 10. Solve 2 earlier problems again, without hints:
1. Sort students by marks, then name2. Active customers, newest first
Problems
74 problemsShow all problems
Choose a live query or a snapshot
Learn it: Choose a live query or a snapshot
Group sessions and join topic names
Learn it: Group sessions and join topic names
Streaming Operators
Learn it: Streaming Operators: Where, Select and Take in O(1) Extra Space
OrderBy Under the Hood
Learn it: OrderBy Under the Hood: O(n log n), an O(n) Buffer, Stability and Top-k
Hidden Buffers
Learn it: Hidden Buffers: Reverse, ToList/ToArray Growth, Distinct and Set Operators
Hashing Operators
Learn it: Hashing Operators: GroupBy, ToLookup, ToDictionary, CountBy and AggregateBy
Nested Queries O(n·m) vs Join and HashSet O(n+m)
First, Last, ElementAt and Single
Learn it: First, Last, ElementAt and Single: When They Are O(1) and When O(n)
SelectMany, Zip and Chunk
Learn it: SelectMany, Zip and Chunk: Flattening, Pairing and Batching Costs
Skip, Take and Paging
Learn it: Skip, Take and Paging: O(1) Seeks, O(skip) Walks and Quadratic Paging
Aggregate, Sum, Min and Max
Learn it: Aggregate, Sum, Min and Max: Same O(n), Very Different Constants
Arrays and Strings
Learn it: Arrays and Strings in C#: Prefix Sums, Kadane, In-Place Rotation and Counting Arrays
Hashing Patterns
Learn it: Hashing Patterns in C#: Dictionary, HashSet, CollectionsMarshal and Bad Hash Codes
Linked Lists
Learn it: Linked Lists in C#: Reversal, Fast and Slow Pointers, Merging and an LRU Cache
Sliding Window
Learn it: Sliding Window in C#: Fixed Windows, Grow-and-Shrink, Minimum Window Substring
Queues and Deques
Learn it: Queues and Deques in C#: Queue<T>, Two-Stack Queues and Sliding Window Maximum
Sorting and Selection
Learn it: Sorting and Selection in C#: Merge Sort, Quickselect, Counting Sort and Custom Comparers
Tree Traversals
Learn it: Tree Traversals in C#: Recursive and Iterative DFS, BFS Level Order and Stack Depth
Binary Search Trees
Learn it: Binary Search Trees in C#: Validation, LCA, Kth Smallest and SortedSet
Tries
Learn it: Tries in C#: Prefix Search, Autocomplete and Wildcard Words
Graphs with BFS and DFS
Learn it: Graphs with BFS and DFS in C#: Adjacency Lists, Grid Shortest Paths, Islands and Bipartite Checks
Topological Sort, Dijkstra with PriorityQueue and Union-Find
Learn it: Topological Sort, Dijkstra with PriorityQueue and Union-Find in C#
Heaps with PriorityQueue
Learn it: Heaps with PriorityQueue in C#: Top K, Merge K Sorted, Running Median and API Pitfalls
Interval Problems
Learn it: Interval Problems in C#: Merge, Insert, Greedy Scheduling, Meeting Rooms and Sweep Lines
When to use recursion and when to prefer a loop
How to recognize a DP problem in the wild
House Robber
Coin Change
Learn it: Coin Change: the first minimum DP, and a famous greedy trap
Longest Increasing Subsequence and Word Break
Learn it: Longest Increasing Subsequence and Word Break in C#: DP That Looks Back at Every Earlier Position
Unique Paths and Longest Common Subsequence
Learn it: Unique Paths and Longest Common Subsequence: 2D state
0/1 Knapsack
Learn it: 0/1 Knapsack: the capstone pattern
The universal backtracking template
Learn it: The universal backtracking template
Subsets
Learn it: Subsets: the cleanest first example
Permutations and Combination Sum
Learn it: Permutations and Combination Sum: undo and pruning
N-Queens
Learn it: N-Queens: the famous one, briefly
Output Caching, HybridCache and Rate Limiting
Learn it: Output Caching, HybridCache and Rate Limiting: Three Tools, Three Jobs