Count Pairs with Sum <= X

Hard
4 views 25 Jan 2026
Given a sorted array and X, count pairs (i...

Queue Rotation

Hard
6 views 25 Jan 2026
Commands: PUSH x, POP, ROTATE k (move first to end k times). Print final queue (space-separated)....

Max Overlapping Intervals

Hard
7 views 25 Jan 2026
Given n intervals [l,r], find the maximum number of overlaps at any point....

GCD Function

Easy
3 views 25 Jan 2026
Write a gcd(a,b) function and print gcd for the given inputs....

Palindrome Function

Easy
3 views 25 Jan 2026
Create a function isPalindrome(s) that ignores spaces and case. Print YES or NO....

Count Vowels Function

Easy
6 views 25 Jan 2026
Write a function that counts vowels in a string (a,e,i,o,u)....

Rectangle Area Function

Easy
5 views 25 Jan 2026
Write area(w,h) and print the rectangle area....

Reverse String Function

Easy
4 views 25 Jan 2026
Write a function reverseStr(s) and print the reversed string....

Recursive Factorial

Medium
4 views 25 Jan 2026
Compute n! using recursion (n...

Fibonacci with Memo

Medium
4 views 25 Jan 2026
Compute fib(n) with memoization (fib(0)=0, fib(1)=1)....

Sort Strings by Length

Medium
3 views 25 Jan 2026
Sort n strings by length, and for equal length sort lexicographically....

Apply f(x)=2x+1 Twice

Medium
4 views 25 Jan 2026
Given x, apply f(x)=2x+1 two times and print the result....

Square Every Number

Medium
3 views 25 Jan 2026
Given n numbers, use a function to square each and print the squared list....

Bracket Check Function

Medium
4 views 25 Jan 2026
Write a function balanced(s) for () only. Print YES or NO....

Merge Two Sorted Arrays

Medium
4 views 25 Jan 2026
Given two sorted arrays, merge them using a function and print the merged list....

Binary Search Queries

Hard
4 views 25 Jan 2026
Given a sorted array and q queries, use a function to binary search each query. Print 0-based index or -1....

Evaluate Postfix Expression

Hard
4 views 25 Jan 2026
Given a postfix expression with integers and ops + - * /, evaluate it using helper functions....

Closure Counter

Hard
5 views 25 Jan 2026
Create a counter() closure that returns 1,2,3,... each time it is called. Input q, print q lines of counts....

Compose Two Functions

Hard
3 views 25 Jan 2026
Input x. Define f(x)=x+3 and g(x)=x*2. Compute g(f(x)) and f(g(x)) and print both....

Generate Permutation by Swaps

Hard
5 views 25 Jan 2026
Given n and a list of swaps (i j), start with [1..n]. Apply swaps and print the final array....

Group Words by First Letter

Hard
5 views 25 Jan 2026
Given n words, group them by first letter (a-z) and print counts per letter present in sorted order....

Top K Frequent Numbers

Hard
5 views 25 Jan 2026
Given n numbers and k, print the k most frequent numbers. If frequencies tie, smaller number first....

Merge Intervals (Function)

Hard
8 views 25 Jan 2026
Given n intervals, merge overlaps and print the merged intervals sorted by start....

Sum of Array

Easy
6 views 25 Jan 2026
Given n integers, print their sum....

Maximum Element

Easy
4 views 25 Jan 2026
Print the maximum value in the array....

Reverse the Array

Easy
6 views 25 Jan 2026
Print the array in reverse order....

Count Occurrences

Easy
5 views 25 Jan 2026
Given n numbers and x, count how many times x appears....

Concatenate Two Arrays

Easy
5 views 25 Jan 2026
Given two arrays, print them concatenated....

Remove Duplicates (Keep Order)

Medium
5 views 25 Jan 2026
Remove duplicates but keep the first time each value appears....

Rotate Array Right

Medium
4 views 25 Jan 2026
Rotate an array to the right by k positions....

Range Sum Queries

Medium
4 views 25 Jan 2026
Answer q range-sum queries on an array....

Two Sum Indices

Medium
4 views 25 Jan 2026
Find indices i and j such that a[i]+a[j]=target. Print first pair found, else -1 -1....

Sort by Frequency

Medium
4 views 25 Jan 2026
Sort array values by frequency (desc), and by value (asc) when tie....

Intersection (Unique Sorted)

Medium
5 views 25 Jan 2026
Given two arrays, print unique common values in increasing order....

Missing Number 1..N

Medium
5 views 25 Jan 2026
You get n-1 numbers from 1..n. Find the missing number....

Longest Subarray Sum = K

Hard
5 views 25 Jan 2026
Given n integers and k, find the longest subarray with sum exactly k....

Maximum Subarray Sum

Hard
4 views 25 Jan 2026
Print the maximum subarray sum (Kadane)....

Count Inversions

Hard
5 views 25 Jan 2026
Count pairs i a[j]....

Sliding Window Maximum

Hard
4 views 25 Jan 2026
Given array and window size k, print the maximum in each window....

Minimum Swaps to Sort

Hard
5 views 25 Jan 2026
Given a permutation of 1..n, print minimum swaps to sort it....

Kth Smallest (Quickselect)

Hard
4 views 25 Jan 2026
Find the k-th smallest value in the array (1-based k)....

Split into 3 Equal Sum Parts

Hard
4 views 25 Jan 2026
Check if the array can be split into three contiguous parts with equal sum. Print YES or NO....

Largest Rectangle in Histogram

Hard
5 views 25 Jan 2026
Given bar heights, find the largest rectangle area in the histogram....

Reverse a String

Easy
5 views 25 Jan 2026
Print the reverse of the given string....

Count Vowels

Easy
7 views 25 Jan 2026
Count vowels (a,e,i,o,u) in the string, case-insensitive....

Title Case

Easy
4 views 25 Jan 2026
Capitalize the first letter of each word (words separated by spaces)....

Palindrome Check

Easy
4 views 25 Jan 2026
Check if the string is a palindrome ignoring spaces and case....

Word Count

Easy
6 views 25 Jan 2026
Count how many words are in the string (words separated by spaces)....

Run-Length Encode

Medium
6 views 25 Jan 2026
Compress the string using run-length encoding like a3b2....

First Non-Repeating Character

Medium
5 views 25 Jan 2026
Print the first character that appears only once. If none, print -1....

Anagram Check

Medium
4 views 25 Jan 2026
Given two strings, check if they are anagrams (ignore spaces, case-insensitive)....

Remove Duplicate Characters

Medium
4 views 25 Jan 2026
Remove duplicate characters but keep the first occurrence (spaces included)....

Longest Word

Medium
6 views 25 Jan 2026
Print the longest word in the line (if tie, print the first)....

Rotation Check

Medium
4 views 25 Jan 2026
Check if b is a rotation of a (case-sensitive). Print YES or NO....

Count Substring Occurrences

Medium
5 views 25 Jan 2026
Count how many times pattern p occurs in s (overlaps allowed)....

Longest Common Prefix

Hard
4 views 25 Jan 2026
Given n strings, print their longest common prefix (or empty)....

KMP Count Pattern

Hard
5 views 25 Jan 2026
Count how many times pattern p appears in s (overlaps allowed) using KMP....

Longest Substring Without Repeat

Hard
4 views 25 Jan 2026
Find the length of the longest substring with all unique characters....

Remove Adjacent Duplicates

Hard
5 views 25 Jan 2026
Repeatedly remove adjacent equal characters. Print the final string....

Longest Palindromic Substring Length

Hard
5 views 25 Jan 2026
Print the length of the longest palindromic substring (expand-around-center)....

Decode Bracket String

Hard
4 views 25 Jan 2026
Decode pattern like 3[a2[c]] -> accaccacc....

Find All Anagram Starts

Hard
4 views 25 Jan 2026
Given s and p (lowercase), print all start indices where an anagram of p begins....

Rearrange Without Adjacent Equals

Hard
5 views 25 Jan 2026
Rearrange the string so that no two adjacent characters are the same. If not possible, print IMPOSSIBLE....

Safe Division

Easy
6 views 25 Jan 2026
Print a/b as integer. If b is 0, print DIVIDE_BY_ZERO....

Safe Array Index

Easy
5 views 25 Jan 2026
Given n integers and index i, print a[i] or OUT_OF_RANGE....

Strict Integer Input

Easy
4 views 25 Jan 2026
If the token is not a valid integer (optional sign, digits only), print INVALID....

JSON Key Count

Easy
6 views 25 Jan 2026
Given a JSON object. If invalid, print INVALID_JSON. Else print how many keys it has....

Validate Date (YYYY-MM-DD)

Easy
7 views 25 Jan 2026
If date is valid (YYYY-MM-DD), print OK else INVALID_DATE....

Average or EMPTY

Medium
6 views 25 Jan 2026
Given n numbers, print average with 2 decimals. If n=0, print EMPTY....

Stack Pop with Underflow

Medium
7 views 25 Jan 2026
Process q commands: PUSH x or POP. POP prints value, but if empty prints UNDERFLOW....

Division List

Medium
4 views 25 Jan 2026
You get n pairs a b. For each, print a/b as integer. If b=0 print ERROR....

Safe Square Root

Medium
4 views 25 Jan 2026
Given x, print floor(sqrt(x)). If x is negative, print ERROR....

Age Validator (Exception)

Medium
4 views 25 Jan 2026
If age is between 0 and 120, print OK. Otherwise print INVALID_AGE....

Simplify Fraction with Checks

Medium
5 views 25 Jan 2026
Input a b meaning a/b. If b=0 print ERROR. Else print reduced fraction p q....

Validate IPv4

Medium
5 views 25 Jan 2026
Print OK if input is valid IPv4 address (0..255 each part), else INVALID_IP....

Parse 32-bit Integer

Hard
6 views 25 Jan 2026
Given an integer as text, print it if it fits 32-bit signed, else print OVERFLOW....

Comma-Separated Integers

Hard
6 views 25 Jan 2026
Input is a comma-separated list of integers. If any item is invalid, print ERROR, else print the maximum....

Config Line Error Count

Hard
4 views 25 Jan 2026
Read lines KEY=VALUE. Count how many lines are invalid (missing '=', empty key). Print error count....

Postfix with Error Handling

Hard
5 views 25 Jan 2026
Evaluate postfix expression. If it ever divides by zero or lacks operands, print ERROR....

JSON Required Keys

Hard
6 views 25 Jan 2026
JSON object must contain keys id and name. Print OK, MISSING_KEYS, or INVALID_JSON....

Base Conversion with Validation

Hard
4 views 25 Jan 2026
Given base b and string s, convert to decimal. If s contains invalid digit for base, print INVALID....

Decode with Bracket Errors

Hard
4 views 25 Jan 2026
Decode k[text]. If brackets are unbalanced or number is missing, print ERROR....

Rectangle Class

Easy
7 views 25 Jan 2026
Create a Rectangle class with width and height. Print area and perimeter....

Counter Object

Easy
6 views 25 Jan 2026
Make a Counter class with inc() and dec(). Process q commands INC or DEC and print final value....

Bank Account

Easy
7 views 25 Jan 2026
Create BankAccount with deposit/withdraw. Withdraw that goes below 0 is ignored. Print final balance....

Student Average

Easy
8 views 25 Jan 2026
Create a Student class that stores marks and prints average with 2 decimals....

Stack Class

Easy
8 views 25 Jan 2026
Implement a Stack class with push/pop. POP on empty prints EMPTY. Print outputs for POP....

Queue Class

Medium
7 views 25 Jan 2026
Implement a Queue class with enqueue/dequeue. DEQ on empty prints EMPTY....

Inventory Item

Medium
8 views 25 Jan 2026
Create Item with qty. Commands: ADD x, SELL x (cannot go below 0). Print final qty....

Polymorphic Areas

Medium
7 views 25 Jan 2026
Types: C r for circle, S a for square. Print area for each shape with 2 decimals....

Temperature Converter Object

Medium
7 views 25 Jan 2026
Make a Temperature class with setC(c) and getF(). Input c, print Fahrenheit with 2 decimals....

Book Borrowing

Medium
6 views 25 Jan 2026
Commands: ADD book, BORROW book, RETURN book. Track if a book is available. BORROW unavailable prints FAIL....

Word Counter Class

Medium
7 views 25 Jan 2026
Given a line, build a WordCounter object and print how many words it has....

LRU Cache Simulator

Hard
8 views 25 Jan 2026
Capacity c. Commands: PUT k v, GET k. GET prints value or -1. Evict least recently used....

Disjoint Set Union

Hard
6 views 25 Jan 2026
Commands: UNION a b, FIND a b. FIND prints YES if connected else NO....

Expression Tree from Postfix

Hard
8 views 25 Jan 2026
Build an expression tree from postfix (+,-,*,/) and evaluate it....

Binary Search Tree Commands

Hard
5 views 25 Jan 2026
Commands: INSERT x, FIND x. Print YES/NO for FIND....

Undoable Text Editor

Hard
6 views 25 Jan 2026
Commands: ADD text, DEL k, UNDO. Print final text....

Leaderboard Class

Hard
6 views 25 Jan 2026
Commands: ADD name score, TOP k. TOP prints top k names by score (desc), tie by name....

Log Line Counter

Hard
4 views 25 Jan 2026
Each non-empty line should look like LEVEL:message. LEVEL is INFO, WARN, or ERROR. Count each level and also count invalid lines. Print: info warn error invalid....

Playlist Manager

Medium
7 views 25 Jan 2026
Build a Playlist object and process commands: ADD song, REMOVE song, COUNT. Songs are unique by name. COUNT prints how many songs are in the playlist....

Fenwick Range Sum Class

Hard
6 views 25 Jan 2026
You have an array of n integers. Support two operations: ADD i x (a[i]+=x) and SUM l r (inclusive). Print answers for SUM queries....

Task Manager (Priority Queue)

Hard
7 views 25 Jan 2026
Commands: ADD name p, POP. POP removes and prints the task with highest priority; if tie, the one added earlier. If empty, print EMPTY....

Swap Two Numbers (No Temp)

Easy
4 views 25 Jan 2026
Two integers a and b are given. Swap them without using a third variable and print the result....

Sum 1 to N

Easy
5 views 25 Jan 2026
Given n, print the sum 1+2+...+n....

Celsius to Fahrenheit

Easy
4 views 25 Jan 2026
Input is a temperature in Celsius. Print Fahrenheit with 2 decimals....

Running Counter

Easy
4 views 25 Jan 2026
You are given n and then n integers. Start total=0. Add each value and print final total....

Simple Interest

Easy
6 views 25 Jan 2026
Given p r t, print simple interest (p*r*t/100) with 2 decimals....

SET/GET One Variable

Medium
4 views 25 Jan 2026
You will get q commands: SET x, GET. Keep a single variable (starts EMPTY). GET prints value or EMPTY....

Store Variables by Name

Medium
4 views 25 Jan 2026
Commands: SET name value, GET name. Save values by name. GET prints value or NOT_FOUND....

Plus/Minus Simulator

Medium
4 views 25 Jan 2026
Line1 x. Line2 ops string. '+' means x++, '-' means x--. Print final x....

Parse KEY=VALUE Lines

Medium
4 views 25 Jan 2026
Input has lines like KEY=VALUE. Ignore empty lines and lines starting with #. Print number of keys stored....

Shadowing Counter

Medium
4 views 25 Jan 2026
Commands: LET x, BEGIN, END. Count how many LET shadows a name already present in an outer scope....

Variable Variables

Medium
4 views 25 Jan 2026
Input: name value. Create a variable with that name and print it back....

Running Average

Medium
4 views 25 Jan 2026
Given n numbers, print the running average after each number (2 decimals)....

Reference Chain

Hard
5 views 25 Jan 2026
You get three integers a b c. Set x=a, y=&x, x=b, z=&y, y=c. Print x y z....

Use Before SET

Hard
3 views 25 Jan 2026
Commands: SET name value, PRINT name. Count how many PRINT happen before a name is ever SET....

UNSET Tracker

Hard
4 views 25 Jan 2026
Commands: SET name val, UNSET name, GET name. For GET print value or UNSET....

XOR Swap

Hard
4 views 25 Jan 2026
You get a and b. Swap using XOR trick and print swapped....

Mini Scope Interpreter

Hard
5 views 25 Jan 2026
Commands: BEGIN, END, SET name value, GET name. GET searches inner to outer. Print value or NOT_FOUND....

Template Replace

Hard
5 views 25 Jan 2026
You get n pairs key value, then one text line. Replace {key} with value and print final text....

Static Call Counter

Hard
4 views 25 Jan 2026
Given q lines (CALL), print counter after each call using a static variable inside function....

Merge Two Config Layers

Hard
4 views 25 Jan 2026
You get base key=value lines, then override key=value lines. Overrides replace base. Print final key count....

Detect Integer or Float

Easy
5 views 25 Jan 2026
A number is given as text. Print INT if it looks like an integer, otherwise FLOAT....

First Character Category

Easy
5 views 25 Jan 2026
Given a string, look at the first character. Print DIGIT, LETTER, or OTHER....

ASCII to Character

Easy
4 views 25 Jan 2026
You get an integer code (0..255). Print the character for it....

Simple Truthy Check

Easy
5 views 25 Jan 2026
Input is one token. Treat '', '0', and 'false' (case-insensitive) as false, everything else as true. Print TRUE or FALSE....

String Length

Easy
6 views 25 Jan 2026
Print the length of the given string (bytes)....

Count Integers and Floats

Medium
5 views 25 Jan 2026
Given n numeric tokens, count how many look like integers vs floats (contains '.' or exponent)....

Strict Integer Parse

Medium
6 views 25 Jan 2026
If the input is a valid integer text (optional sign, digits only) print the number, else print INVALID....

Binary to Decimal

Medium
4 views 25 Jan 2026
Convert a binary string to decimal....

Decimal to Hex

Medium
5 views 25 Jan 2026
Convert an integer to uppercase hexadecimal (no 0x prefix)....

Sum Only Numeric Tokens

Medium
4 views 25 Jan 2026
Given a line with mixed tokens, add only the numeric ones and print the sum. Print as integer if it is whole....

Parse Money String

Medium
4 views 25 Jan 2026
Input like 1,234.50. Remove commas and print the number with 2 decimals....

Base-N to Decimal

Medium
5 views 25 Jan 2026
Given base b (2..36) and string s (digits/letters), convert to decimal....

Big Integer Addition

Hard
5 views 25 Jan 2026
Two big non-negative integers are given as strings. Print their sum....

Big Integer Comparison

Hard
5 views 25 Jan 2026
Compare two big non-negative integers given as strings. Print , or =....

Big Integer Subtraction

Hard
4 views 25 Jan 2026
Given a and b as big integers (a >= b), print a-b....

Add Fractions

Hard
4 views 25 Jan 2026
Input a b c d meaning a/b + c/d. Print the reduced fraction p q....

Big Decimal to Binary

Hard
4 views 25 Jan 2026
You get a big decimal integer as string. Convert it to binary....

Big Binary to Decimal

Hard
5 views 25 Jan 2026
Convert a binary string (up to 500 bits) into a decimal string....

Round to K Decimals

Hard
5 views 25 Jan 2026
Input x and k. Print x rounded to k decimals....

Big Multiply by Digit

Hard
5 views 25 Jan 2026
Input big integer a and digit m (0..9). Print a*m....

Basic Arithmetic Trio

Easy
4 views 25 Jan 2026
Given a and b, print a+b, a-b, and a*b on one line....

Even or Odd

Easy
4 views 25 Jan 2026
Check if n is even or odd....

Clamp a Number

Easy
5 views 25 Jan 2026
Input x lo hi. Print x clamped inside [lo,hi]....

Bitwise AND

Easy
7 views 25 Jan 2026
Given a and b, print a & b....

Max Using Ternary

Easy
4 views 25 Jan 2026
Print the bigger of two integers using a ternary expression....

Swap with XOR

Medium
6 views 25 Jan 2026
Swap two integers using XOR and print them....

Count Set Bits

Medium
5 views 25 Jan 2026
Print how many 1-bits are in n....

Check Nth Bit

Medium
5 views 25 Jan 2026
Input n and k (0-based). Print 1 if kth bit is set, else 0....

Toggle Nth Bit

Medium
4 views 25 Jan 2026
Input n and k (0-based). Flip kth bit and print new number....

XOR of Array

Medium
5 views 25 Jan 2026
Given n integers, print XOR of all values....

Fast Power Mod

Medium
4 views 25 Jan 2026
Input a b m. Print (a^b) mod m....

Bitwise OR Summary

Medium
6 views 25 Jan 2026
Given n numbers, print bitwise OR of them....

Add Without Plus

Hard
5 views 25 Jan 2026
Input a and b (non-negative). Add them using bit operations only....

Multiply Without Star

Hard
6 views 25 Jan 2026
Multiply a and b using only addition and bit shifts....

Divide Without Slash

Hard
4 views 25 Jan 2026
Input a b (a>=0, b>0). Print quotient and remainder without using / or %....

Evaluate Left-to-Right

Hard
3 views 25 Jan 2026
Expression tokens like: number op number op number. Evaluate strictly left-to-right (no precedence). Ops are + - *....

Bitmask Permissions

Hard
6 views 25 Jan 2026
Start with mask=0. Commands: GRANT k, REVOKE k, CHECK k. k is 0..30. CHECK prints 1/0....

XOR on Range

Hard
5 views 25 Jan 2026
Given L and R, print XOR of all integers in [L,R]....

Minimum Bit Flips

Hard
6 views 25 Jan 2026
Input a and b. Print how many bit flips to turn a into b....

Gray Code Value

Hard
5 views 25 Jan 2026
Input n. Print gray code g = n ^ (n>>1)....

Grade from Marks

Easy
4 views 25 Jan 2026
Given marks (0..100), print grade: A(90+), B(80-89), C(70-79), D(60-69), else F....

Leap Year

Easy
5 views 25 Jan 2026
Print YES if the year is a leap year, otherwise NO....

Absolute Difference

Easy
7 views 25 Jan 2026
Given a and b, print |a-b|....

Factorial (Loop)

Easy
4 views 25 Jan 2026
Given n, print n! using a loop....

Count Positive Numbers

Easy
4 views 25 Jan 2026
You get n and then n integers. Count how many are > 0....

FizzBuzz

Medium
5 views 25 Jan 2026
Print numbers 1..n, but print Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for both....

Sum Until Zero

Medium
5 views 25 Jan 2026
Read integers until you see 0. Print the sum of numbers before 0....

Prime Check

Medium
5 views 25 Jan 2026
Given n, print PRIME if n is prime else NOT_PRIME....

Count Digits

Medium
4 views 25 Jan 2026
Print how many digits are in n (for n=0, answer is 1)....

Collatz Steps

Medium
6 views 25 Jan 2026
Starting from n, apply: if even n=n/2 else n=3n+1. Count steps to reach 1....

First Value Greater Than X

Medium
5 views 25 Jan 2026
Given n numbers and x, print the first number that is > x. If none, print -1....

Minimum in Matrix

Medium
5 views 25 Jan 2026
Given r and c and the matrix values, print the minimum value....

Balanced Brackets

Hard
5 views 25 Jan 2026
Input is a string with (), [], {}. Print YES if it is balanced, else NO....

Traffic Light Simulation

Hard
6 views 25 Jan 2026
Colors cycle: Red -> Green -> Yellow -> Red. Given start color and t steps, print final color....

Command Calculator

Hard
4 views 25 Jan 2026
Start value=0. Commands: ADD x, SUB x, MUL x, DIV x (integer, ignore if x=0). Print final value....

Longest Increasing Run

Hard
6 views 25 Jan 2026
Given n integers, find the length of the longest strictly increasing contiguous run....

One Step of Life

Hard
4 views 25 Jan 2026
Given r c and a grid of 0/1, apply one step of Conway's Game of Life and print new grid....