20 min read
Coding interviews aren’t always hard to crack; creating a plan and being familiar with the systems can easily help you crack the interview and get a job in your desired company.
Today, we’ll be taking IBM coding questions with answers , where we will break down the IBM coding assessment round for you and help you land a job.
IBM is a well-known technology company in America, which means International Business Machines Corporation, headquartered in Armonk, New York, United States.
Key takeaways
- Most reports describe two coding questions in roughly 55–60 minutes, non-adaptive, with no negative marking — but IBM publishes no universal duration, so your invitation email is the only reliable spec.
- HackerRank is the platform candidates most often name. IBM itself names none publicly.
- Scoring is proportional to test cases passed, so a working brute-force solution beats an unfinished elegant one.
- The Associate System Engineer (ASE) track is the highest-volume graduate route; CIC and data-engineer tracks differ in emphasis.
- All 20 solutions below are Python, and every one has been checked to run as printed.
IBM is one of the most innovative companies with a valuable Brand ranking. There are multiple elements that you need to tackle in order to crack the coding round of IBM. Create a proper plan where you study technical topics and focus on the test input.
The second thing you can do is keep things simple, as people don’t like complexity. It’s your job to keep the code readable, and it should be understandable for the programmers.
IBM Coding Questions For Associate System Engineer
Understand the important things first when you’re doing an interview; you need to be aware of the company and what they do. How they operate, and every other element of the company.
It’s okay to seek help, and being confident with your unfamiliarity with the topic doesn’t make you a bad candidate; ensure you’re relaxed throughout the rounds. Understand and review before you submit; it’s crucial to operate things patiently and check your code before you offer the solution.
Refactoring your code will only help you to understand what you can do better at it. Let’s understand the overall IBM coding questions process.
Candidate reports for the Associate System Engineer track commonly describe two coding questions in a window of roughly 55 to 60 minutes, non-adaptive, with no negative marking. Sources disagree on the exact timing, and IBM publishes no universal duration or question count — its own application process page says only that you will “Complete a set of multiple-choice questions or coding challenges depending on the role you applied to”, and that IBM “might ask you to complete one or two assessments, which can vary depending on your role.” Treat the figures below as a typical reported pattern rather than a guarantee, and read your invitation email — that is the only reliable specification for your own test. To solve the problems, you need to be familiar with these languages, which are C, C++, JAVA, and Python.
IBM Coding Questions Test Duration
| Questions in the coding round | Type of test | Time duration | Negative marking |
|---|---|---|---|
| 2 coding questions | Non-adaptive | ~55–60 minutes | No |
20 IBM Coding Questions with Answers (2026)
1. How to find the maximum subarray sum in an array of integers.
def max_subarray_sum(a):
max_so_far = 0
max_ending_here = 0
for i in range(len(a)):
max_ending_here = max(0, max_ending_here + a[i])
max_so_far = max(max_so_far, max_ending_here)
return max_so_farTo find the maximum subarray sum in an array of integers we have tackled two main variables which are : max_so_far and max_ending_here. Both the elements represent the maximum subarray that has been going and the sum that ends at the current index. The algorithm here stats with initializing max_so_far to 0 then iterates keeping track of max_ending_here. After the iterating process is completed it sends the value of max_so_far.
2. A simple method to sort an array of integers in ascending and descending order.
def bubble_sort(a):
for i in range(len(a) - 1):
for j in range(len(a) - i - 1):
if a[j] > a[j + 1]:
a[j], a[j + 1] = a[j + 1], a[j]The algorithm here works by consistently comparing the adjacent components which are present in the array and exchanging them to get them in the right order. The algorithm starts and iterates over it, comparing each component to its next one. If the present component is greater than its side one the algorithm exchanges them. The algorithm keeps repeating again and again until it’s sorted.
3. The easiest way to find the shortest path between two nodes in a graph
def dijkstra(graph, source):
distances = {}
for node in graph:
distances[node] = float("inf")
distances[source] = 0
queue = [source]
while queue:
current_node = queue.pop(0)
for neighbor in graph[current_node]:
new_distance = distances[current_node] + graph[current_node][neighbor]
if new_distance < distances[neighbor]:
distances[neighbor] = new_distance
queue.append(neighbor)
return distancesA priority queue is the main element in this function which helps us keep track of distances from sources to other nodes which are present in the graph. The algorithm adds a source node to the priority queue and the priority queue is distinguished by the distances of the nodes in the queue. Shortest distance of node from source node will be present at the front of the queue. The function here eliminates when the priority queue is emptying which tells us nodes present in the graph have been traveled and their distances to the source node have been calculated.
4. What is the space complexity of a binary search tree?
The space complexity of a binary search tree is O(n), where n is the number of nodes in the tree. This is because a binary search tree must store each node in the tree.
5. What’s the time complexity of inserting an element into a Doubly linked list?
class Node:
def __init__(self, data):
self.data = data
self.next = None
self.prev = None
class DoublyLinkedList:
def __init__(self):
self.head = None
self.tail = None
def insert_at_beginning(self, data):
new_node = Node(data)
new_node.next = self.head
self.head = new_node
if self.tail is None:
self.tail = new_node
else:
self.head.prev = new_node
def insert_at_end(self, data):
new_node = Node(data)
new_node.prev = self.tail
self.tail = new_node
if self.head is None:
self.head = new_node
else:
self.tail.next = new_node
def insert_at(self, index, data):
if index == 0:
self.insert_at_beginning(data)
elif index == len(self):
self.insert_at_end(data)
else:
new_node = Node(data)
current_node = self.head
for i in range(index - 1):
current_node = current_node.next
new_node.next = current_node.next
current_node.next.prev = new_node
new_node.prev = current_node
current_node.next = new_nodeFor this algorithm, we have inserted a new node at the start of the doubly linked list and at the end we’ve done the same. To get the index we insert a new node for the specified index. For the time complexity at the beginning and end we’ve inserted O(1) and at index O(n) where n is signified as the index.
6. There’s a binary tree, check if it is a binary search tree or not.
class TreeNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def is_bst(root):
if root is None:
return True
if root.left is not None and root.left.data > root.data:
return False
if root.right is not None and root.right.data < root.data:
return False
return is_bst(root.left) and is_bst(root.right)For the binary search tree check system, we’ve defined a function at first to check if it’s a binary search tree by recursively validating node values.
7. Given a linked list, determine if it has a cycle.
def has_cycle(head):
slow = head
fast = head
while fast is not None and fast.next is not None:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return FalseFor this code what we can do is create a function using the well-known Floyd’s Tortoise and Hare algorithm to check if a linked list has a cycle or not.
8. There’s a string, determine if it is a palindrome or not.
def is_palindrome(string):
string = string.lower()
left = 0
right = len(string) - 1
while left < right:
if string[left] != string[right]:
return False
left += 1
right -= 1
return TrueHere we have implemented a function is_palindrome to check if the string is a palindrome or not. By using left and right pointers to compare the characters from start and end to the string moving towards the center.
9. Given an array of integers, find the two numbers that add up to a given target sum.
def find_two_numbers_with_sum(array, target_sum):
seen = set()
for number in array:
complement = target_sum - number
if complement in seen:
return (complement, number)
seen.add(number)
return NoneIn this function, we’ve used find_two_numbers_with_sum element to find two numbers in an array that gives us a target addition. It uses a set to track numbers which are present while iterating from the array.
10. How to find the kth largest element in an array in linear time gives a brief explanation.
import random
def quickselect(array, k):
if len(array) == 1:
return array[0]
pivot = array[random.randint(0, len(array) - 1)]
less_than_pivot = []
greater_than_pivot = []
for element in array:
if element < pivot:
less_than_pivot.append(element)
elif element > pivot:
greater_than_pivot.append(element)
if k <= len(less_than_pivot):
return quickselect(less_than_pivot, k)
elif k > len(less_than_pivot) + 1:
return quickselect(greater_than_pivot, k - len(less_than_pivot) - 1)
else:
return pivotThe above code uses the QuickSelect algorithm which helps us to find the k-th smallest element in an unordered list. Base Case, Pivot Selection, Partitioning, and Recursion are the four main elements which we use in this function to get the desired results. One thing to flag if an interviewer probes it: this partition drops elements equal to the pivot rather than keeping them in a third bucket, so on an array containing duplicates the k-th position can shift. Being able to spot that edge case yourself is often worth more marks than the happy-path solution.
11. How do you check if a string is a palindrome or not? Write a code and explain.
def is_palindrome(string):
string = string.lower()
reversed_string = string[::-1]
return string == reversed_stringHere the algorithm is pretty easy as we’ve converted the input string to lowercase and then reverse the string and given a command to Returns True if the original string which is added is equal to its reverse, indicating a palindrome.
12. Write a function to find the factorial of a number.
def factorial(number):
if number == 0:
return 1
return number * factorial(number - 1)For the factorial function we’ve used recursion to calculate the factorial of the number. The base case here is factorial(0) returns 1 and the recursive case here multiplies the number by the factorial of – 1.
13. Write a code to find out the greatest common divisor (GCD) of two numbers.
def gcd(a, b):
while b != 0:
a, b = b, a % b
return aTo get the Greatest Common Divisor we’ve used the Euclidean Algorithm mixed with a while loop. The algorithm then Swaps and calculates the remainder until the number at the second position becomes zero. Then it returns the answer
14. How you reverse a linked list ?
def reverse_linked_list(head):
if head is None or head.next is None:
return head
new_head = None
while head is not None:
next = head.next
head.next = new_head
new_head = head
head = next
return new_headFor the reverse linked list we Iteratively reverse a linked list by adjusting its given pointers. We Use three pointers head, new_head, and next in the program to reverse the links.
15. Write a function to clone a linked list ?
def clone_linked_list(head):
if head is None:
return None
new_head = Node(head.data)
current = head
new_current = new_head
while current.next is not None:
new_node = Node(current.next.data)
new_current.next = new_node
new_current = new_node
current = current.next
return new_headFor a Clone Linked List we Create a new linked list with mixing nodes which have the same data as the original linked list present. Then it Iterates through the original list, making new nodes for each.
Also Read :
16. Write a function to find the lowest common ancestor of two nodes in a binary tree.
def lowest_common_ancestor(root, p, q):
if root is None or root == p or root == q:
return root
left = lowest_common_ancestor(root.left, p, q)
right = lowest_common_ancestor(root.right, p, q)
if left and right:
return root
return left or rightFor this code to get the Lowest Common Ancestor in a Binary Tree we Recursively find the lowest common ancestor of two nodes in a binary tree. Then it returns the root when it comes forward to a node and mixes the results from left and right subtrees.
17. Write a code and explain the easiest way to check if a binary tree is balanced or not.
def is_balanced(root):
if root is None:
return True
left_height = height(root.left)
right_height = height(root.right)
return (
abs(left_height - right_height) <= 1
and is_balanced(root.left)
and is_balanced(root.right)
)For the Balanced Binary Tree Check algorithm we first Recursively checks if a binary tree is balanced or not. Then we compare the heights of the left and right subtrees and make sure that their difference is at most 1.
18. Write a function to find the k largest elements in an array of integers.
import heapq
def find_k_largest_elements(arr, k):
heap = []
for num in arr:
heapq.heappush(heap, num)
if len(heap) > k:
heapq.heappop(heap)
return sorted(heap, reverse=True)
# Test the function with an example
arr = [3, 5, 2, 4, 1]
k = 3
print(find_k_largest_elements(arr, k)) # Output: [5, 4, 3]For the largest element in the array a function header is given and it would involve sorting the array and returning the elements.
19. How you delete a node from a linked list ?
def delete_node(head, node):
"""
Deletes a node from a linked list.
Args:
head: The head of the linked list.
node: The node to delete.
Returns:
The head of the linked list after the node has been deleted.
"""
if head == node:
head = head.next
return head
previous_node = None
current_node = head
while current_node != node:
previous_node = current_node
current_node = current_node.next
if current_node is None:
return head
previous_node.next = current_node.next
return headFirst up if the node which is to be deleted is head then we update the head to the next node and return to the new head. If it’s not head we traverse the list until we find the node to delete. The next pointer will be updated of the previous node to skip the node which is to be deleted in the code.
20. Given a graph, check if it is bipartite.
def is_bipartite(graph):
colors = {}
for node in graph:
if node not in colors:
colors[node] = 0
if colors[node] == 1:
for neighbor in graph[node]:
if neighbor in colors and colors[neighbor] == 1:
return False
for neighbor in graph[node]:
if neighbor not in colors:
colors[neighbor] = 1 - colors[node]
return TrueThe color nodes of a graph with two colors is 0 and 1 and adjacent nodes have very different colors. Here we use a dictionary which is of colors to store the color of every node that is present to have different colors. By checking if the coloring is valid by ensuring no adjacent nodes have the same color in the code. Then we Return True if the graph is bipartite and False is not.
Scoring is proportional to test cases passed — so finishing something that works beats perfecting something you don’t.

IBM Coding Assessment on HackerRank: What to Expect
Most IBM coding questions reported by candidates are delivered through HackerRank, and the platform matters as much as the problems. Knowing the interface before you sit down removes a surprise you do not need.
IBM itself is deliberately non-specific. Its application process page lists a Coding Assessment alongside a Video Assessment and an English Language Assessment, describing the coding one only as “multiple-choice questions or coding challenges depending on the role you applied to”. It names no platform and no duration.
What candidate accounts consistently describe:
- A browser-based editor. You write in HackerRank’s own IDE, not your local setup. Practise without autocomplete at least once.
- Partial credit by test case. Scoring is generally proportional to the test cases you pass, so a working brute-force solution beats an unfinished optimal one.
- Proctoring varies. Some IBM assessments run with webcam proctoring enabled, others with none. Your invitation states which.
- Links expire. Reports commonly cite about a week, some less. Do not sit on the invitation.
- No published pass mark. IBM does not disclose a cut-off, so any specific number you read elsewhere is someone’s estimate.
For the platform mechanics in depth — proctoring, copy-paste tracking and what appears in the employer’s report — see our coding assessment test platform guide.
Which IBM Role Are You Actually Interviewing For?
The phrase “IBM coding questions” covers several hiring tracks, and the IBM coding questions you face are not identical across them. Check your invitation before choosing what to revise.
Associate System Engineer (ASE)
The highest-volume graduate track, and the one the 20 IBM coding questions above map to most directly. Expect core data structures and algorithms — arrays, strings, linked lists, trees, graphs and recursion — at a level that rewards clean, correct implementation over clever optimisation.
IBM CIC (Client Innovation Centre)
CIC hires through its own route, including off-campus drives, and candidates search for it separately from the main ASE track. Reported content overlaps heavily with ASE, so the practice above applies. The difference is usually the recruitment path rather than the question style.
Data Engineer and Data-focused Roles
If you applied to a data engineering role, weight your preparation towards SQL and data manipulation rather than pure algorithmic puzzles. Candidates in these tracks report query-writing and data-handling tasks that do not appear in the generalist assessment. Our data engineer interview questions guide covers that shape in detail.
Software Developer and System Engineer Titles
IBM uses several adjacent titles. Reported content is broadly the same fundamentals, but seniority changes the bar: experienced-hire tracks report harder problems and sometimes a technical discussion of your solution rather than an automated score alone.
A note on previous-year papers
Searching for IBM coding questions from previous years, often called PYQ papers, is reasonable preparation — but treat any leaked set with caution. IBM draws from a rotating pool, so the value is in recognising which topics recur, not in memorising problems you are unlikely to see again.
IBM Coding Assessment FAQs: Format, Platform and Scoring
How long is the IBM coding assessment?
Candidate reports for the Associate System Engineer track commonly describe two coding questions in a window of roughly 55 to 60 minutes. IBM does not publish a universal duration, and sources disagree on the exact figure, so treat your invitation email as the only reliable specification for your own test.
How many questions are in the IBM coding test?
Two coding questions is the most commonly reported number for the ASE track. IBM’s own careers material says it “might ask you to complete one or two assessments, which can vary depending on your role”, so the count is not fixed across every hiring track.
Does IBM use HackerRank for its coding assessment?
HackerRank is the platform most candidate accounts describe, and several queries for this test reference it directly. IBM itself names no platform publicly, so confirm against your invitation rather than assuming.
What is a good score on the IBM coding assessment?
IBM publishes no pass mark. Scoring is generally proportional to the test cases your solution passes, which means a working brute-force answer that clears most cases can score better than an elegant solution you did not finish. Any specific cut-off number you read elsewhere is an estimate, not IBM policy.
Is there negative marking in the IBM coding round?
Candidate reports consistently describe no negative marking and a non-adaptive format, so attempting every question is worthwhile. This is reported rather than officially published.
Which programming languages can I use?
Reported options include C, C++, Java and Python. The 20 solutions on this page are written in Python, but the underlying approaches transfer to any of those languages.
How do I prepare for the IBM coding test?
Work through the 20 IBM coding questions above until you can implement each one cleanly from scratch, then practise in a plain browser editor rather than your usual IDE — you will be writing in the assessment’s own editor with no autocomplete.
What are the most common IBM coding questions?
The IBM coding questions that recur most in candidate reports cover arrays and strings, linked lists, trees and binary search trees, graphs, recursion and basic dynamic programming. The 20 problems on this page cover all of those patterns.
Are IBM CIC coding questions different?
The IBM coding questions reported for Client Innovation Centre roles overlap heavily with the Associate System Engineer track — the same fundamentals. The difference is usually the recruitment route, including off-campus drives, rather than the question style.
Are previous-year IBM papers worth studying?
Older IBM coding questions are useful for spotting which topics recur, less useful as a prediction. IBM draws from a rotating pool, so treat old papers as pattern evidence rather than a question bank you can memorise.
IBM Coding Questions with Answers Pdf
Download for FREE
Conclusion of IBM Coding Questions With Answers
In this blog post, we explored some commonly asked IBM coding questions and provided detailed answers. Remember, the key to acing coding interviews is practice. Make sure to understand the underlying concepts behind these questions and try solving them on your own before referring to the answers. Good luck with your interview preparation, and happy coding!
Follow on Facebook for more updates
Continue reading
