CodeBegun Practice

Practice Coding Problems, the Right Way

Every problem is structured the way you should actually solve one — read it, think first, take a hint only if you need it, work the approach, dry-run an example, then check a clean Java solution. Build the problem-solving habit that clears coding rounds.

  • 100 Problems
  • 5 Categories
  • Hints + Approach + Solution
  • Free

Number Problems 30

Reverse, palindrome, Armstrong, prime, factorial and the classic number logic every fresher interview starts with.

beginnerCheck Whether a Number Is a Neon NumberDetermine whether the digit sum of a number's square equals the number.beginnerCheck Whether a Number Is a PalindromeDetermine whether an integer's digits read the same forwards and backwards.beginnerCheck Whether a Number Is a Spy NumberDecide whether a number is a spy number by checking if its digit sum equals its digit product.beginnerCheck Whether a Number Is an Armstrong NumberDetermine whether a number equals the sum of its digits each raised to the number of digits.beginnerCheck Whether a Number Is Even or Odd Without the Modulus OperatorClassify a number as even or odd without using the modulus operator.beginnerCheck Whether a Number Is PrimeDetermine whether an integer greater than 1 has no divisors other than 1 and itself.beginnerConvert a Decimal Number to BinaryConvert a base-10 integer to its binary representation using arithmetic.beginnerFind All Factors of a NumberPrint every positive divisor of a number in ascending order.beginnerFind the Factorial of a Number Using a LoopCompute the factorial of a non-negative integer using an iterative loop.beginnerFind the Largest of Three NumbersReturn the largest value among three integers using comparisons.beginnerPrint the Fibonacci Series Up to N TermsPrint the first N terms of the Fibonacci sequence in order.beginnerReverse a Number Without Using StringsReverse the digits of an integer using arithmetic only — no String conversion.beginnerSwap Two Numbers Without Using a Third VariableExchange the values of two integers without introducing a temporary variable.easyCheck Whether a Number Is a Disarium NumberDecide whether a number is Disarium by summing each digit raised to its position.easyCheck Whether a Number Is a Harshad NumberDecide whether a number is a Harshad number by testing divisibility by its digit sum.easyCheck Whether a Number Is a Magic NumberDecide whether a number is magic by reducing its repeated digit sum to a single digit of 1.easyCheck Whether a Number Is a Perfect NumberDetermine whether a number equals the sum of its proper divisors.easyCheck Whether a Number Is a Perfect SquareDecide whether a number is the exact square of some integer.easyCheck Whether a Number Is a Power of TwoDecide whether a positive number is an exact power of two in constant time.easyCheck Whether a Number Is a Strong NumberDetermine whether a number equals the sum of the factorials of its digits.easyCheck Whether a Number Is an Abundant NumberDecide whether a number is abundant by comparing the sum of its proper divisors to itself.easyCheck Whether a Number Is an Automorphic NumberDecide whether a number is automorphic by testing if its square ends with the number.easyFind the Factorial of a Number Using RecursionCompute the factorial of a non-negative integer using recursion.easyFind the GCD of Two Numbers Using the Euclidean AlgorithmCompute the greatest common divisor of two integers with the Euclidean algorithm.easyFind the LCM of Two NumbersCompute the least common multiple of two integers using their GCD.easyFind the Nth Fibonacci Number Using RecursionReturn the Nth Fibonacci number using a recursive definition.easyGenerate the First N Prime NumbersPrint the first N prime numbers in ascending order.easyPrint All Armstrong Numbers Between 1 and 1000Print every Armstrong number in the range 1 to 1000 using the sum-of-cubes test.easyPrint All Perfect Numbers in a Given RangePrint every perfect number that lies within a given start-to-end range.easyPrint All Prime Numbers Between 1 and NPrint every prime number from 2 up to a given upper limit N.

Digit Problems 20

Break a number into its digits — count, sum, largest, smallest and digit-manipulation patterns.

beginnerCount the Even and Odd Digits in a NumberCount how many digits of an integer are even and how many are odd.beginnerCount the Number of Digits in a NumberCount how many digits an integer contains using arithmetic only.beginnerCount the Occurrences of a Given Digit in a NumberCount how many times a specific digit appears in an integer, using arithmetic only.beginnerFind the First Digit of a NumberFind the leading (most significant) digit of an integer using arithmetic.beginnerFind the Frequency of Each Digit in a NumberCount how many times each digit 0-9 occurs in an integer using arithmetic only.beginnerFind the Largest Digit in a NumberFind the maximum digit of an integer using arithmetic only.beginnerFind the Product of the Digits of a NumberCompute the product of all digits of an integer using arithmetic.beginnerFind the Smallest Digit in a NumberFind the minimum digit of an integer using arithmetic only.beginnerFind the Sum of the Digits of a NumberCompute the sum of all digits of an integer using arithmetic only.beginnerFind the Sum of the Even Digits in a NumberSum only the even-valued digits of an integer, using arithmetic only.beginnerFind the Sum of the First and Last Digits of a NumberAdd the first (leading) and last (trailing) digits of an integer.beginnerSwap the First and Last Digits of a NumberExchange the leading and trailing digits of an integer and return the new number.easyArrange the Digits of a Number in Descending OrderReorder the digits of an integer so they appear from largest to smallest.easyCheck Whether All Digits of a Number Are DistinctDetermine whether an integer contains any repeated digit, using arithmetic only.easyCheck Whether the Digits of a Number Are in Ascending OrderDetermine whether an integer's digits strictly increase left to right, using arithmetic only.easyFind the Difference Between the Sums of Odd and Even Positioned DigitsCompute the difference between digits at odd positions and digits at even positions, counting from the right.easyFind the Digital Root of a NumberReduce a number to a single digit by repeatedly summing its digits.easyForm the Largest Number From the Digits of a NumberBuild the largest possible integer by reordering the digits of a given number.easyRemove All Zeros From a NumberRebuild an integer after dropping every digit that equals zero, using arithmetic only.easyReplace All Occurrences of a Digit With Another DigitRebuild an integer with every occurrence of one digit replaced by another, using arithmetic only.

Logical Thinking 5

Swap, compare and reason without extra variables — the puzzles that build problem-solving instinct.

Array Problems 25

Traverse, search and transform arrays — the single most tested topic in coding rounds.

beginnerCheck Whether an Array Is a PalindromeDetermine whether an array reads the same forwards and backwards using two pointers.beginnerCount the Even and Odd Numbers in an ArrayCount how many elements of an array are even and how many are odd.beginnerFind the Average of the Elements in an ArrayCompute the arithmetic mean of an array by summing and dividing with floating-point division.beginnerFind the Largest Element in an ArrayReturn the maximum value in an integer array using a single pass.beginnerFind the Smallest Element in an ArrayReturn the minimum value in an integer array using a single pass.beginnerFind the Sum of All Elements in an ArrayCompute the total of all elements in an array using an accumulator loop.beginnerReverse an Array In PlaceReverse the elements of an array in place using two pointers and swaps.beginnerRotate an Array to the Left by One PositionRotate an integer array one position to the left in place.easyCheck Whether an Array Is SortedDetermine whether an array is sorted in non-decreasing order in a single pass.easyCount the Frequency of Each Element in an ArrayCount how many times each distinct value appears in an array using a map.easyFind a Pair With a Given Sum in an ArrayDetermine whether two elements of an array sum to a given target, and report them.easyFind the Intersection of Two Sorted ArraysReturn the values that appear in both of two ascending-sorted arrays.easyFind the Missing Number in an Array of 1 to NFind the single missing number from an array holding 1..N with one value absent.easyFind the Most Frequent Element in an ArrayReturn the element that occurs the most times in an integer array.easyFind the Second Largest Element in an ArrayReturn the second largest distinct value in an integer array using a single pass.easyFind the Second Smallest Element in an Array Without SortingFind the second smallest distinct value in an array in a single pass, without sorting.easyFind the Third Largest Element in an ArrayFind the third largest distinct value in an array in a single pass, without sorting.easyFind the Union of Two ArraysReturn the sorted set of distinct values appearing in either of two arrays.easyMerge Two Sorted Arrays Into One Sorted ArrayCombine two sorted arrays into a single sorted array.easyMove All Negative Numbers to the Beginning of an ArrayRearrange an array so all negative numbers come before all non-negative numbers.easyMove All Zeros to the End of an ArrayMove all zeros to the end of an array in place, preserving the order of non-zero values.easyRemove Duplicates From a Sorted Array In PlaceRemove duplicates from a sorted array in place and return the count of unique elements.easyRemove Duplicates From an Unsorted ArrayRemove duplicates from an unsorted array while preserving first-occurrence order.easyReverse an Array Using RecursionReverse an array using recursion by swapping the outer pair and recursing on the inner range.easySegregate 0s and 1s in an ArrayRearrange an array of 0s and 1s so all 0s come first and all 1s follow.

String Problems 20

Reverse, count, compare and clean strings — vowels, anagrams, frequency and non-repeating characters.

beginnerCapitalize the First Letter of Each Word in a SentenceUppercase the first letter of each word in a sentence, leaving other letters unchanged.beginnerCheck Whether a String Contains Only DigitsReturn true only if the string is non-empty and every character is a digit from 0 to 9.beginnerCheck Whether a String Is a PalindromeReturn whether a string reads identically forwards and backwards.beginnerConvert a String to Uppercase Without Built-in MethodsReturn the uppercase form of a string using only character arithmetic, not String.toUpperCase().beginnerCount the Number of Words in a SentenceCount how many words a sentence contains, treating runs of spaces as one separator.beginnerCount the Vowels and Consonants in a StringCount how many characters of a string are vowels and how many are consonants.beginnerRemove All Vowels From a StringBuild a new string containing every character of the input except the vowels.beginnerRemove All White Spaces From a StringBuild a new string with every whitespace character removed.beginnerReverse a String Without Using Built-in MethodsReverse a string in place on a char array without using library reverse helpers.beginnerToggle the Case of Each Character in a StringReturn a new string where every uppercase letter becomes lowercase and every lowercase letter becomes uppercase.easyCheck Whether a Sentence Is a Palindrome Ignoring Spaces and CaseReturn whether a sentence is a palindrome when spaces, punctuation and case are ignored.easyCheck Whether Two Strings Are AnagramsDetermine whether two strings are anagrams by comparing their character counts.easyCount the Frequency of Each Character in a StringCount how many times each distinct character appears in a string.easyFind the First Non-Repeating Character in a StringReturn the first character in a string that appears exactly once.easyFind the First Repeating Character in a StringReturn the first character that has already been seen while scanning a string left to right.easyPrint the Duplicate Characters in a StringPrint each character that appears more than once in a string along with its count.easyRemove All Duplicate Characters From a StringProduce a string that keeps only the first occurrence of each character.easyReverse a String Using RecursionReverse a string using a recursive function rather than a loop.easyReverse Each Word of a Sentence IndividuallyReverse the letters of each word in a sentence while keeping the word order unchanged.easyReverse the Order of Words in a SentenceReverse the order of words in a sentence while keeping each word's letters in place.

Keep Building

Chat with us