Swap Two Values (No Extra Variable)

Easy
5 views 24 Jan 2026
You are given two values a and b. Swap them and print the swapped values. Use JavaScript style swap (no third variable)....

Real Type Finder

Easy
4 views 24 Jan 2026
Given one value as a string input, print its real JavaScript type in a friendly way: null, array, object, number, string, boolean, undefined, function....

Power of Two Check

Easy
2 views 24 Jan 2026
Given an integer n, print YES if it is a power of 2, else print NO. Use bit logic, not loops....

FizzBuzz Range

Easy
2 views 24 Jan 2026
Given two integers L and R, print FizzBuzz style output for all numbers from L to R (inclusive). For multiples of 3 print Fizz, multiples of 5 print Buzz, multiples of both print FizzBuzz, else print ...

Count Vowels

Easy
4 views 24 Jan 2026
Given a string, count how many vowels are there (a,e,i,o,u) ignoring case. Print the count....

Sum of Even Numbers

Easy
4 views 24 Jan 2026
Given an array of integers, print the sum of only even numbers....

First Duplicate Item

Easy
4 views 24 Jan 2026
Given an array, find the first value that appears again when scanning from left to right. If no duplicate, print -1....

Count Data Fields in Object

Easy
4 views 24 Jan 2026
Given a JSON object, count how many own properties have a value that is NOT a function. Print the count....

Safe JSON Parse

Easy
4 views 24 Jan 2026
Input has two lines: first is a JSON string, second is a default value as JSON. If first line parses, print parsed JSON (stringified). If it fails, print the default JSON as output....

Toggle Active Class

Easy
3 views 24 Jan 2026
You have a button with id btn and a box with id box. When user clicks button, toggle class active on #box. Write the JavaScript code....

Left Rotate Array (In Place)

Medium
5 views 24 Jan 2026
Given an array and a number k, rotate the array to the left by k steps and print the result....

Merge Overlapping Meetings

Medium
5 views 24 Jan 2026
You have meeting time intervals [start,end]. Merge all overlapping intervals and print the merged list sorted by start....

Group Students by City

Medium
3 views 24 Jan 2026
Given a list of students with name and city, group them by city and print each city with names in input order....

Memoize One-Argument Function

Medium
4 views 24 Jan 2026
Input has a list of queries for a slow function f(x)=x*x+1. For repeated x, do not recompute; use memoization and print outputs for each query....

Shadowing Counter

Medium
3 views 24 Jan 2026
You are given variable declarations line by line in a tiny language: 'let x', 'block', 'end'. Count how many times a 'let x' shadows an existing x in an outer scope....

Mini Calculator (No eval)

Medium
2 views 24 Jan 2026
Given an expression with + - * / and non-negative integers, compute the result using correct precedence (* and / first). Integer division should floor....

Check Balanced Brackets

Medium
3 views 24 Jan 2026
Given a string with brackets (), {}, [], check if it is balanced. Print YES or NO....

Normalize to Number or NaN

Medium
4 views 24 Jan 2026
Input is a JSON array with mixed values. Convert each item to a number using Number(). Print a JSON array where invalid conversions become null....

Retry a Promise Task

Medium
4 views 24 Jan 2026
You are given two integers: attempts and failCount. Simulate a task that fails first failCount times and then succeeds. Using async/await, retry until success or attempts finish. Print SUCCESS or FAIL...

Wrap Errors with Context

Medium
3 views 24 Jan 2026
Given a number x. If x is negative, throw an error 'NEG'. Catch it and print 'Bad input: NEG'. Otherwise print x*x....

Queue Using Class

Medium
3 views 24 Jan 2026
Implement a queue with methods enqueue, dequeue, size. Process commands: ENQ x, DEQ, SIZE. Print outputs of DEQ and SIZE....

Build HTML Table Rows

Medium
4 views 24 Jan 2026
You are given an array of objects like {name,score}. Create table rows inside . For each item, add namescore....

Deep Freeze One Level

Medium
2 views 24 Jan 2026
Given a JSON object, freeze it and also freeze all direct child objects/arrays (one level deep). Print DONE....

Curry Add

Medium
6 views 24 Jan 2026
Create a function add(a)(b)(c) that returns a+b+c. For input a b c, print the result using currying....

Run Tasks with Concurrency Limit

Medium
4 views 24 Jan 2026
Given n tasks durations (ms) and a limit k, simulate running tasks with max k parallel workers. Print total time taken....

Sliding Window Maximum

Hard
5 views 24 Jan 2026
Given n numbers and window size k, print the maximum for each window....

K-th Smallest (Quickselect)

Hard
4 views 24 Jan 2026
Given an array and integer k, find the k-th smallest element (1-based) without fully sorting....

Count Paths in Grid with Blocks

Hard
5 views 24 Jan 2026
You are given a grid with 0 (free) and 1 (blocked). You can move only right or down. Count number of ways from top-left to bottom-right modulo 1000000007....

Add Two Big Numbers (String)

Hard
4 views 24 Jan 2026
Two very large non-negative integers are given as strings. Add them and print the sum as string....

Parse .env Style Lines

Hard
3 views 24 Jan 2026
Input has lines like KEY=VALUE. Ignore empty lines and lines starting with #. Print JSON object of key-value pairs (as strings)....

LRU Cache Simulator

Hard
4 views 24 Jan 2026
Implement LRU cache of capacity C. Commands: GET key, PUT key value. GET prints value or -1. PUT updates cache....

Async Compose Pipeline

Hard
4 views 24 Jan 2026
You are given n numbers. For each number x, apply async steps: add 1, then multiply by 2, then subtract 3 (each step is awaited). Print final numbers....

Promise Timeout Wrapper

Hard
5 views 24 Jan 2026
Given duration t and timeout ms. Simulate a promise that resolves after t ms. If it does not finish within timeout, print TIMEOUT else DONE....

Collect Promise Errors

Hard
4 views 24 Jan 2026
Given n and n integers. For each integer x, create a promise that rejects if x is odd, resolves if x is even. Wait all and print count of rejects....

Event Emitter Basics

Hard
5 views 24 Jan 2026
Process commands on an emitter: ON event, ONCE event, EMIT event, OFF event. Maintain how many times handler runs and print total at end....

Reverse Print

Easy
5 views 24 Jan 2026
You got n numbers in an array. Print them in reverse order. Simple thing, but do it clean....

Find Target Index

Easy
4 views 24 Jan 2026
Given an array and a value x, find the first index (0-based) where x is present. If not present, print -1....

Check Non-Decreasing

Easy
4 views 24 Jan 2026
Array diya hai. Check karo whether it is non-decreasing (every next element is >= previous). Print YES or NO....

Move Zeros to End

Easy
6 views 24 Jan 2026
Given an array, move all zeros to the end, but keep the order of non-zero items same. Print the updated array....

Max Minus Min

Easy
4 views 24 Jan 2026
Array diya hai. Print (maximum - minimum)....

Count Occurrence of X

Easy
6 views 24 Jan 2026
Given array and number x, count how many times x appears....

Second Largest (Distinct)

Easy
4 views 24 Jan 2026
Find the second largest distinct value in the array. If it does not exist, print -1....

Running Sum Array

Easy
5 views 24 Jan 2026
Given an array, print its running sum array. Running sum at i is sum of elements from 0 to i....

Remove All X

Easy
4 views 24 Jan 2026
Array se value x ko jitni baar bhi aayi hai, sab hata do. Baaki order same rehna chahiye. Print new length and new array....

Subarray Sum Equals K

Medium
3 views 24 Jan 2026
Given n, k and an array. Count how many subarrays have sum exactly k....

Maximum Subarray Sum

Medium
6 views 24 Jan 2026
Find the maximum possible sum of a contiguous subarray. Print the maximum sum....

Product Except Self

Medium
4 views 24 Jan 2026
For each index i, print product of all elements except arr[i]. Do it without using division....

Missing Number from 1..n

Medium
5 views 24 Jan 2026
Array has n-1 numbers from 1..n, one number is missing. Find and print it....

Minimum Swaps to Group

Medium
5 views 24 Jan 2026
Given array and value k, you want all elements ...

Equilibrium Index

Medium
5 views 24 Jan 2026
Find an index i such that sum of left side equals sum of right side. Print smallest such index, else -1....

Top K Frequent Numbers

Medium
4 views 24 Jan 2026
Given an array, print the k most frequent numbers. If frequency ties, smaller number comes first....

Longest Two-Type Subarray

Medium
4 views 24 Jan 2026
Given an array, find the longest contiguous subarray that contains at most 2 distinct numbers. Print its length....

Right Rotate Using Cycles

Medium
4 views 24 Jan 2026
Rotate array to the right by k steps, in-place idea using gcd cycles. Print rotated array....

Next Greater Element (Right)

Medium
6 views 24 Jan 2026
For each element, find the next greater element on its right side. If none, print -1 at that position....

Sort 0 1 2

Medium
4 views 24 Jan 2026
Array me sirf 0,1,2 hain. Sort it in O(n) time and O(1) extra space....

Subarrays Divisible by K

Medium
5 views 24 Jan 2026
Count subarrays whose sum is divisible by k....

Spiral Print Matrix

Medium
6 views 24 Jan 2026
Given r x c matrix, print all elements in spiral order....

Count Inversions

Hard
6 views 24 Jan 2026
Count number of inversions in the array (iarr[j]). Print the count....

Trapping Rain Water

Hard
5 views 24 Jan 2026
Given heights array, find how much water can be trapped after rain....

Largest Rectangle in Histogram

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

Minimum Jumps to End

Hard
6 views 24 Jan 2026
Each element tells max jump length. Find minimum jumps needed to reach last index. If not possible, print -1....

Maximum of Minimums

Hard
5 views 24 Jan 2026
For every window size from 1 to n, print the maximum among all minimums of windows of that size....

Split Array Min Largest Sum

Hard
5 views 24 Jan 2026
Given array and m, split into m continuous parts so that the largest part sum is minimum. Print that minimum largest sum....

Length of LIS

Hard
5 views 24 Jan 2026
Find length of the Longest Increasing Subsequence (not necessarily contiguous)....

Shortest Subarray With Sum At Least K

Hard
3 views 24 Jan 2026
Given array (can have negatives) and value K, find the length of shortest subarray with sum >= K. If not found, print -1....

Minimum Length Subarray (Positive)

Medium
5 views 24 Jan 2026
Numbers are all positive. Find the minimum length of a contiguous subarray with sum >= S. If not possible, print 0....

Max Subarray Sum With One Deletion

Hard
4 views 24 Jan 2026
You may delete at most one element from the array (or delete none). Find the maximum subarray sum possible after that....

Async Double

Easy
4 views 24 Jan 2026
Given a number x, return 2*x using async/await style. Print the result....

Await Then Print

Easy
3 views 24 Jan 2026
Input has one line text. Print the same text, but do it inside an async function with one await....

Async Max of Two

Easy
6 views 24 Jan 2026
Given two numbers a and b, find the bigger number using async/await and print it....

Async Add Three

Easy
3 views 24 Jan 2026
Given three integers a b c, return their sum using async function add(). Print sum....

Async Even or Odd

Easy
3 views 24 Jan 2026
Given an integer n, write async function that returns EVEN or ODD. Print it....

Async Safe Divide

Easy
2 views 24 Jan 2026
Given a and b, do a/b using async function. If b is 0, catch error and print DIV0....

Async Parse JSON Number

Easy
4 views 24 Jan 2026
Input is a JSON value. If it is a number, print it. Otherwise print INVALID. Do parsing inside async/await....

Async Reverse Words

Easy
2 views 24 Jan 2026
Given a sentence, reverse word order using an async function and print it....

Async Count Digits

Easy
7 views 24 Jan 2026
Given an integer n, count digits (ignore sign) using async function and print count....

Parallel Squares Sum

Medium
3 views 24 Jan 2026
Given n numbers, square each number using async function in parallel (Promise.all). Print sum of squares....

Async Map Series

Medium
3 views 24 Jan 2026
Given n numbers, apply async transform f(x)=x*3+1 one by one (series). Print results....

Async Map Parallel Preserve Order

Medium
4 views 24 Jan 2026
Given n numbers, apply async transform f(x)=x*x-1 in parallel, but output must be in original order....

AllSettled Summary

Medium
3 views 24 Jan 2026
Given n integers. Create promise for each: resolve if x is even, reject if x is odd. Use allSettled and print okCount failCount....

Async Reduce Sum

Medium
4 views 24 Jan 2026
Given n integers, sum them using async reduce pattern (await inside loop). Print sum....

Sequential vs Parallel Time (Simulation)

Medium
3 views 24 Jan 2026
You have n task durations. If done sequentially, total is sum. If done in parallel with unlimited workers, total is max. Print both totals....

Retry Until Non-Zero

Medium
4 views 24 Jan 2026
You get attempts and a list of values returned by a flaky API (length attempts). The first non-zero value means success. Print the value, or FAIL....

Promise Chain Without Nesting

Medium
2 views 24 Jan 2026
Input has n numbers. Apply steps on each number: +1 then *2 then -3. Use async/await and print final numbers....

Limit Concurrency and Preserve Order

Hard
4 views 24 Jan 2026
Given n numbers and limit k, apply async function f(x)=x*x with at most k in flight. Output results in original order....

Limit Concurrency with Error Count

Hard
3 views 24 Jan 2026
Given n numbers and limit k. Task rejects if number is negative, else resolves with abs value. Run with max k concurrency and print okCount failCount....

Execute Steps Until Cancel

Hard
3 views 24 Jan 2026
Given totalSteps N and cancelAt (1-based). Run an async loop from 1..N. If i reaches cancelAt, stop and print CANCELLED i. If cancelAt is 0, complete and print DONE N....

Async Task Order by Priority (Simulation)

Hard
5 views 24 Jan 2026
You have n tasks, each has priority and value. You always pick highest priority next (bigger is higher). Process in that order and print the final values (value*2)....

Async Batch Processing

Hard
2 views 24 Jan 2026
Given n numbers and batch size b. Process each batch in parallel, but inside a batch do series (await each). Output total batches and the final sum....

Run Until First Success (Parallel)

Hard
3 views 24 Jan 2026
Given n values. For each value x, async task succeeds if x%3==0 and returns x. Run all tasks in parallel and print the smallest successful value, else print NONE....

Async Dependency Finish Time

Hard
4 views 24 Jan 2026
You have tasks 1..n with durations. Also m dependencies (u v) meaning u must finish before v starts. Compute total minimum time to finish all tasks (no worker limit)....

Async Absolute Value

Easy
5 views 24 Jan 2026
Given an integer n, print its absolute value using async/await style....

Promise.any First Success

Medium
3 views 24 Jan 2026
Given n numbers, a task succeeds if number is divisible by 5. Run tasks and print the first successful number in input order. If none, print ALL_FAIL....

Async Filter Positives

Medium
3 views 24 Jan 2026
Given n integers, keep only positive numbers using async predicate. Print new length and the filtered list....

Async Cache (Count API Calls)

Medium
2 views 24 Jan 2026
You have q keys. API for key k returns k*k. Use caching so each distinct key calls API only once. Print apiCalls, then outputs for each query....

Semaphore Validity (Simulation)

Medium
4 views 24 Jan 2026
You have capacity C and a list of events: ACQ or REL. ACQ means one async job started, REL means one finished. If at any time active goes above C or REL happens at active=0, print INVALID else VALID....

Chunked Parallel Sum

Medium
5 views 24 Jan 2026
Given n numbers and chunk size c. For each chunk, sum numbers in parallel (Promise.all) and add to total. Print final total sum....

Completion Order with Concurrency Limit

Hard
4 views 24 Jan 2026
You have n task durations and limit k. Start first k tasks. When one finishes, start next. Print total time in first line, and completion order of task indices (1-based) in second line....

First Fulfilled with Concurrency Limit

Hard
2 views 24 Jan 2026
Given n numbers and limit k. Task succeeds if x is prime (returns x), else rejects. Run with max k in-flight and print the first fulfilled value in input order; if none, print NONE....

Grade Maker

Easy
3 views 24 Jan 2026
Marks diye hain (0 to 100). Print grade as per rule: 90+ A, 80-89 B, 70-79 C, 60-69 D, else F....

Day Name (Switch)

Easy
3 views 24 Jan 2026
Input is day number (1-7). Print day name (Monday..Sunday). If number is out of range, print INVALID....

Factorial Big

Easy
3 views 24 Jan 2026
Given n, print n! (factorial). Use loop and BigInt because number can be big....

Sum Until Zero

Easy
4 views 24 Jan 2026
Input has integers separated by spaces/new lines. Keep adding until you see 0. Print the sum (0 is not included)....

Odd Even Count

Easy
3 views 24 Jan 2026
Given n numbers, count how many are odd and how many are even. Print as: oddCount evenCount....

Number Staircase

Easy
2 views 24 Jan 2026
Given n, print staircase pattern of numbers. Line i has numbers from 1 to i (space separated)....

Leap Year Check

Easy
3 views 24 Jan 2026
Year diya hai. Print YES if leap year else NO. Leap year rules apply (div by 400 or div by 4 but not by 100)....

First Multiple of 7

Easy
3 views 24 Jan 2026
Given N, find the smallest multiple of 7 which is >= N. Print that number....

Digit Product

Easy
4 views 24 Jan 2026
Given an integer n, find the product of its digits (ignore sign). Print the product....

Collatz Steps

Medium
2 views 24 Jan 2026
Given n, apply Collatz until it becomes 1. If n is even: n=n/2 else n=3n+1. Print number of steps. If steps cross 1000000, print -1....

RPS Winner

Medium
3 views 24 Jan 2026
Two players played Rock-Paper-Scissors for n rounds. You get two strings A and B (length n) with chars R/P/S. Print A if player A wins, B if player B wins, else DRAW....

ATM Notes Breakdown

Medium
5 views 24 Jan 2026
Given amount, break it into notes of 2000,500,200,100,50,20,10 using greedy. Print counts in same order. If amount is not multiple of 10 or negative, print -1....

Password Strength Check

Medium
5 views 24 Jan 2026
Given a password string, print STRONG if it has at least 8 chars and contains at least one lowercase, uppercase, digit, and one special from !@#$%^&*. Otherwise print WEAK....

First Non-Repeating Character

Medium
4 views 24 Jan 2026
Given a lowercase string, find the first character that does not repeat. Print the character, or -1 if all repeat....

Run-Length Encode

Medium
6 views 24 Jan 2026
Given a string, compress it using run-length encoding: aaaabb -> a4b2. Print encoded string....

12h to 24h Time

Medium
4 views 24 Jan 2026
Input is time in 12-hour format like HH:MM AM/PM. Convert to 24-hour format HH:MM and print....

Pascal Row

Medium
2 views 24 Jan 2026
Given n (0-based), print n-th row of Pascal triangle (space separated)....

Count Primes in Range

Medium
3 views 24 Jan 2026
Given L and R, count how many prime numbers are there in [L,R]....

Robot Final Position

Medium
4 views 24 Jan 2026
You get a string of commands with letters L,R,U,D. Start at (0,0). Print final x y....

First Return to Origin

Medium
3 views 24 Jan 2026
You get command string L,R,U,D. Find the earliest step (1-based) when position becomes (0,0) again. If never, print -1....

Postfix Calculator

Medium
6 views 24 Jan 2026
Given a postfix expression with space-separated tokens (numbers and + - * /). Evaluate it and print result. Division is integer division toward zero....

Until One (Reduce Rules)

Medium
3 views 24 Jan 2026
Given n, in one step you can do: if even n=n/2 else n=n-1. Count steps to reach 1. Print steps....

Longest Valid Parentheses

Hard
4 views 24 Jan 2026
Given a string with only '(' and ')', find length of the longest valid (well-formed) parentheses substring....

Decode Bracket String

Hard
4 views 24 Jan 2026
Input like 3[a2[c]] means repeat inside brackets. Decode and print final string....

Min Operations to One

Hard
3 views 24 Jan 2026
You can do operations: n=n-1, if n%2==0 n=n/2, if n%3==0 n=n/3. Find minimum steps to make n to 1....

Shortest Path in Maze

Hard
4 views 24 Jan 2026
You get a grid with 0 (free) and 1 (blocked). Find shortest steps from (0,0) to (r-1,c-1) moving 4 directions. Print -1 if not possible....

Ways to Climb with Broken Steps

Hard
3 views 24 Jan 2026
You have n steps. You can climb 1 or 2 steps. Some steps are broken (cannot land). Count number of ways to reach step n mod 1000000007....

Vending Machine Simulator

Hard
4 views 24 Jan 2026
You start with balance 0. Commands: COIN x (add to balance) and BUY p (try to buy item price p). If balance>=p print OK and reduce balance, else print NEED. At end print final balance....

Sudoku Valid Rows and Columns

Hard
3 views 24 Jan 2026
Given 9x9 grid (0 means empty), check if rows and columns are valid (no duplicate 1..9). Print YES or NO....

Josephus Winner

Hard
3 views 24 Jan 2026
n people are standing in a circle (1..n). Starting from 1, every k-th person is removed. Print the winner position....

Mini Jump Interpreter

Hard
3 views 24 Jan 2026
You get m instructions. Each instruction is: INC x, DEC x, JNZ x off. x is variable name (single word). Start all vars at 0. Execute from line 1. JNZ jumps relative if x!=0. Stop when pointer goes out...

Traffic Light Waiting Time

Medium
3 views 24 Jan 2026
A traffic light has 3 phases: Red, Yellow, Green with fixed durations. You are given current phase (R/Y/G) and how many seconds are left in that phase. Find how many seconds you will wait to see Green...

Truthy Tally

Easy
2 views 24 Jan 2026
You get a JSON array. Count how many values are truthy in JavaScript (like 1, "hi", [], {} are truthy; 0, "", null, false are falsy). Print the count....

Nullish Fallback

Easy
5 views 24 Jan 2026
Two JSON values are given on two lines: a and b. Print the value of (a ?? b) as JSON (stringified). Remember: only null and undefined trigger the fallback, not 0 or empty string....

Number-ish Check

Easy
2 views 24 Jan 2026
One string is given. If JavaScript Number(s) becomes a valid number (not NaN), print YES else print NO....

Minus Zero Detector

Easy
8 views 24 Jan 2026
One number is given as string (can be -0). Print YES if it is exactly -0 in JavaScript, else NO....

Finite or Not

Easy
4 views 24 Jan 2026
One number string is given. Print YES if it is a finite number in JavaScript (not NaN, not Infinity), else NO....

Basic Type Buckets

Easy
5 views 24 Jan 2026
You get a JSON array with mixed values. Count how many are: number, string, boolean, null, array, object. Print 6 counts in this order....

Loose vs Strict

Easy
5 views 24 Jan 2026
Two JSON values are given on two lines: a and b. Print two words: the result of (a == b) and (a === b) as YES/NO....

ToString Difference

Easy
2 views 24 Jan 2026
One JSON value is given. Print two values: String(v) and JSON.stringify(v). If JSON.stringify gives undefined, print the word UNDEFINED there....

Same Type or Not

Easy
6 views 24 Jan 2026
Two JSON values are given on two lines. Print YES if both values have the same JavaScript type (treat null as its own type and array as its own type). Else print NO....

Deep Type Summary

Medium
3 views 24 Jan 2026
You get one JSON value (can be nested). Traverse all nested values and count how many times each type appears: number, string, boolean, null, array, object. Print counts as JSON object....

Stable JSON Print

Medium
5 views 24 Jan 2026
Given a JSON object, print the same object but with keys sorted alphabetically at every level (recursive). Output should be JSON string....

Safe Add (Number or BigInt)

Medium
4 views 24 Jan 2026
Two integers are given as strings. If both fit safely in JavaScript Number and the sum is also safe, print the sum as Number. Otherwise print the sum using BigInt....

Coerce and Sum (Ignore NaN)

Medium
7 views 24 Jan 2026
You get a JSON array. Convert every item with Number(x). Ignore items that become NaN. Sum remaining values and print the sum....

Object.is Checker

Medium
3 views 24 Jan 2026
You get q queries. Each query has two number strings a and b. For each, print SAME if Object.is(a,b) is true, else DIFF. Handles NaN and -0 properly....

Normalize Mixed to Strings

Medium
4 views 24 Jan 2026
You get a JSON array. Convert each item to a display string: primitives use String(x), null becomes 'null', objects/arrays become JSON string. Print JSON array of these strings....

Strict Integer Token

Medium
4 views 24 Jan 2026
One line has space-separated tokens. For each token, print YES if it is a valid base-10 integer format: optional leading '-' and digits, and no leading zeros unless the number is exactly 0. Else print...

Clamp With NaN

Medium
5 views 24 Jan 2026
Given three number strings x min max. If x is NaN print NaN. Else clamp x into [min,max] and print the result....

Big Integer Compare

Medium
3 views 24 Jan 2026
Two big integers are given as strings (may be negative). Print -1 if A < B, 0 if equal, 1 if A > B....

Bytes to Human

Medium
4 views 24 Jan 2026
Bytes amount is given. Print size in B, KB, MB, or GB with 2 decimals (base 1024). Example: 1536 -> 1.50 KB....

Array-Like to Array

Medium
4 views 24 Jan 2026
You get a JSON object having numeric keys and a length. Build a real array of that length. If a key is missing, keep null there. Print the array as JSON....

Plain Object Flags

Medium
4 views 24 Jan 2026
You get a JSON array. For each item print PLAIN if it is a plain object (typeof object, not null, not array). Else print NO. One output per line....

Filter by Type

Medium
3 views 24 Jan 2026
You get a JSON array and a type name. Keep only items matching that type (number,string,boolean,null,array,object) and print the resulting JSON array....

Sort Mixed (Numeric First)

Medium
4 views 24 Jan 2026
You get n tokens (strings). If a token is a valid finite number, treat it as numeric. Sort numeric tokens by numeric value. Non-numeric tokens come later sorted lexicographically. Print the final list...

Deep Equal (JSON)

Hard
5 views 24 Jan 2026
Two JSON values are given on two lines. Check deep equality: primitives compare normally (NaN does not appear in JSON), arrays compare by order, objects compare by keys and values ignoring key order. ...

Deep Merge Two Objects

Hard
6 views 24 Jan 2026
Two JSON objects are given on two lines. Merge them deeply: if both values are objects -> merge, if both are arrays -> concatenate, otherwise second value overrides. Print merged object as JSON....

Validate Value by Schema

Hard
3 views 24 Jan 2026
Two JSON values are given on two lines: schema and value. Schema has field type (number|string|boolean|null|array|object). For array, schema can have items. For object, schema can have props and requi...

Get JSON Value by Path

Hard
5 views 24 Jan 2026
You get a JSON object, then a path string like a.b[0].c. Print the value at that path as JSON. If path does not exist, print null....

Set JSON Value by Path

Hard
7 views 24 Jan 2026
You get a JSON object, a path like a.b[0].c, and a JSON value. Set that path in the object (create objects/arrays when needed). Print updated object as JSON....

Top-Level JSON Array Split

Hard
4 views 24 Jan 2026
One line has a JSON array as plain text (do NOT parse). Count how many top-level elements are present, ignoring commas inside strings/brackets. Print the count....

Canonical JSON Hash

Hard
6 views 24 Jan 2026
Given a JSON object, create canonical JSON by sorting keys recursively, then compute 32-bit FNV-1a hash of that canonical string. Print hash as unsigned integer....

Parse Query String (Typed)

Hard
3 views 24 Jan 2026
You get a query string like key=value&key=value. Decode %xx and + as space. Convert values: 'true'/'false' -> boolean, numbers -> number, else string. Repeated keys become arrays. Print JSON object....

Minify JSON Text

Hard
3 views 24 Jan 2026
Input is a JSON value as text (may contain spaces and new lines). Without parsing it, remove all whitespace that is outside string literals. Print the minified JSON text....

JS Identifier Check (ASCII)

Hard
4 views 24 Jan 2026
One string is given. Print YES if it is a valid JavaScript identifier using only ASCII rules: first char is letter/_/$, next chars are letters/digits/_/$. Otherwise NO....

Show/Hide Text on Button Click

Easy
4 views 24 Jan 2026
You have a button #btn and a text box #box. On click, toggle #box display between block and none....

Live Character Count

Easy
2 views 24 Jan 2026
You have and . While typing, show current character count inside #count....

Add Item to List

Easy
2 views 24 Jan 2026
You have , , and
    . On button click, add a new
  • with input text (trim). Ignore if empty....

Remove Element by Click

Easy
4 views 24 Jan 2026
You have many elements with class card. When any card is clicked, remove only that card from DOM....

Highlight Even Table Rows

Easy
2 views 24 Jan 2026
You have a table with rows inside . Add class even-row to every even row (2nd, 4th, ...)....

Toggle Password Visibility

Easy
3 views 24 Jan 2026
You have and . On click, change input type between password and text, and update button text to SHOW/HIDE....

Disable Submit for Empty Required

Easy
3 views 24 Jan 2026
You have a form #f with inputs having attribute data-req=1. Disable button #submit until all required inputs have some value (trimmed)....

Run Click Handler Only Once

Easy
2 views 24 Jan 2026
You have a button #once. When clicked first time, set its text to DONE and disable it. Further clicks should not run the handler logic....

Read Data Attribute and Show It

Easy
2 views 24 Jan 2026
You have
and . On page load, read data-id and show it inside #out....

Dynamic List Delete (Event Delegation)

Medium
2 views 24 Jan 2026
You have
    where each
  • contains text and a Delete. Items can be added later. On clicking Delete, remove that
  • . Use event delegation....

Debounce Search Filter

Medium
3 views 24 Jan 2026
You have and many items with class item inside #list. Filter items by text content (case-insensitive). Debounce the filtering by 300ms....

Tabs Component

Medium
3 views 24 Jan 2026
You have buttons with class tab-btn and data-tab=panelId. Panels have class tab-panel and id matching data-tab. On click, show only that panel and add class active on the clicked button....

Accordion Toggle

Medium
5 views 24 Jan 2026
You have sections .acc where each has a header .acc-head and body .acc-body. On clicking header, toggle its body. Close other bodies in the same container....

Modal Open/Close with ESC

Medium
5 views 24 Jan 2026
You have #open button and a modal #modal with a close button #close. On open show modal (add class show). On close/ESC click hide it (remove class show)....

Smooth Scroll to Section

Medium
3 views 24 Jan 2026
You have anchor links with class jump and href like #section1. On click, prevent default and smoothly scroll to the target element....

Copy Text to Clipboard

Medium
2 views 24 Jan 2026
You have . On click, copy data-copy text to clipboard and change button text to COPIED for 1 second....

Serialize Form to JSON

Medium
3 views 24 Jan 2026
You have a form #f and a
. On submit, prevent default and print JSON of all fields into #out. Multiple same-name fields should become an array....                        

Lazy Load Images

Medium
5 views 24 Jan 2026
Images have data-src and class lazy. When an image is near viewport, set its src from data-src and remove class lazy. Use IntersectionObserver....

Infinite Scroll Add Items

Medium
2 views 24 Jan 2026
You have
. When user scrolls near bottom (within 200px), append 10 new
Item N
. Keep count with variable start....

Resizable Box (Drag Handle)

Medium
3 views 24 Jan 2026
You have a box #box and a handle #handle in its bottom-right corner. On dragging handle, resize the box (width/height) with minimum 100px....

Auto Save Textarea to localStorage

Medium
8 views 24 Jan 2026
You have and a . Save textarea value to localStorage key note_text on input (debounced 200ms). On load, restore. Clear button removes storage and clears textarea....

Sort Table by Clicking Header

Medium
3 views 24 Jan 2026
You have a table #t with . Rows are in . On clicking a header, sort rows by that column text. Toggle asc/desc each time....

Max Length Counter with Warning

Medium
4 views 24 Jan 2026
You have and . Show how many characters left. If limit exceeded, add class bad on #text....

Simple Tooltip on Hover

Hard
5 views 24 Jan 2026
Elements with attribute data-tip should show a tooltip div near mouse on hover and hide on mouse leave....

Hash Router (Single Page)

Hard
3 views 24 Jan 2026
You have a container #view and multiple templates , etc. Use location.hash (like #home). On hash change, render matching template into #view. Default to home....

Sortable List (Drag and Drop)

Hard
2 views 24 Jan 2026
You have
    with
  • . Allow user to reorder list items by drag and drop....

Modal Focus Trap (Accessibility)

Hard
5 views 24 Jan 2026
You have #modal with focusable elements and class show means open. When open, trap Tab/Shift+Tab inside modal. ESC closes....

Virtual List Rendering

Hard
5 views 24 Jan 2026
You have a container #list with fixed height and overflow auto. Render 10000 rows but keep only visible rows in DOM using virtualization. Row height is 30px....

Undo/Redo for Textarea

Hard
3 views 24 Jan 2026
You have , , . Keep history of changes (max 50). Undo/redo should update textarea value....

Auto Number Headings with MutationObserver

Hard
4 views 24 Jan 2026
You have a container #article where headings are

. Prefix each heading text with its number like '1. Title'. If headings change later, auto re-number....

Keyboard Navigation Dropdown

Hard
3 views 24 Jan 2026
You have
with and
  • ..
. Implement open/close and keyboard: Enter/Space opens, ArrowDown/ArrowUp moves focus inside list, E...

Clipboard Copy with Fallback

Hard
4 views 24 Jan 2026
You have #btn and #src (text input). On click copy #src value. Use navigator.clipboard when available, else fallback using a hidden textarea and document.execCommand('copy'). Show result in #msg....

Image Gallery Lightbox

Hard
4 views 24 Jan 2026
You have thumbnails .thumb with data-full URL. On click, open overlay #light with . Clicking overlay closes. ESC closes too....

Safe Divide

Easy
4 views 24 Jan 2026
Two integers a and b are given. If b is 0, handle it safely and print ERR. Otherwise print integer division result (truncate towards zero)....

Parse Integer or INVALID

Easy
4 views 24 Jan 2026
One token is given. If it is a valid base-10 integer (like -12, 0, 99) print its double. Else print INVALID. Use try/catch for validation....

Required String Check

Easy
3 views 24 Jan 2026
One line text is given. If after trim it becomes empty, throw error EMPTY and print EMPTY. Else print trimmed length....

Safe BigInt Convert

Easy
3 views 24 Jan 2026
One token is given. Convert to BigInt safely. If conversion fails, print BAD. Else print value+1....

JSON Parse or Empty Object

Easy
3 views 24 Jan 2026
One line is given (supposed to be JSON). If it parses, print it back as JSON string. If parsing fails, print {}....

Missing Key Finder

Easy
3 views 24 Jan 2026
Input has a JSON object in line1 and a key in line2. If key is present (own property), print its value as JSON. Else print MISSING....

Clamp Numbers but Validate Range

Easy
4 views 24 Jan 2026
Three integers x min max are given. If min > max, handle the error and print BAD_RANGE. Else clamp x into [min,max] and print it....

Try Catch Finally Score

Easy
3 views 24 Jan 2026
One integer x is given. In try block add 1, and if x...

Promise Reject Catch (Single)

Easy
2 views 24 Jan 2026
One integer n is given. Create a promise that rejects if n is odd, else resolves. Using async/await and try/catch, print OK or ERR....

Sum Tokens with Error Count

Medium
3 views 24 Jan 2026
One line has space separated tokens. Add only tokens that are valid finite numbers. Count bad tokens (NaN/Infinity/non-number). Print: sum badCount....

Timeout Simulation

Medium
4 views 24 Jan 2026
Two integers workMs and timeoutMs are given. Simulate a task that resolves after workMs. If it does not finish within timeoutMs, print TIMEOUT else DONE....

Retry Task Until Success

Medium
4 views 24 Jan 2026
Input has attempts and failCount. A task fails first failCount times then succeeds. Retry using async/await. Print SUCCESS if it succeeds within attempts else FAIL....

Wrap Error and Print Chain

Medium
4 views 24 Jan 2026
One word is given. If it is NEG, throw error NEG inside inner(). Outer should catch it, wrap as OUTER and attach cause. Finally print messages chain like OUTER->NEG....

Validate User Record (Multi Errors)

Medium
3 views 24 Jan 2026
One JSON object is given with fields name, age, email. Check: name is non-empty string, age is integer 1..120, email contains @. Print OK if valid else print all errors joined by ;...

JSON Lines Sum (Skip Bad)

Medium
6 views 24 Jan 2026
First line n, then n lines each should be a JSON number. Sum valid numbers. Count how many lines were bad JSON or not a finite number. Print: sum badCount....

Try Parse JSON Else Number Else String

Medium
3 views 24 Jan 2026
One line text is given. First try JSON.parse. If it fails, try Number() and if finite print NUMBER . Else print STRING ....

Custom HttpError

Medium
3 views 24 Jan 2026
One integer status code is given. If status is 400 or more, throw HttpError with message BAD_REQUEST for 400-499 and SERVER_ERROR for 500+. Catch and print: status message. If ...

Stop on First Invalid JSON Line

Medium
3 views 24 Jan 2026
First line n and then n lines (any JSON). Parse line by line. If a line is invalid JSON, print BAD k (1-based) and stop. If all ok, print OK....

Parse Date YYYY-MM-DD

Medium
3 views 24 Jan 2026
One date string is given in format YYYY-MM-DD. Validate it properly (real calendar). If invalid print INVALID else print DAYOFWEEK as 0..6 (0=Sunday)....

Safe Object Path Read

Medium
3 views 24 Jan 2026
Line1 is JSON object, line2 is a dot path like a.b.c. If path exists print value as JSON. If any step missing, handle error and print null....

Cleanup Counter with Finally

Medium
3 views 24 Jan 2026
Input has n and failAt. Simulate opening a resource n times in loop and closing in finally. If i equals failAt, throw. Print final openCount (should be 0)....

Promise Chain Error Recovery

Medium
3 views 24 Jan 2026
Two integers a and b are given. Start a promise with a. In then, if b is 0 throw DIV0 else divide. Catch error and output 0. Otherwise output result....

Transactional Array Updates

Hard
4 views 24 Jan 2026
You are given an array and update operations. If any operation is invalid (index out of range), rollback everything and print ROLLBACK and original array. Else print OK and final array....

Strict JSON Lines Sum (Stop Early)

Hard
4 views 24 Jan 2026
First line n then n lines, each should be a JSON number. If any line is invalid JSON or not finite number, print LINE k and stop. Otherwise print the sum....

Template Fill (Strict Keys)

Hard
5 views 24 Jan 2026
Line1 is a template with placeholders like {name}. Line2 is a JSON object. Replace placeholders with values. If any key is missing, print MISSING key. Else print final string....

Expression Evaluate or ERR pos

Hard
3 views 24 Jan 2026
One line expression has digits, + - * / ( ) and spaces. Evaluate with correct precedence. If any invalid character appears, print ERR pos (1-based index in original string)....

Promise Pool Stop After K Failures

Hard
3 views 24 Jan 2026
You get n numbers and limit k. Each task rejects if number is odd, resolves if even. Run tasks in order with concurrency 3. Stop starting new tasks after failures become > k. Print startedCount failCo...

Deep Required Paths Checker

Hard
4 views 24 Jan 2026
Line1 is JSON object. Line2 has integer q. Next q lines are paths like a.b[0].c. If any path missing, collect them and print MISSING count and list. Else print OK....

Error Code Summary

Hard
4 views 24 Jan 2026
Input has n lines. Some lines look like ERROR:CODE where CODE is a word. Count each code and print in descending count, tie by code. Ignore lines that do not match....

Strict CSV Rows Count

Medium
3 views 24 Jan 2026
First line n then n lines. Each line must have exactly 3 comma-separated parts (no escaping). For each line, if it is valid count it as ok, else count as bad. Print: ok bad....

Balance Transaction Rollback

Hard
4 views 24 Jan 2026
First line balance. Next line m. Next m lines are operations: DEBIT x or CREDIT x. If any debit makes balance negative, rollback all and print ROLLBACK and original balance. Else print COMMIT and fina...

Deep Merge Strict Types

Hard
6 views 24 Jan 2026
Two JSON objects are given on two lines. Deep merge them: object+object merges keys, array+array concatenates, primitives override. But if types mismatch (like object vs array), stop and print TYPE_MI...

Array First Element

Medium
4 views 23 Jan 2026
Return the first element from a JavaScript array....

Array Length

Medium
4 views 23 Jan 2026
Return total number of elements in a JavaScript array....