Shortest Path BFS

Hard
4 views 24 Jan 2026
Input provides {x}. Implement bfs to output shortest distance (edges count) or -1....

Graph Shortest Path Class

Hard
4 views 24 Jan 2026
Input provides {x}. Create Graph class with bfs(s,t) method. Output shortest distance or -1....

Sort Mixed Tokens

Hard
4 views 24 Jan 2026
You get {x}. Token types: INT, FLOAT (with dot), WORD. Sort by type order INT then FLOAT then WORD. For ints sort by numeric value, for floats sort by numeric value, for words sort lexicographically. ...

Trie Prefix Counter

Hard
4 views 24 Jan 2026
We have {x}. Create Trie class. For COUNT output how many added words have this prefix....

Dijkstra Shortest Path (Many Cases)

Hard
5 views 24 Jan 2026
For each testcase you get weighted undirected graph. Output shortest distance from 1 to n. If unreachable output -1....

Median Finder Class

Hard
4 views 24 Jan 2026
You will receive q commands: ADD x or MEDIAN. Create MedianFinder class using two heaps. For MEDIAN output lower median (floor for even count)....

Distinct In Every Window

Hard
4 views 24 Jan 2026
For each testcase you get n, k and n integers. For each window of size k output how many distinct numbers are inside....

First Repeat Prefix Sum

Hard
4 views 24 Jan 2026
We have {x}. If never repeats, output -1....

Merge Intervals

Hard
4 views 24 Jan 2026
Input provides {x}. Write function merge(intervals) and output merged intervals sorted....

Segment Tree Range Sum

Hard
5 views 24 Jan 2026
Given {x}, Two types: 1 i x means set a[i]=x, 2 l r means output sum of a[l..r] (1-based). Implement build/update/query helpers....

Sliding Window Maximum

Hard
4 views 24 Jan 2026
You're given {x}. For each window output maximum. Use a deque....

Smallest Subarray Sum at Least S

Hard
4 views 24 Jan 2026
You get {x}. Compute the minimum length of a contiguous subarray with sum >= S. If not found, output 0....

Tree Diameter For Each Testcase

Hard
5 views 24 Jan 2026
For each testcase you get a tree with n nodes. Output the diameter length (number of edges on longest path)....

Binary Search Function

Medium
4 views 24 Jan 2026
Consider {x}. Output result....

Longest Common Prefix

Medium
4 views 24 Jan 2026
Given {x}, Output their longest common prefix. If no common prefix, output EMPTY....

Longest Increasing Prefix Length

Medium
4 views 24 Jan 2026
For each testcase you get n numbers. Compute length of the longest prefix that is strictly increasing....

Sliding Window Maximum (Algorithms)

Medium
5 views 24 Jan 2026
For each testcase you get n, k and n numbers. Output max of each window of size k (space-separated)....

Sort By Frequency

Medium
5 views 24 Jan 2026
For each testcase you get n integers. Sort them by frequency descending. If frequency same, smaller number first. Output sorted list....

All Subset Sums

Hard
17 views 24 Jan 2026
Consider {x}. Use recursion function dfs(i,cur) to generate all subset sums. Output sums sorted....

Fast Power Mod Function

Hard
4 views 24 Jan 2026
We have {x}....

Kth Switch Toggle

Hard
4 views 24 Jan 2026
You have n bulbs all OFF. For i from 1 to n, toggle every i-th bulb. At the end, how many bulbs are ON? Output count....

Longest Subarray with At Most K Distinct

Hard
5 views 24 Jan 2026
Input provides {x}. Compute length of the longest contiguous subarray that has at most K distinct numbers....

Maximum Subarray Sum Circular

Hard
6 views 24 Jan 2026
You're given {x}. Compute maximum subarray sum in circular array and output it....

Prefix Sums Print

Easy
4 views 24 Jan 2026
Given {x}, Output prefix sum after each element (same order)....

Segment Tree Range Minimum

Hard
5 views 24 Jan 2026
Consider {x}. Build SegmentTree class with update(i,x) and query(l,r) returning minimum. Output query answers....

String Hash Queries

Hard
4 views 24 Jan 2026
Input provides {x}. Implement to build prefix hashes and answer hash values mod 1000000007....

Sum Numbers With Prefix Base

Hard
4 views 24 Jan 2026
We have {x}. Each token can be decimal like 15, binary like 0b1010, octal like 0o12, or hex like 0xFF. Tokens can also have a leading '-' sign. Convert all to integer and output the sum....

Topological Order Or Cycle

Hard
4 views 24 Jan 2026
For each testcase you get a directed graph. If topological order exists, output one order. If cycle exists, output CYCLE....

Binary XOR

Medium
4 views 24 Jan 2026
Two binary strings a and b are provided (same length). Compute bitwise XOR and output result without leading zeros (output 0 if all zero)....

Count Set Bits

Medium
4 views 24 Jan 2026
One non-negative integer n is provided. Count how many 1 bits are in binary representation and output it....

Integer to Binary with Variables

Medium
4 views 24 Jan 2026
You get {x}. Output its binary without using bin(). Use repeated division and variables....

Kth Bit Check

Medium
4 views 24 Jan 2026
You're given {x}. Output 1 if k-th bit (0-based) of n is set, else 0....

Kth Largest Element

Medium
5 views 24 Jan 2026
For each testcase you get n, k and n integers. Output the k-th largest element....

Kth Smallest Quickselect

Medium
5 views 24 Jan 2026
You're given {x}. Compute kth smallest element using quickselect style and output it....

Prefix Count Queries

Medium
4 views 24 Jan 2026
Consider {x}. For each word, count all its prefixes. Then q prefixes are provided. For each prefix output how many words start with it....

Prefix Sum Function

Medium
4 views 24 Jan 2026
Consider {x}. Write function build_prefix(arr) and answer sums fast....

Sort By Frequency (Algorithms)

Medium
4 views 24 Jan 2026
We have {x}. Sort them by frequency ascending, if tie by value ascending. Output sorted list....

Sort Circles By Area

Medium
4 views 24 Jan 2026
Consider {x}. Create Circle class with area() and sort circles by area ascending. Output sorted radii....

Subarray Sum Positive

Medium
4 views 24 Jan 2026
Consider {x}. Output YES if there exists a subarray with sum exactly S else NO....

Add Without Plus

Hard
4 views 24 Jan 2026
Consider {x}. Add them without using + or -. Use bit operations and output sum....