IBM Previous Year Coding Questions & Solutions for Freshers 2025
IBM’s coding assessment is a crucial step in its hiring process, aimed at evaluating candidates' technical skills, problem-solving abilities, and algorithmic thinking. For freshers aspiring to secure a role at IBM, reviewing the previous year's coding questions can be a game-changer.
It not only familiarises you with the exam pattern but also boosts your confidence. This article serves as a complete guide to help you excel in the IBM coding test.
Key Features of IBM Coding Assessments
Category |
Details |
Exam Mode |
Online proctored or in-person (as per hiring needs). |
Sections |
Logical Reasoning, MCQs on Programming, Hands-on Coding. |
Coding Platforms |
The in-built platform provided by IBM during the test. |
Languages Supported |
|
Time Allotted |
Approximately 60-120 minutes. |
Assessment Scope |
Testing analytical and logical reasoning, algorithm efficiency, and syntax. |
Why Focus on Previous Year Questions?
- Understand Exam Trends
Familiarise yourself with the frequently tested concepts and their complexity. - Skill Benchmarking
Assess your problem-solving pace and accuracy against IBM standards. - Confidence Building
Reduce anxiety by practising realistic questions under timed conditions.
Commonly Asked Topics
- Array Operations
- Reversal, rotation, and sorting techniques.
- Searching and modifying elements efficiently.
- Strings
- Palindrome verification, string matching, and manipulation.
- Applications of regular expressions in coding.
- Algorithms
- Sorting (quick, merge) and searching (binary, linear).
- Algorithm optimisation and complexity analysis.
- Data Structures
- Mastery of stacks, queues, linked lists, and binary trees.
- Dynamic Programming
- Solving problems with optimal substructure properties.
Are you looking for IBM coding questions related to previous years? Click here to access coding practice sessions from moderate to challenging levels.
Top 5 Questions with Solutions for IBM Coding
Problem Statement 1
Given two strings, word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word:
Insert a character
Delete a character
Replace a character
Input Format
Two Strings will be passed in the form of alphabets as word1 and word2.
Output Format
An integer value will be returned equal to the minimum number of operations required to convert word1 to word2. Two Strings will be passed in alphabets as word1 and word2.
Constraints
0 <= word1.length, word2.length <= 500
word1 and word2 consist of lowercase English letters.
Solution C++
Solution Java
Solution Python
Problem Statement 2
Aryan and Ankit play a game with N boxes. There are an even number of boxes arranged in a row, and each box has a positive integer number of stone balls, denoted by balls(i). The objective of the game is to end with the most balls. The total number of balls across all the boxes is odd, so there are no ties.
Rules:
Aryan and Ankit take turns picking all the balls from either the beginning or the end of the row of boxes. Aryan always plays first. Both players play optimally, meaning they make decisions to maximize their number of balls.
The game ends when there are no more boxes left. Assume Aryan and Ankit play optimally. Print Aryan if Aryan wins, and print Ankit if Ankit wins.
Input Format
The first line of input contains an integer N, representing the size of the array.
The second line of input contains N space separated integers representing the number of balls in the boxes.
Output Format
Display "Aryan" if Aryan wins or Display"Ankit" if Ankit wins.
Constraints
1<=N<=10^2
Assuming Arr denotes the array and Arr(i) denotes array element at ith index of the array.
1<=Arr(i)<=10^4
Solution C++
Solution Java
Solution Python
Problem Statement 3
You are given an integer array nums of unique elements, return all possible power sets. (All subsets). The solution set must not contain duplicate subsets. Print the subsets in a specific order, starting with the largest indexed element and proceeding with combinations that include the largest indexed elements first and then the second largest indexed element, and so on.
Input Format
The first line contains an integer N.
The Next N lines contain the integer A[i], where 0 <= i < N.
Output Format
Print all possible subsets (the power set) of the given array. Each subset should be printed on a new line. Subsets should be printed in order, starting with the subsets containing the largest indexed element, followed by combinations that include the second largest indexed elements first, and so on.
Constraints
1 <= nums.length <= 10
-10 <= nums[i] <= 10
All the numbers of nums are unique.
Solution C++
Solution Java
Solution Python
Problem Statement 4
A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end.
For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2]. Given an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix.
Input Format
The first line contains two integers, M and N, representing the number of rows and columns in the matrix. The next M lines each contain N integers, representing the elements of the matrix mat. Each line corresponds to a row in the matrix.
Output Format
Print the Diagonally sorted matrix. Each row of the matrix should be printed on a new line.
Constraints
1 <= M, N <= 10^2
1 <= mat[i][j] <= 10^2
Solution C++
Solution Java
Solution Python
Problem Statement 5
Anna, a talented mathematician at the National Institute of Mathematics, was tasked with organizing a large collection of positive integers. She needed to find the smallest group of numbers (a subsequence) that, when removed from the collection, would leave her with a set of unique numbers.
The numbers in the subsequence had to be in non-decreasing order, and Anna only had a limited amount of time to complete the task. Help Anna identify and print the subsequence that, when taken from an array of length N, leaves her with a collection of distinct integers.
Since there may be multiple subsequences that can be removed to achieve this result, the subsequence that is both non-decreasing and smallest in length will be considered the optimal solution. If no such subsequence can be found, Anna must print -1.
Input Format
The first line contains an integer, N, the number of elements in the array Arr.
The next line contains N space-separated integers, denoting the array Arr.
Output Format
Print the subsequence that, when removed from the array, leaves Anna with a set of unique numbers. The resulting subsequence should be minimum in length and non-decreasing order. If such a suitable subsequence cannot be found, then print -1.
Constraints
1 <= N <= 10^5
1 <= Arr[i] <= 10^6
Solution C++
Solution Java
Solution Python
Conclusion
Cracking IBM’s coding assessment requires focused preparation and a strategic approach. By thoroughly understanding the test pattern and practicing the previous year's coding questions, you can significantly enhance your chances of success.
Stay consistent, sharpen your logic, and approach the test with confidence. Good luck!
Frequently Asked Questions (FAQs)
1. What is the structure of IBM’s coding assessment?
It comprises a mix of MCQs and 1-2 coding problems designed to evaluate programming proficiency and logical reasoning.
2. Which languages can I use for coding questions?
Commonly supported languages include Java, Python, C++, and C.
3. Are IBM’s previous year's questions repetitive?
While questions aren’t repeated verbatim, similar patterns and logic are often tested.
4. Where can I find IBM’s previous coding questions?
IBM does not officially release past questions. However, you can find curated examples on trusted online forums and platforms.
5. Can I expect dynamic programming problems in the coding test?
Yes, basic to intermediate-level dynamic programming problems are often included.
Disclaimer: While we strive for accuracy, we do not guarantee its completeness or reliability. Readers are encouraged to verify all facts and statistics from the official company website or check independently before making decisions.
Suggested reads:
- Accenture Coding Questions: 5 Coding Solutions for Freshers 2025
- HCL Coding Questions: Coding Pattern with Questions & Solutions
- TCS Ninja Coding Questions: Top 5 Coding Questions with Solution
- Deloitte Coding Questions: Top 5 Coding Questions for Freshers
- TCS Digital Coding Questions: Top 5 Coding Questions & Solutions
Login to continue reading
And access exclusive content, personalized recommendations, and career-boosting opportunities.
Comments
Add comment