Skip to content
CodeKruPro

Stage 3 of 11

Coding problems

A curated sheet of 112 well-known problems in teaching order. Statements are the same in Java and Python; only the starter code changes.

0 / 112 solvedEasy 0/67Medium 0/38Hard 0/7Continue

Basics and maths

0/12
StatusProblemDifficultyAsked in
Not startedCount the digits of a numberEasyAsked in: JPMorgan Chase, TCS
Not startedReverse the digits of an integerEasyAsked in: Capgemini, Infosys, Wipro
Pro+Swap two numbers without a third variableEasyAsked in: Accenture, Capgemini, Infosys +1
Pro+The first n Fibonacci numbersEasyAsked in: Capgemini
Pro+Check whether a year is a leap yearEasyAsked in: Infosys
Pro+Check whether a number is an Armstrong numberEasyAsked in: Oracle, VMware
Pro+Add the digits until one digit remainsEasyAsked in: Zupee
Pro+Check whether a number is primeEasyAsked in: Accenture, Capgemini, TCS
Pro+Build a star pyramid patternEasyAsked in: Accenture, Capgemini, Cognizant
Pro+Compute an electricity bill from unit slabsEasyAsked in: Wipro
Pro+List all primes up to n (Sieve of Eratosthenes)Easy-MediumAsked in: Accenture, Capgemini, TCS
Pro+Multiply two numbers without the multiplication operatorEasy-MediumAsked in: Accenture

About basics and maths

Arrays

0/11
StatusProblemDifficultyAsked in
Not startedFind the largest and second largest valuesEasyAsked in: Capgemini, Infosys, Razorpay +2
Not startedFind the missing numberEasyAsked in: Accenture, Coupa
Pro+Move all zeros to the endEasyAsked in: Amazon, Bloomberg, LinkedIn +3
Pro+Merge two sorted listsEasy-MediumAsked in: Capgemini
Pro+Rotate a list to the right by k stepsEasy-MediumAsked in: Adobe, Amazon, Apple +3
Pro+Find the leaders in a listEasy-Medium
Pro+Best time to buy and sell a stockEasy-MediumAsked in: Adobe, Amazon, Google +3
Pro+Find the majority elementEasy-MediumAsked in: Amazon, Atlassian, D. E. Shaw +3
Pro+Sort a list of 0s, 1s and 2s in one passMediumAsked in: GreyOrange
Pro+Maximum subarray sum (Kadane)MediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Find the repeating and the missing numberMediumAsked in: Amazon, Apple, Bloomberg +3

About arrays

Strings

0/17
StatusProblemDifficultyAsked in
Not startedReverse a stringEasyAsked in: Accenture, Capgemini, Cognizant +2
Not startedCheck whether a string is a palindromeEasyAsked in: Accenture, Capgemini, Wipro
Pro+Count vowels, consonants, digits, spaces and other charactersEasyAsked in: Capgemini, TCS, Wipro
Pro+Remove special characters, keep letters and digitsEasyAsked in: Infosys
Pro+Remove extra spaces from a sentenceEasy
Pro+Pad a number with leading zerosEasyAsked in: Accenture
Pro+Remove duplicate charactersEasyAsked in: Cognizant, Infosys, Wipro
Pro+Check whether two strings are anagramsEasyAsked in: Capgemini
Pro+Longest common prefix of a list of stringsEasyAsked in: Google, Microsoft, VMware
Pro+Count each characterEasy-MediumAsked in: Capgemini, Infosys, TCS +1
Pro+Find the duplicate characters and their countsEasy-MediumAsked in: Accenture, Capgemini
Pro+Reverse the words in a sentenceEasy-MediumAsked in: Capgemini, TCS, Wipro
Pro+Reverse each word and capitalise its first letterEasy-Medium
Pro+Compress a string with run counts (aaabb to a3b2)Easy-MediumAsked in: Fivetran, TCS
Pro+Reverse a string but keep the spaces in placeMediumAsked in: Infosys, Zupee
Pro+Extract valid dates from a textMediumAsked in: Capgemini, Infosys
Pro+Add two very large numbers given as stringsMediumAsked in: PhonePe

About strings

Hashing: counting and lookups

0/13
StatusProblemDifficultyAsked in
Not startedTwo sumEasy
Not startedFirst non-repeating characterEasyAsked in: Amazon, Flipkart, Goldman Sachs +3
Pro+Count how often each value occursEasyAsked in: Capgemini, Infosys
Pro+Find the duplicate values in a listEasyAsked in: Accenture, Capgemini, Infosys +1
Pro+Remove duplicates from a list, keeping the orderEasyAsked in: Cognizant
Pro+Check whether all characters are uniqueEasyAsked in: Capgemini
Pro+Find the characters common to two stringsEasy-MediumAsked in: Capgemini, Infosys
Pro+Count how often each word occursEasy-MediumAsked in: Infosys
Pro+Remove repeated words from a sentenceEasy-MediumAsked in: Infosys
Pro+Fewest distinct values after removing k itemsMediumAsked in: Fivetran
Pro+Longest run of consecutive numbersMediumAsked in: Amazon
Pro+Group anagrams togetherMediumAsked in: Amazon, Goldman Sachs, Google +3
Pro+Count the subarrays that add up to kMediumAsked in: Adobe, Amazon, Apple +3

About hashing: counting and lookups

Sorting

0/6
StatusProblemDifficultyAsked in
Not startedSort the characters of a stringEasyAsked in: TCS
Not startedSort a list without a library sort (bubble, selection or insertion)EasyAsked in: Capgemini
Pro+Sort words by how often they occurEasy-MediumAsked in: Accenture, Wipro
Pro+Sort a large list fast (merge sort)MediumAsked in: Coupa
Pro+Merge overlapping intervalsMediumAsked in: Amazon, Google, Microsoft +2
Pro+Minimum number of railway platformsMediumAsked in: Adobe, Amazon, Atlassian +3

About sorting

Binary search

0/6
StatusProblemDifficultyAsked in
Not startedBinary searchEasyAsked in: JPMorgan Chase, Zupee
Not startedSearch insert positionEasyAsked in: Adobe, Amazon, Apple +3
Pro+Square root without a library functionEasy-MediumAsked in: Accolite, Amazon, Flipkart +2
Pro+First and last position of a value in a sorted listMediumAsked in: Amazon, Google, Microsoft
Pro+Search in a rotated sorted listMediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Smallest truck capacity to ship packages in d daysMedium-HardAsked in: Amazon, D. E. Shaw

About binary search

Two pointers and sliding window

0/7
StatusProblemDifficultyAsked in
Not startedPair with a target sum in a sorted listEasyAsked in: Adobe, Amazon, Apple +3
Not startedLargest sum of k consecutive valuesEasyAsked in: NPCI, OYO
Pro+Count pairs whose difference is at most kMediumAsked in: Amazon
Pro+Container with the most waterMediumAsked in: Amazon, Flipkart, Google
Pro+Longest substring without repeating charactersMediumAsked in: Coupa
Pro+Three numbers that add up to zero (3 sum)MediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Trapping rain waterHardAsked in: Adobe, Amazon, Flipkart +3

About two pointers and sliding window

Recursion and backtracking

0/7
StatusProblemDifficultyAsked in
Not startedFast power: x to the power n, modulo 1,000,000,007Easy-Medium
Not startedAll subsets of a listMediumAsked in: Adobe, Amazon, Apple +3
Pro+All permutations of a listMediumAsked in: Adobe, Amazon, Apple +3
Pro+Combination sum: reach a target with reusable valuesMediumAsked in: Adobe, Amazon, Microsoft +1
Pro+Generate balanced brackets up to a depth limitMedium
Pro+Word search in a letter gridMediumAsked in: Amazon, Apple, Intuit +2
Pro+Find all dictionary words in a letter gridHardAsked in: Airbnb, Amazon, Apple +3

About recursion and backtracking

Linked list

0/9
StatusProblemDifficultyAsked in
Not startedReverse a linked listEasyAsked in: AMD
Not startedMiddle node of a linked listEasyAsked in: Adobe, Amazon, Flipkart +3
Pro+Merge two sorted linked listsEasyAsked in: Amazon, Flipkart, Microsoft +3
Pro+Remove the nth node from the end of a linked listEasy-MediumAsked in: Adobe, Amazon, Apple +3
Pro+Check whether a linked list is a palindromeEasy-MediumAsked in: Accolite, Adobe, Amazon +3
Pro+Detect a loop in a chain of links and find where it startsMediumAsked in: Adobe, Amazon, Apple +3
Pro+Add two numbers stored as linked listsMediumAsked in: Adobe, Amazon, Apple +3
Pro+Insert a value into a sorted circular linked listMedium-HardAsked in: Amazon, Microsoft, Zoho
Pro+Reverse a linked list in groups of kHardAsked in: Adobe, Amazon, Goldman Sachs +3

About linked list

Stack and queue

0/6
StatusProblemDifficultyAsked in
Not startedBalanced bracketsEasy-MediumAsked in: Swiggy
Not startedBuild a queue from two stacksEasy-MediumAsked in: Adobe, Amazon, Apple +3
Pro+Min stack: a stack that knows its smallest valueMediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Next greater element for every valueMediumAsked in: Adobe, Amazon, Flipkart +2
Pro+Maximum of every window of size kHardAsked in: Adobe, Amazon, Apple +3
Pro+Largest rectangle in a histogramHardAsked in: Google, Microsoft, NPCI

About stack and queue

Trees

0/10
StatusProblemDifficultyAsked in
Not startedInorder traversal of a binary treeEasyAsked in: Deloitte
Not startedMaximum depth (height) of a binary treeEasyAsked in: Adobe, Amazon, Apple +3
Pro+Level order traversal of a binary treeEasy-MediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Check whether two binary trees are the sameEasyAsked in: Amazon, Flipkart, Microsoft
Pro+Check whether a binary tree is a mirror of itselfEasyAsked in: Adobe, Amazon, Apple +3
Pro+Diameter of a binary treeMediumAsked in: Amazon, Microsoft, NPCI +1
Pro+Insert a value into a binary search treeEasy-MediumAsked in: Deloitte
Pro+Check whether a binary tree is a valid binary search treeMediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Lowest common ancestor of two nodes in a binary treeMediumAsked in: Amazon, American Express, Flipkart +3
Pro+Maximum path sum in a binary treeHardAsked in: Flipkart, Google, Meta +1

About trees

Further problems

0/8
StatusProblemDifficultyAsked in
Not startedClimbing stairs: count the waysEasyAsked in: Adobe, Amazon, Flipkart +3
Not startedLargest total with no two neighbours (house robber)Easy-MediumAsked in: Adobe, Amazon, Flipkart +3
Pro+Fewest coins or notes to make an amountMediumAsked in: Amazon
Pro+Fewest jumps to reach the end of a listMedium-HardAsked in: Amazon
Pro+Count the islands in a gridMediumAsked in: Amazon, Apple, Google +3
Pro+Rotting oranges: minutes until every orange is rottenMedium-HardAsked in: Amazon
Pro+Build a growable list from scratchMediumAsked in: Cognizant
Pro+LRU cache: evict the least recently used entryHardAsked in: Adobe, Amazon, Flipkart +3

About further problems

Not startedNot startedIn progressIn progressSolvedSolvedPro+Pro+

The first 2 questions of each topic are free. Pro+ opens every question.