2 views
24 Jan 2026
Read n pairs. Using recursion function back(pos,open,close), count how many balanced strings are possible. Output count....
3 views
24 Jan 2026
Read n and n integers (n...
3 views
24 Jan 2026
Read a b m, write function modpow(a,b,m) using binary exponent and output a^b mod m....
2 views
24 Jan 2026
Read n intervals [l,r]. Write function merge(intervals) and output merged intervals sorted....
2 views
24 Jan 2026
Read an undirected graph with n nodes and m edges and two nodes s and t. Use helper function bfs to output shortest distance (edges count) or -1....
4 views
24 Jan 2026
Read n integers. Use function mergesort_count(arr) to return inversion count and output it....
3 views
24 Jan 2026
Read n commands: PUSH x, POP, TOP. Use functions do_push, do_pop, do_top on a stack and output TOP outputs (or EMPTY)....
2 views
24 Jan 2026
Read a string s (lowercase) and q queries l r (1-based). Use helper function to build prefix hashes and answer hash values mod 1000000007....
3 views
24 Jan 2026
Read n integers and q queries. Two types: 1 i x means set a[i]=x, 2 l r means output sum of a[l..r] (1-based). Use functions build, update, query....
2 views
24 Jan 2026
Read n integers. Output the sum....
3 views
24 Jan 2026
Read n integers. Output minimum and maximum in one line....
2 views
24 Jan 2026
Read n integers. Output them in reverse order....
2 views
24 Jan 2026
Read n integers. Count how many are > 0 and output count....
2 views
24 Jan 2026
Read n integers and a target x. Output the first index (0-based) where x appears, else -1....
2 views
24 Jan 2026
Read n integers and value x. Remove all x and output remaining numbers. If nothing left output EMPTY....
3 views
24 Jan 2026
Read q commands: PUSH x or POP. Start empty list. POP on empty does nothing. At end output size and last element (or EMPTY)....
3 views
24 Jan 2026
Read two lists A and B. Output concatenated list A followed by B....
2 views
24 Jan 2026
Read n integers. Output YES if list is non-decreasing else NO....
2 views
24 Jan 2026
Read n integers. Build a new list of size n-1 where b[i]=a[i]+a[i+1]. Output b (or EMPTY if n...
2 views
24 Jan 2026
Read n integers and k. Rotate list to the right by k positions and output....
2 views
24 Jan 2026
Read two integers a and b. Swap them and output the swapped values. Use Python multiple assignment....
2 views
24 Jan 2026
Read n integers and q queries l r (1-based). Output sum of each range....
2 views
24 Jan 2026
Principal P, rate R (in percent), and time T (in years) are provided. Output simple interest = (P*R*T)/100. If result is integer, output without decimals else output up to 2 decimals....
2 views
24 Jan 2026
Read n integers and target T. Output YES if there exist i...
2 views
24 Jan 2026
Celsius value C is provided. Convert to Fahrenheit F = C*9/5 + 32 and output with 2 decimals....
2 views
24 Jan 2026
Read n integers. Compress as pairs value count for consecutive equal values. Output pairs in new lines....
2 views
24 Jan 2026
Read one integer n. Output two things: last digit of |n| and the sign as NEG, ZERO, or POS....
3 views
24 Jan 2026
Read n integers. Remove duplicates but keep first occurrence order. Output the new list....
4 views
24 Jan 2026
Total seconds S is provided. Convert it to hh:mm:ss (00 padded) assuming 0 ...
3 views
24 Jan 2026
Read n integers. Output the second largest distinct value, or NONE if not exists....
3 views
24 Jan 2026
Read two numbers length L and width W. Output area L*W. Output without trailing zeros (like Python str())....
4 views
24 Jan 2026
Read n bits (0/1). Compute longest consecutive 1s length....
2 views
24 Jan 2026
Read two integers x and y. Do these updates in order: x=x+y, y=y+1, x=x-y. Output final x and y....
2 views
24 Jan 2026
Read n positive integers and target S. Output YES if there exists a subarray with sum exactly S else NO....
2 views
24 Jan 2026
Read one integer n. Count number of digits in |n| without converting to string. For n=0 answer is 1....
2 views
24 Jan 2026
Read n integers. Sort them by frequency ascending, if tie by value ascending. Output sorted list....
2 views
24 Jan 2026
First name and last name are provided. Output as 'Last, First'....
2 views
24 Jan 2026
Read n integers. Move all zeros to end keeping order of non-zeros. Output result....
5 views
24 Jan 2026
Input has two integers n and k are provided (k>0). Round n to nearest multiple of k. If exactly middle, round up....
2 views
24 Jan 2026
Read n integers and pivot x. Output list such that all x. Keep relative order inside each group....
3 views
24 Jan 2026
Read three integers a b c. Rotate left once: a...
3 views
24 Jan 2026
Read r and c and then matrix. Output transpose matrix (c rows each has r numbers)....
4 views
24 Jan 2026
Read n pairs (a,b). For each pair swap them and output. This is to practice variable assignment quickly....
2 views
24 Jan 2026
Read r and c and a matrix. Output elements in spiral order....
3 views
24 Jan 2026
Read opening balance B and m operations. Each operation is: ADD x or SUB x. Output final balance....
2 views
24 Jan 2026
Read n integers. If an element appears more than n/2 times, output it else output NONE....
2 views
24 Jan 2026
Read n integers, output min, max, and (max-min). Use variables, one pass....
4 views
24 Jan 2026
Read n integers and k (1-based). Compute kth smallest element using quickselect style and output it....
3 views
24 Jan 2026
Read n integers, find the second largest DISTINCT number. If it doesn't exist, output NONE....
2 views
24 Jan 2026
Read n integers. Output length of longest increasing subsequence....
2 views
24 Jan 2026
You will receive q commands on variable x: SET v, ADD v, MUL v. Start x=0. After all commands output x....
3 views
24 Jan 2026
Read n integers and window size k. For each window output maximum. Use deque logic....
2 views
24 Jan 2026
You have two variables a and b starting at 0. You get q commands: SETA x, SETB x, ADDA x, ADDB x, SWAP. Output final a and b....
3 views
24 Jan 2026
Read n bar heights. Compute the largest rectangle area in histogram and output it....
2 views
24 Jan 2026
Read a and b for equation a*x + b = 0. Output x as reduced fraction p/q. If no solution output NONE. If infinite solutions output ALL....
5 views
24 Jan 2026
Read n heights. Water trapped between bars should be calculated and printed....
2 views
24 Jan 2026
You will receive n lines like 'x = value'. Count how many times the same variable name appears again (2nd time onwards). Output count....
3 views
24 Jan 2026
Read n integers and k. Count subarrays whose sum is divisible by k....
2 views
24 Jan 2026
One line has n and then n integers. Store them into variables: first, middle (all), last. Output first, count of middle elements, last....
3 views
24 Jan 2026
Read n integers where a[i] is max jump length from i. Output minimum jumps from 0 to n-1 or -1 if not possible....
5 views
24 Jan 2026
You will receive integer score. If score is below 0 set to 0, if above 100 set to 100. Output final value....
3 views
24 Jan 2026
Read n integers and integer k. Count number of pairs (i...
2 views
24 Jan 2026
Read one integer n. Output its binary without using bin(). Use repeated division and variables....
4 views
24 Jan 2026
Read n integers and m parts. Split array into m non-empty continuous parts to minimize the maximum part sum. Output that minimum possible value....
2 views
24 Jan 2026
Read two integers userId and orderId, build an id string as userId-orderId with zero padding of orderId to 6 digits. Output the string....
3 views
24 Jan 2026
Read n integers (can be negative). Compute maximum subarray sum in circular array and output it....
3 views
24 Jan 2026
Read n and k. Start x=0. Repeat n times: x=(x+1) % k. Output x. This is a small variable-state walk....
3 views
24 Jan 2026
Read n integers and k. Output k elements with highest frequency. If tie, smaller number first. Output in order of frequency desc then number asc....
2 views
24 Jan 2026
You will receive q queries like GET name or SET name value. Maintain variables in a dict. For each GET, output value if present else UNSET....
2 views
24 Jan 2026
Name and age are provided. Create class Person with method greet() that returns 'Hi , you are '. Output greet()....
3 views
24 Jan 2026
Read a tiny language with commands: 'let x', 'block', 'end'. Each block makes a new scope. Count how many times a let shadows a variable from an outer scope....
2 views
24 Jan 2026
Length and width are provided. Create Rectangle class with area() method. Output area as integer....
2 views
24 Jan 2026
You will receive n assignments like x = y + 5 or x = 10. Variables are single lowercase letters. Compute final values for all variables that appear on left side, assuming missing variables start at 0....
2 views
24 Jan 2026
You have a bank account with starting balance B. Then q commands: DEP x, WIT x (withdraw, but if not enough keep same). Output final balance....
2 views
24 Jan 2026
You have two variables a and b. For each step you get newA and newB expressions in terms of old a and b: 'A' means old a, 'B' means old b, or an integer. Apply parallel assignment each step (both upda...
2 views
24 Jan 2026
You have q commands: INC, DEC. Create Counter class. DEC cannot go below 0. Output final value....
2 views
24 Jan 2026
Read q operations on x starting with 0. Operations are ADD v, MUL v, and MOD m. Values can be large. Use big integers safely and output final x....
2 views
24 Jan 2026
Read n marks. Create Student class with method avg(). Output average with 2 decimals....
3 views
24 Jan 2026
You will receive n statements in a tiny language: 'set x v' or 'add x y' meaning x = x + y. If add uses a variable that was never set before (for x or y), count it as a bad read. Output badReadCount....
2 views
24 Jan 2026
Read two integers x and y. Create Point class with method dist0() giving distance from origin. Output with 3 decimals....
2 views
24 Jan 2026
You will receive n variables with values. Output the top k variables by value (desc), tie by name (asc). Each name is a string without spaces....
2 views
24 Jan 2026
Title (no spaces) and pages are provided. Create Book class with method thick() that returns YES if pages>300 else NO....
2 views
24 Jan 2026
Read a string s and integer base B and mod M. Compute rolling hash: h=0; for each char c: h=(h*B+ord(c))%M. Output h....
2 views
24 Jan 2026
Celsius value is provided. Create Temperature class with method to_f(). Output Fahrenheit with 2 decimals....
2 views
24 Jan 2026
Read n words. Maintain two counters: vowelStart and consonantStart. Increment depending on first letter of each word. Output both counts....
2 views
24 Jan 2026
Distance d, mileage m (km per litre) and fuel f are provided. Create Car class can_reach(d) returns YES if fuel enough else NO....
2 views
24 Jan 2026
Time is provided as hour (0-23) and minute (0-59). Also an integer k (can be big) is provided. Add k minutes to the time and output the new time in HH:MM format....
2 views
24 Jan 2026
You will receive q commands: PUSH x, POP, TOP. Create Stack class and for TOP output value or EMPTY....
3 views
24 Jan 2026
You have one variable x starting at 0. You get q commands: SET v, ADD v, MUL v, SNAP, ROLLBACK. SNAP saves current x. ROLLBACK restores x to the last saved SNAP and removes that SNAP. If there is no S...
2 views
24 Jan 2026
Read n items each with name, price, qty. Create Item class with total() method. Output grand total cost....
2 views
24 Jan 2026
Read an integer n, output two words. First word should be EVEN or ODD. Second word should be BIG if n is greater than 100, otherwise SMALL....
4 views
24 Jan 2026
Read n radii. Create Circle class with area() and sort circles by area ascending. Output sorted radii....
2 views
24 Jan 2026
Marks m are provided (0 to 100). Output PASS if m is at least 35, otherwise output FAIL....
2 views
24 Jan 2026
Time hh mm ss and extra seconds x are provided. Create Time class add(x) and output new time in HH:MM:SS (24h)....
4 views
24 Jan 2026
Read one integer n. Output its absolute value without using abs()....
3 views
24 Jan 2026
Read monthly salary and bonus percent. Create Employee class yearly() to return yearly salary with bonus included. Output as integer....
3 views
24 Jan 2026
Read integer n, output numbers from 1 to n in one line separated by spaces. If n is 0, output nothing....
2 views
24 Jan 2026
Read two fractions a/b and c/d. Create Fraction class that reduces and supports add. Output result as p q reduced....
3 views
24 Jan 2026
A list of integers is provided. Add numbers one by one until you see 0. Do not include 0 in sum. Output the sum....
2 views
24 Jan 2026
Read r c and two matrices. Create Matrix class with add method. Output resulting matrix....
3 views
24 Jan 2026
Read n integers. Count how many are divisible by 7 and output the count....
2 views
24 Jan 2026
You will receive q commands: ADD name, DONE name, COUNT. Create TaskTracker class. COUNT prints how many tasks are pending....
4 views
24 Jan 2026
Read a year y, output YES if it is a leap year else NO. Leap year rule: divisible by 400 or divisible by 4 but not by 100....
6 views
24 Jan 2026
Read n entries name score. Create Player class and group by name summing scores. Output names sorted with total score....
4 views
24 Jan 2026
Read three integers a, b, c. Output the maximum using if-else logic....
2 views
24 Jan 2026
You will receive q commands: ADD item price, REMOVE item, TOTAL. Create Cart class. TOTAL prints sum of prices of current items....
2 views
24 Jan 2026
One character ch is provided. Output VOWEL if it is a vowel (a,e,i,o,u in any case), CONSONANT if it is an English letter but not vowel, else output OTHER....
3 views
24 Jan 2026
You will receive q commands: ENQ x, DEQ, FRONT. Create Queue class using two stacks. FRONT prints front value or EMPTY....
3 views
24 Jan 2026
Bill amount amt is provided. If amt is less than 1000, no discount. If amt is 1000 or more, give 10 percent discount. Output final payable as integer (rounded down)....
2 views
24 Jan 2026
One URL string like domain/path is provided (no spaces). Create URL class with domain() and path() methods. If no '/', path is EMPTY....
3 views
24 Jan 2026
Read integer n, for i from 1 to n output on new line: Fizz if i divisible by 3, Buzz if divisible by 5, FizzBuzz if divisible by both, else output i....
2 views
24 Jan 2026
Read a password string. Create Validator class ok() that checks: length>=8, has at least one digit, one uppercase, one lowercase. Output YES or NO....
2 views
24 Jan 2026
Read n integers. Read in order. Stop the moment you see a negative number. Output two values: how many numbers were processed before stopping, and their sum....
2 views
24 Jan 2026
Read degree n, then n+1 coefficients from highest to constant, and x. Create Polynomial class eval(x). Output value....
2 views
24 Jan 2026
Read integer n (>0). Do: if n is even n=n/2 else n=3n+1. Count steps until n becomes 1. Output steps....
2 views
24 Jan 2026
You will receive q commands: PUSH x, POP, MIN. Create MinStack class and for MIN output current minimum or EMPTY....
2 views
24 Jan 2026
Read integer n, output PRIME if it is prime else NOT. Use loop up to sqrt and break early....
4 views
24 Jan 2026
Cache capacity cap is provided and q commands: PUT k v, GET k. Implement LRUCache class. For GET output value or -1....
3 views
24 Jan 2026
Read two integers a and b. Compute gcd(a,b) using Euclid while loop and output it....
3 views
24 Jan 2026
Read n m edges and s t. Create Graph class with bfs(s,t) method. Output shortest distance or -1....
3 views
24 Jan 2026
Read n and base b (2 to 10). Count digits needed to write n in base b. For n=0 answer is 1....
3 views
24 Jan 2026
Read n meetings as start end. Create Calendar class add(start,end) returns YES if added else NO (conflict if overlap). Output results for each add....
2 views
24 Jan 2026
Read n integers. A peak means a[i] is greater than both neighbours (i-1 and i+1). Output the first peak index (0-based). If no peak, output -1....
2 views
24 Jan 2026
You will receive q commands: SET path value, GET path. Path is dot separated. Create Store class to handle. For GET output value or NOT FOUND....
2 views
24 Jan 2026
You will receive q queries of form: op a b, where op is ADD, SUB, MUL, DIV. For DIV, if b is 0 output ERR else output integer division a//b. Output answer for each query on new line....
2 views
24 Jan 2026
Two sparse vectors are provided as list of index:value pairs. Build SparseVector class with dot(other). Output dot product....
3 views
24 Jan 2026
Read n and k, output numbers from 1 to n but skip numbers divisible by k. Output in one line separated by spaces....
4 views
24 Jan 2026
Read two complex numbers as a b and c d, meaning (a+bi) and (c+di). Create Complex class with add and mul. Output sum then product as 'x y' for real and imag....
3 views
24 Jan 2026
Read n integers, sum the values at odd positions (1st, 3rd, 5th...) and output the sum....
2 views
24 Jan 2026
Read n email strings. Create Email class that normalizes (lowercase, trim spaces). Output count of unique normalized emails....
2 views
24 Jan 2026
Read weight w (kg) and distance d (km). Charge rules: if w100 add extra 100. Output final charge....
2 views
24 Jan 2026
Read n and q queries. Make DSU class with find and union. Queries: UNION u v, ASK u v. For ASK output YES if connected else NO....
2 views
24 Jan 2026
A string s is provided (may contain spaces). Count how many characters are digits, how many are English letters, and how many are others. Output three counts....
3 views
24 Jan 2026
Read q operations: ADD word or COUNT prefix. Create Trie class. For COUNT output how many added words have this prefix....
3 views
24 Jan 2026
You are at step 0 and want to reach step n. Each move you can go +1 or +2. Output number of ways modulo 1000000007....
3 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)....
2 views
24 Jan 2026
Words are provided one by one. Output all words until you see the word stop (case sensitive). Do not output stop itself....
3 views
24 Jan 2026
Read n numbers and q queries. Build SegmentTree class with update(i,x) and query(l,r) returning minimum. Output query answers....
4 views
24 Jan 2026
Read n, find how many trailing zeros are in n factorial. Use loop dividing by 5....
2 views
24 Jan 2026
Input is a single token. If it can be converted to integer, output it. Otherwise output 0....
3 views
24 Jan 2026
Read n integers in a circle. In one move, rotate left by 1 (first element goes to end). Compute minimum moves to make array non-decreasing. If not possible, output -1....
3 views
24 Jan 2026
Read two tokens. If both are integers, output their sum. If any is missing or not an integer, output ERROR....
2 views
24 Jan 2026
You have a grid of size r x c. Start at (sr, sc). You get a command string of U, D, L, R. If a move goes outside grid, ignore it and count it as blocked. Output final position and blocked count....
2 views
24 Jan 2026
Read two integers a and b. Output a//b. If b is 0 output DIVIDE BY ZERO. If input is not valid, output ERROR....
3 views
24 Jan 2026
Read a string of only '(' and ')', check if it is balanced. Output YES or NO. Stop early if you ever go negative balance....
2 views
24 Jan 2026
Read two integers a and b. Output a%b. If b is 0 output DIVIDE BY ZERO. If input is invalid, output ERROR....
2 views
24 Jan 2026
Read n integers (can be positive, zero) and target S. Compute the minimum length of a contiguous subarray with sum >= S. If not found, output 0....
3 views
24 Jan 2026
Read n integers and an index i (0-based). Output a[i]. If i is outside range or input is invalid, output OUT OF RANGE....
2 views
24 Jan 2026
You start with L lives. You get q events: HIT x (lose x) or HEAL x (gain x). The moment lives becomes ...
2 views
24 Jan 2026
Time string is provided in HH:MM. Output minutes since 00:00. If format is wrong or values are out of range, output INVALID....
4 views
24 Jan 2026
Read n integers, find the earliest index i (1-based) where the prefix sum value has appeared before. If never repeats, output -1....
2 views
24 Jan 2026
String s and position p are provided (0-based). Output character at that position. If p is not integer or out of range, output INVALID....
2 views
24 Jan 2026
Read n integers and target K, find the first pair in reading order that sums to K. Output their 1-based indices i j (i...
4 views
24 Jan 2026
Input is a single token. If it is a non-negative integer and perfect square output YES else NO. If input is invalid output NO....
3 views
24 Jan 2026
Read a string s (no spaces), compress it as char + count for each consecutive run. Example aaabb becomes a3b2. Output compressed string....
4 views
24 Jan 2026
Read two integers a and b. Output a^b modulo 1000000007. If b is negative or input invalid, output ERROR....
3 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....
2 views
24 Jan 2026
Input is a single token. If it is a number, output it with 2 decimals. Else output 0.00....
3 views
24 Jan 2026
You have daily gains array of n positive integers. Starting total=0, add day by day until total reaches or exceeds T. Output that day number (1-based). If never reaches, output -1....
2 views
24 Jan 2026
Expression is provided as: a op b (space-separated). op can be + - * / %. Division is integer division. If op is invalid or division by zero happens, output ERROR....
6 views
24 Jan 2026
Read one token. Decide its data type using simple rules: True/False is BOOL, signed digits is INT, number with dot is FLOAT, otherwise STRING. Output the type name....
3 views
24 Jan 2026
Read n tokens (may contain junk). Count how many tokens are valid integers and output the count....
3 views
24 Jan 2026
A number is provided as a string x and an integer y is provided. Convert x to int and output x+y....
2 views
24 Jan 2026
Read n tokens. Add only those tokens that are valid integers. Output the sum (0 if none valid)....
2 views
24 Jan 2026
A decimal number x is provided. Round it to nearest integer (0.5 goes away from zero) and output the integer....
4 views
24 Jan 2026
Read n tokens. Multiply only valid integers and take modulo 1000000007. If no valid integers, output 0....
2 views
24 Jan 2026
One character ch is provided. Output its ASCII/Unicode code using ord()....
2 views
24 Jan 2026
Read a string num and base b (2 to 36). Convert num to decimal and output it. If conversion fails, output INVALID....
2 views
24 Jan 2026
Input has one integer code is provided (0 to 127). Output the character using chr()....
4 views
24 Jan 2026
Read a string, check if it is a valid IPv4 like A. B.C.D where each part is 0 to 255 and no empty parts. Output YES or NO....
2 views
24 Jan 2026
Word w and integer n are provided. Output w repeated n times, joined with '-' (dash). If n is 0 output empty....
2 views
24 Jan 2026
Read n numbers and q queries l r (0-based inclusive). For each query output sum. If query is out of range or invalid, output ERROR for that query....
2 views
24 Jan 2026
Read integer b (0 or 1), flip it (0 becomes 1 and 1 becomes 0). Output flipped value....
2 views
24 Jan 2026
Read a list of tokens ending with END. Start sum=0. Add each token as integer. If a token is not integer (and not END), output BAD and stop. If all good, output sum....
3 views
24 Jan 2026
String s is provided (no spaces). Output YES if all characters are digits, else NO....
3 views
24 Jan 2026
You will receive q commands: ADD x, SUB x, MUL x. Start value=0. If any command has invalid number or unknown op, output ERROR at line i (1-based) and stop. Else output final value....
3 views
24 Jan 2026
Three words are provided: first, middle, last. Output initials like R.K.S (with dots)....
3 views
24 Jan 2026
Read r c and then r lines of matrix. Some lines may have less than c numbers. Treat missing cells as 0. Output sum of each column....
3 views
24 Jan 2026
Input has two integers a and b are provided (b is not 0). Output a/b with exactly 4 digits after decimal....
2 views
24 Jan 2026
A phone number string is provided. Extract only digits and output them. If there are no digits, output INVALID....
4 views
24 Jan 2026
Read n tokens. Each token can be: signed int, float (with dot), True/False, NONE, or a word. Count how many INT, FLOAT, BOOL, NONE, and WORD tokens and output counts in this order....
2 views
24 Jan 2026
Read n tokens. Consider only valid integers, compute average and output floor value. If no valid integer, output 0....
5 views
24 Jan 2026
Read n values, each value is either integer or float (contains dot). Sum them and output result with exactly 3 decimals....
3 views
24 Jan 2026
Read n lines with format key=value. Some lines may not have '=' or may be empty, ignore them. Then q queries keys. For each query output value or NOT FOUND....
2 views
24 Jan 2026
Input has one integer n is provided (can be very large). Output how many bits are needed to represent |n| in binary. For n=0 output 1....
4 views
24 Jan 2026
Date string is provided as dd-mm-yyyy. Output VALID if it is a real date (with leap year rules) else INVALID....
4 views
24 Jan 2026
Read two floats a and b. If |a-b| < 1e-9 output EQUAL. Else output GREATER if a>b else SMALLER....
3 views
24 Jan 2026
Read string like a2b3c1 meaning aa bbb c. Output decoded string. If format is invalid (missing count or non-digit count), output ERROR....
3 views
24 Jan 2026
Hex string h is provided (without 0x). Convert it to decimal integer and output it....
3 views
24 Jan 2026
Expression contains integers, + - * / and parentheses. Division is integer division. If expression is invalid or division by zero occurs, output ERROR, else output result....
3 views
24 Jan 2026
Read one integer n. Output its lowercase hexadecimal representation without 0x....
2 views
24 Jan 2026
You will receive q commands: BEGIN, COMMIT, ROLLBACK, SET k v, GET k. Implement nested transactions. GET prints value or NOT FOUND. If COMMIT/ROLLBACK is invalid, output ERROR and stop....
3 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)....
2 views
24 Jan 2026
Read n lines, each should be 'name amount'. amount must be integer. Sum valid amounts and count bad lines. Output total and badCount....
3 views
24 Jan 2026
Read a b c d, treat them as complex numbers (a+bi) and (c+di). Multiply them and output real and imag parts....
3 views
24 Jan 2026
Read n m and then m edges. Some edge lines may be broken or have nodes out of range. Ignore invalid edges. Output number of connected components in resulting graph....
2 views
24 Jan 2026
A line string s is provided (can contain spaces). Convert it to UTF-8 bytes. Output two integers: byteLength and checksum (sum of bytes modulo 256)....
3 views
24 Jan 2026
Read expression like 'a0 a1 a2... an | x'. Left side are ints separated by spaces. If any coefficient is invalid, output ERROR. Else evaluate polynomial at x using Horner and output....
3 views
24 Jan 2026
Read n tokens. If token is a valid signed integer, add it to sum. Otherwise ignore it. Output the sum....
2 views
24 Jan 2026
First line q. Next q lines have a b. For each line output a//b. If b is 0 or parsing fails, output ERROR for that line....
4 views
24 Jan 2026
Amount is provided as string like 12, 12.3, 12.345. Output it in money format with 2 decimals using normal rounding (half up)....
2 views
24 Jan 2026
Read a string containing brackets only: ()[]{}. If any other char is present, output ERROR. Else if brackets are balanced output YES else NO....
3 views
24 Jan 2026
A string s is provided. If it starts and ends with double quote, remove those two quotes. Otherwise output as it is....
2 views
24 Jan 2026
Read n coordinate pairs. Each line should contain x y integers. If a line is invalid, treat it as 0 0. Output total distance travelled from (0,0) visiting points in order (Manhattan)....
2 views
24 Jan 2026
Input is a single token t is provided. If t is True output 1, if False output 0, if NONE output NULL. Otherwise output t unchanged....
2 views
24 Jan 2026
Read n tokens and integer k. Consider only tokens that are valid integers. If there are less than k valid integers, output ERROR. Else output sum of k largest valid integers....
3 views
24 Jan 2026
A number is provided as a string, it may be in scientific notation like 1e3 or 2.50E-1. Output it as normal decimal without exponent and remove extra trailing zeros....
3 views
24 Jan 2026
You will receive q commands: PUSHFRONT x, PUSHBACK x, POPFRONT, POPBACK. Start empty. On POP when empty, output ERROR and stop. Else after all commands output final deque as space-separated or EMPTY....
5 views
24 Jan 2026
Read n tokens, find the first adjacent pair (i,i+1) which have different inferred type using rules: BOOL, INT, FLOAT, WORD. Output i (1-based) or -1 if all adjacent types are same....
5 views
24 Jan 2026
Read n and a text line a, output the same line a exactly n times (each on new line)....
2 views
24 Jan 2026
A number is provided as string. It may have + sign, leading zeros, and decimal part. Normalize it: remove +, remove extra leading zeros, remove trailing zeros in decimal, and if it becomes -0 or 0.0 t...
3 views
24 Jan 2026
Read n, output square of every number from 1 to n, one per line....
3 views
24 Jan 2026
Read n tokens. 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....
3 views
24 Jan 2026
First number t is provided. For each testcase, two integers a and b are provided. Output a+b for each testcase....
4 views
24 Jan 2026
Two fractions are provided as p/q form. Add them and output result in reduced form p/q with q positive....
3 views
24 Jan 2026
Read t lines. For each line, count how many characters are digits (0-9) and output the count....
3 views
24 Jan 2026
A quoted string is provided. It can contain escapes: \\\\n, \\\\t, \\\\\\\\, and \\\\\. Unescape it and output two integers: length and checksum (sum of char codes modulo 256)."....
4 views
24 Jan 2026
Read t integers. For each number, reverse its digits and keep the sign. Example -120 becomes -21....
3 views
24 Jan 2026
A JSON array is provided in one line, like [1,2,true,null]. Count how many numbers, strings, booleans, and null values. Output counts in order: num str bool null....
4 views
24 Jan 2026
Read t integers. Output EVEN if number is even else ODD for each testcase....
3 views
24 Jan 2026
Read n and then n integers (0..255). Put them into a bytes object and output hex string in uppercase....
4 views
24 Jan 2026
Read t lines. For each line, remove leading and trailing spaces and output the length of the remaining text....
2 views
24 Jan 2026
Read n values (each is int or float with dot). If all are integers, output PRODUCT as integer. Otherwise output SUM as float with 2 decimals....
4 views
24 Jan 2026
For each testcase you get three integers. Output the minimum among them....
2 views
24 Jan 2026
Two complex numbers are provided as a b and c d (a+bi and c+di). Output FIRST if first magnitude is bigger, SECOND if second bigger, else EQUAL....
5 views
24 Jan 2026
Read n, output a right triangle of stars. Line i has i stars (1 to n)....
2 views
24 Jan 2026
Read x and n. Repeat n times: x = round(x,2) + 0.1 (decimal rounding half up). Output final x with exactly 2 decimals....
3 views
24 Jan 2026
Read n numbers. Output prefix sum after each element (same order)....
2 views
24 Jan 2026
Read n tokens. 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...
5 views
24 Jan 2026
Read t pairs a b. For each pair output gcd(a,b)....
3 views
24 Jan 2026
Read n entries of name and phone. Then one query name is provided. Output the phone if present else output NOT FOUND....
4 views
24 Jan 2026
Read t testcases. Each testcase has n and array. Output YES if array is non-decreasing else NO....
3 views
24 Jan 2026
A line sentence is provided. Words are separated by spaces. Count how many unique words are there and output the count....
4 views
24 Jan 2026
For each testcase you get string s and integer k. Rotate string to the right by k and output the new string....
4 views
24 Jan 2026
Read n pairs key value. If a key appears many times, keep the last value. After all pairs, output value for query key, or NA if key never appeared....
5 views
24 Jan 2026
For each testcase you get a full line sentence. Count unique words ignoring case and output the count....
3 views
24 Jan 2026
Read n pairs key and integer value. Add all values and output total sum. Keys may repeat, still add every time....
4 views
24 Jan 2026
For each testcase you get string s. Output index (0-based) of first character that appears exactly once. If none, output -1....
2 views
24 Jan 2026
Read n keys (one per line). Then query key is provided. Output YES if query exists else NO....
4 views
24 Jan 2026
For each testcase you get n, k and n numbers. Output max of each window of size k (space-separated)....
3 views
24 Jan 2026
A string of digits is provided. Count frequency of each digit 0 to 9 and output 10 integers in one line....
4 views
24 Jan 2026
For each testcase you get n numbers. Compute length of the longest prefix that is strictly increasing....
2 views
24 Jan 2026
Read n words. Count how many words start with each first letter. Output results sorted by letter as: letter count each on new line....
4 views
24 Jan 2026
Each testcase has n numbers and q queries (l r, 1-based). Output sum for each query....
3 views
24 Jan 2026
Read n pairs in list A and m pairs in list B (key and score). Make final score for each key as sum of scores from both lists (missing is 0). Output keys sorted with their final score....
3 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....
3 views
24 Jan 2026
Read n pairs key value (integer). Compute the key with maximum value. If tie, pick lexicographically smallest key. Output the key....
6 views
24 Jan 2026
For each testcase you get n and array of size n with numbers 1..n, but one number is missing and one is repeated. Output missing and duplicate....
2 views
24 Jan 2026
Read n words (one per line). Output each distinct word with its count, sorted by word....
4 views
24 Jan 2026
For each testcase you get string s. Repeatedly remove adjacent equal characters using a stack idea. Output final string (or EMPTY)....
3 views
24 Jan 2026
Read n words and integer k. Output top k words by frequency (desc), tie by word (asc)....
4 views
24 Jan 2026
For each testcase you get n, target and n integers. Output first pair indices i j (0-based) such that a[i]+a[j]=target. If not found output -1 -1....
2 views
24 Jan 2026
You have a dictionary of balances. Commands: ADD name x, SUB name x, GET name. Missing name starts at 0. For GET, output current balance....
3 views
24 Jan 2026
For each testcase you get n, m and n integers. Count how many numbers give remainder 0..m-1 when divided by m. Output counts in one line....
2 views
24 Jan 2026
Read n words in order. Output the first word that appears exactly once. If none, output NONE....
5 views
24 Jan 2026
For each testcase you get two sorted arrays. Output unique common elements in increasing order (space-separated) or EMPTY....
3 views
24 Jan 2026
Read n keys with integer values. Count how many unordered pairs of keys have same value. Output the number....
3 views
24 Jan 2026
For each testcase you get n, k and n integers. Output the k-th largest element....
4 views
24 Jan 2026
Read n words. Two words are anagrams if their letters can be rearranged. Count how many distinct anagram groups are there and output it....
4 views
24 Jan 2026
For each testcase you get n and q updates. Each update adds val to all positions l..r (1-based). After all updates output final array....
2 views
24 Jan 2026
Read n integers. Store the first index (1-based) for each distinct value. Then q queries follow, each query is a value. Output its first index or -1....
4 views
24 Jan 2026
For each testcase you get n, k and n integers. Count number of subarrays whose XOR is exactly k....
3 views
24 Jan 2026
You have q commands: INC key, DEC key. Start counts at 0. If after DEC the count becomes 0, remove the key from dictionary. At end output number of keys left....
5 views
24 Jan 2026
For each testcase you get array where a[i] is max jump length from i. Compute minimum jumps to reach last index, else -1....
2 views
24 Jan 2026
Read two dictionaries A and B as lists of keys. Output how many keys are present in both....
4 views
24 Jan 2026
For each testcase you get weighted undirected graph. Output shortest distance from 1 to n. If unreachable output -1....
2 views
24 Jan 2026
One line has pairs like key:value separated by spaces. Build dictionary and output how many pairs were parsed and sum of all integer values....
3 views
24 Jan 2026
For each testcase you get n. Output Fibonacci(n) modulo 1000000007. Use fast doubling so big n is also ok....
3 views
24 Jan 2026
Read n words. For each word, count all its prefixes. Then q prefixes are provided. For each prefix output how many words start with it....
3 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....
2 views
24 Jan 2026
Read n assignments like name value (integer). Then one expression is provided as: name1 op name2 where op is + or -. Output result using stored values. Missing names are treated as 0....
4 views
24 Jan 2026
For each testcase you get string s. Output length of longest palindromic subsequence....
2 views
24 Jan 2026
Read n pairs key value. Build reverse mapping: for each value, how many keys map to it. Output values sorted with their counts....
4 views
24 Jan 2026
For each testcase you get n bar heights. Compute largest rectangle area in histogram....
2 views
24 Jan 2026
Read q operations: SET k v, RENAME old new. RENAME works only if old exists and new does not exist. At end output number of keys and then keys sorted....
3 views
24 Jan 2026
For each testcase you get a tree with n nodes. Output the diameter length (number of edges on longest path)....
3 views
24 Jan 2026
Read n integers and target K. Count number of subarrays with sum exactly K. Output the count....
5 views
24 Jan 2026
For each testcase you get a directed graph. If topological order exists, output one order. If cycle exists, output CYCLE....
3 views
24 Jan 2026
Read n integers and K. Compute length of the longest contiguous subarray that has at most K distinct numbers....
3 views
24 Jan 2026
Read string s and pattern p (both no spaces). Compute the length of smallest substring of s that contains all characters of p with at least same counts. If not possible output 0....
2 views
24 Jan 2026
You have cache capacity cap. Commands: GET key, PUT key value. For GET output value if present else -1. LRU eviction is used when capacity exceeded....
3 views
24 Jan 2026
You will receive q commands on a nested dictionary: SET path value, GET path. Path is dot separated like a.b.c. For GET output value if exists else NOT FOUND....
3 views
24 Jan 2026
You have an inventory counts dictionary. Commands: ADD item x, REMOVE item x, COUNT item. Missing item starts at 0. REMOVE cannot make count below 0 (stop at 0). For COUNT output current count....
2 views
24 Jan 2026
You will receive q operations: ADD x or FIRST. ADD adds number x to stream. FIRST should output the first number that has appeared exactly once so far, or -1 if none....
3 views
24 Jan 2026
Read n pairs key value. Then two integers L and R. Output how many keys have value in range [L,R]....
3 views
24 Jan 2026
Read n words. Build frequency of each word. Then q queries of integer f. For each query, output how many distinct words have frequency exactly f....
3 views
24 Jan 2026
Read n key-value pairs (string keys and string values). Then two keys k1 and k2 are provided. If both keys exist, swap their values. Finally output value of k1 and value of k2 (use NA if a key does no...
2 views
24 Jan 2026
Read n pairs key and integer value. If a key comes many times, keep only the maximum value for that key. After processing, output each key with its max value, sorted by key....
4 views
24 Jan 2026
Read n integers and target K. Count number of subarrays with bitwise XOR exactly K. Output the count....
3 views
24 Jan 2026
Input has two integers a and b and an operator op are provided (+, -, *, /, %). For / do integer floor division like Python //. Output the result....
2 views
24 Jan 2026
Input has two integers a and b are provided (b != 0). Output quotient (a//b) and remainder (a%b) in one line....
4 views
24 Jan 2026
Read one integer n. Output EVEN if n is even else ODD....
3 views
24 Jan 2026
Read two integers a and b. Output < if a if a>b else =....
3 views
24 Jan 2026
Read three integers x L R. Output YES if L...
4 views
24 Jan 2026
Read three integers a b c. Output the minimum using operators and comparisons....
3 views
24 Jan 2026
Read two non-negative integers a and b. Output a & b....
2 views
24 Jan 2026
Read two non-negative integers a and b. Output a | b....
2 views
24 Jan 2026
Read two non-negative integers a and b. Output a ^ b....
3 views
24 Jan 2026
Read two integers n and k. Toggle (flip) the k-th bit (0-based) of n and output the new number....
3 views
24 Jan 2026
Four integers a b c d are provided. Compute (a+b)*c - d and output it....
2 views
24 Jan 2026
Read three integers a b c. Compute a + b*c and a*b + c. Output both in one line....
2 views
24 Jan 2026
Integers a b m are provided. Output (a^b) % m. Use fast power (pow with mod)....
3 views
24 Jan 2026
Read two non-negative integers n and k. Output 1 if k-th bit (0-based) of n is set, else 0....
3 views
24 Jan 2026
One non-negative integer n is provided. Count how many 1 bits are in binary representation and output it....
7 views
24 Jan 2026
One non-negative integer n is provided (n>0). Remove the rightmost set bit once and output the new number....
4 views
24 Jan 2026
Read two integers a and b. Output YES if they have opposite signs (one negative, one positive). If any is zero, output NO....
3 views
24 Jan 2026
Read n-1 numbers from 1..n (one is missing). Compute the missing number using XOR....
2 views
24 Jan 2026
Read two non-negative integers a and b. Hamming distance is number of different bits. Output it....
3 views
24 Jan 2026
Read two integers x and k. Output x * (2^k) using shift operator....
3 views
24 Jan 2026
Input has two integers x and k are provided (k>=0). Output floor(x / (2^k)) using right shift (for non-negative x)....
3 views
24 Jan 2026
Read two integers x and r. Treat x as unsigned 32-bit. Rotate left by r and output the unsigned result....
3 views
24 Jan 2026
Read two integers a and b. Add them without using + or -. Use bit operations and output sum....
2 views
24 Jan 2026
Read one integer n. In one move you can add 1 or subtract 1. Output minimum moves needed to make n even....
2 views
24 Jan 2026
Input has two integers p and q are provided (q != 0). Reduce the fraction p/q and output as p q (reduced). Keep denominator positive....
4 views
24 Jan 2026
Read n and then k indices (0-based). Build a bitmask with those bits set and output it as integer....
3 views
24 Jan 2026
One non-negative integer n is provided (n>0). Compute the smallest integer > n that has the same number of set bits. Output it....
3 views
24 Jan 2026
Read three non-negative integers a b c. In one flip you can change one bit of a or b. Compute minimum flips needed so that (a | b) == c....
3 views
24 Jan 2026
Read n integers, total Hamming distance is sum of distances over all pairs (i...
5 views
24 Jan 2026
Read n integers, find maximum value of ai ^ aj over all pairs. Output the maximum XOR....
3 views
24 Jan 2026
Integers a and m are provided, and exponent b is provided as a very large decimal string. Output (a^b) % m....
3 views
24 Jan 2026
Read n numbers, consider all subsets. For each subset take XOR of its elements. Output the sum of XOR over all subsets....
3 views
24 Jan 2026
Read array of n integers and q queries (l r). For each query output XOR of a[l..r] (1-based)....
3 views
24 Jan 2026
Read n integers and q queries (l r). For each query output bitwise AND of a[l..r] (1-based)....
3 views
24 Jan 2026
A boolean string s of 0/1 and a boolean string t of 0/1 are provided, same length. Treat them as bits and compute (s XOR t) as a new string. Output it....
4 views
24 Jan 2026
Input is a single string s is provided (can contain spaces). Output its length, first character and last character. If string is empty, output 0 - -....
3 views
24 Jan 2026
Input is a single string s is provided (no trailing spaces needed). Output the reversed string....
2 views
24 Jan 2026
A string s is provided. Count how many vowels (a,e,i,o,u) are present (both cases). Output the count....
3 views
24 Jan 2026
A string s is provided. Convert lowercase to uppercase and uppercase to lowercase. Other characters keep same. Output final string....
3 views
24 Jan 2026
A string s is provided. Remove all space characters and output the new string....
3 views
24 Jan 2026
A string s (only letters and digits) is provided. Output YES if it is palindrome else NO....
3 views
24 Jan 2026
A string s is provided and a character ch is provided. Count how many times ch occurs in s....
2 views
24 Jan 2026
A string s is provided, and two characters a and b. Replace every a with b and output result....
2 views
24 Jan 2026
A sentence line is provided with words separated by spaces. Join words using '-' and output....
2 views
24 Jan 2026
Read two strings s and p. Output YES if s starts with p else NO....
3 views
24 Jan 2026
A string s is provided. Compress it using run-length encoding as: char followed by count (only when count>1). Output encoded string....
2 views
24 Jan 2026
An encoded string is provided like a3b2c (letters with optional number). Decode and output the original string....
2 views
24 Jan 2026
A sentence is provided. Words are separated by spaces. Output the longest word. If tie, output the first one....
3 views
24 Jan 2026
A string s is provided (no spaces). Remove consecutive duplicate characters and output result....
3 views
24 Jan 2026
A string s is provided (no spaces). Output the first character that appears exactly once. If none, output -1....
4 views
24 Jan 2026
Input has two strings a and b are provided (lowercase letters). Output YES if they are anagrams else NO....
3 views
24 Jan 2026
A string s and integer k are provided. Rotate string to the right by k positions and output....
4 views
24 Jan 2026
A string s is provided containing only '(' and ')'. Output YES if it is balanced else NO....
2 views
24 Jan 2026
Read two strings s and p. Output all starting indices (0-based) where p occurs in s. If none, output -1....
2 views
24 Jan 2026
A string s is provided (maybe with leading spaces and sign). Parse first integer like simple atoi. If no number, output 0....
2 views
24 Jan 2026
Read n strings. Output their longest common prefix. If no common prefix, output EMPTY....
2 views
24 Jan 2026
A string s is provided. Remove all digits (0-9) and output remaining string....
3 views
24 Jan 2026
A string s is provided and integer k. Output the lexicographically smallest substring of length k. If k>len(s), output EMPTY....
2 views
24 Jan 2026
A sentence is provided. Reverse order of words and output. Extra spaces should be treated as separators....
3 views
24 Jan 2026
Read two strings text and pattern. Count how many times pattern occurs in text (overlapping allowed). Output the count....
2 views
24 Jan 2026
A string s is provided (no spaces). Compute length of longest palindromic substring. Use linear-time method....
4 views
24 Jan 2026
A string is provided in form like 3[a2[c]] where number means repeat. Decode and output the final string....
2 views
24 Jan 2026
Read two strings s and p. Remove every occurrence of p from s while scanning left to right (like stack remove). Output final string....
3 views
24 Jan 2026
A string s is provided. Consider all rotations of s. Output the lexicographically smallest rotation....
2 views
24 Jan 2026
Read string s and pattern p with '?' (any char) and '*' (any sequence). Output YES if pattern matches whole string else NO....
3 views
24 Jan 2026
A string s is provided (no spaces). Compute minimum insertions needed to make it a palindrome. Output the number....
3 views
24 Jan 2026
A string s and integer k are provided. Pick a subsequence of length k (keep order) with smallest lexicographic value. Output that subsequence....
3 views
24 Jan 2026
Two non-negative integers a and b are provided as strings (very large). Output a+b....
3 views
24 Jan 2026
Input has two strings s and t are provided (same length). Two strings are isomorphic if each character in s can be mapped to exactly one character in t and vice-versa. Output YES or NO....
3 views
24 Jan 2026
Read two strings text and pattern. Count how many times pattern occurs in text (overlapping allowed). Use Z algorithm logic and output count....
2 views
24 Jan 2026
Read two integers a and b. Write a function add(a,b) and output add(a,b)....
2 views
24 Jan 2026
Read two integers a and b. Write a function mx(a,b) that returns bigger value (if equal return same). Output result....
2 views
24 Jan 2026
Read one integer n. Create function ab(n) and output absolute value....
2 views
24 Jan 2026
Radius r is provided. Make function area(r)=pi*r*r and output with 2 decimals. Use pi=3.141592653589793....
2 views
24 Jan 2026
One non-negative integer n is provided. Make function digits(n) and output digit count (for n=0 count is 1)....
2 views
24 Jan 2026
Read one integer n. Make function fact(n) and output n!...
3 views
24 Jan 2026
Read one integer n. Make function fib(n) that returns nth Fibonacci (0-index: fib(0)=0,fib(1)=1). Output fib(n)....
4 views
24 Jan 2026
Read two integers a and b. Write function gcd(a,b) using Euclid and output it (always non-negative)....
2 views
24 Jan 2026
Read one integer n. Write function is_prime(n) and output YES if prime else NO....
2 views
24 Jan 2026
One line string s is provided. Write function vowel_count(s) and output number of vowels....
2 views
24 Jan 2026
Read n and n integers. Write function sum_sq(arr) to return sum of squares and output it....
2 views
24 Jan 2026
Read n names (one per line). Make function norm(name) which trims spaces and converts to Title Case (first letter uppercase, rest lowercase per word). Output normalized names....
7 views
24 Jan 2026
Read a b and op (ADD/SUB/MUL). Create function apply(a,b,op) and output result....
2 views
24 Jan 2026
Read q queries, each query is n. Make a fib function and answer all queries fast using memoization....
3 views
24 Jan 2026
Read n integers, write function minmax(arr) returning (min,max). Output min and max....
2 views
24 Jan 2026
Read two integers a and b. Write gcd and lcm functions. Output lcm(a,b). If any is 0, lcm is 0....
3 views
24 Jan 2026
One line sentence is provided. Write function rev_words(s) that reverses word order. Output output....
4 views
24 Jan 2026
Read two strings s and p. Write function count_occ(s,p) and output number of occurrences (overlap allowed)....
2 views
24 Jan 2026
Input has one integer n is provided (non-negative). Write recursive function sumdig(n). Output result....
2 views
24 Jan 2026
Read integers a and b (b>=0), write recursive function powr(a,b) and output a^b....
2 views
24 Jan 2026
Read n integers. Write function only_even(arr) that returns list of even numbers in same order. Output them space-separated, if none output EMPTY....
2 views
24 Jan 2026
Read n integers and chunk size k. Write function chunks(arr,k) that prints each chunk sum in new line....
3 views
24 Jan 2026
Read n integers and q queries (l r, 1-based). Write function build_prefix(arr) and answer sums fast....
2 views
24 Jan 2026
Read n. Define function step(x) that returns x//2 if x even else 3*x+1. Starting from n, keep applying step until 1. Output number of steps....
2 views
24 Jan 2026
Read sorted array of n integers and target x, write function bsearch(arr,x) returning index (0-based) or -1. Output result....
2 views
24 Jan 2026
Read m n. Write function ways(m,n) that returns number of paths from (0,0) to (m-1,n-1) moving only right or down....