Skip to main content

IBM Coding Interview Questions

25 IBM coding interview problems with full optimal solutions — 12 easy, 13 medium, 0 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an IBM interviewer values, and a FAQ section.

  • #1easyfoundational

    1. Two Sum

    Two Sum is IBM's universal warm-up across SWE and intern phone screens. The interviewer is grading whether you can pivot from the obvious O(n^2) double loop to the one-pass hash-map solution and whether you can articulate the space-for-time tradeoff cleanly.

    3 free resourcesSolve →
  • #3mediumfrequently asked

    3. Longest Substring Without Repeating Characters

    Longest Substring Without Repeating Characters is IBM's sliding-window screener. The interviewer is grading whether you reach for the dynamic-window technique with a last-seen index map, whether you handle the 'jump the left pointer' optimization, and whether you ship O(n) with a single pass.

    3 free resourcesSolve →
  • #15mediumfrequently asked

    15. 3Sum

    3Sum is IBM's two-pointer-on-sorted-array screener. The interviewer is grading whether you sort first to enable the two-pointer pattern, whether you skip duplicates cleanly at all three pointer positions, and whether you arrive at O(n^2) instead of the naive O(n^3).

    3 free resourcesSolve →
  • #20easyfoundational

    20. Valid Parentheses

    Valid Parentheses is IBM's stack-pattern screener. The interviewer is grading whether you recognize the stack signature (matching pairs of arbitrary depth), whether you handle the closer-without-opener and unclosed-tail edge cases, and whether you finish in O(n) on a single pass.

    3 free resourcesSolve →
  • #21easyfoundational

    21. Merge Two Sorted Lists

    Merge Two Sorted Lists is IBM's pointer-discipline check for SWE-1 and intern phone screens. The interviewer is grading whether you reach for a sentinel/dummy node, whether you re-use existing nodes instead of allocating fresh ones, and whether your loop exit cleanly attaches the remaining tail.

    3 free resourcesSolve →
  • #49mediumfrequently asked

    49. Group Anagrams

    Group Anagrams is IBM's hash-keyed-bucketing screener. The interviewer is grading whether you pick a canonical key (sort the chars OR a frequency tuple), articulate the tradeoff between O(k log k) sort and O(k) counter, and ship the bucket map cleanly.

    3 free resourcesSolve →
  • #53mediumfrequently asked

    53. Maximum Subarray

    Maximum Subarray is IBM's Kadane's-algorithm screener. The interviewer is grading whether you can derive Kadane's by stating the 'extend-or-restart' decision rule, ship it in O(n) with O(1) space, and articulate how it generalizes to the 2D variant.

    4 free resourcesSolve →
  • #56mediumfrequently asked

    56. Merge Intervals

    Merge Intervals is IBM's sort-then-sweep screener — directly relevant to calendar scheduling and time-range queries in IBM Cloud monitoring. The interviewer is grading whether you sort by start, whether you handle the touching-but-not-overlapping edge case, and whether you ship O(n log n) cleanly.

    3 free resourcesSolve →
  • #70easyfrequently asked

    70. Climbing Stairs

    Climbing Stairs is IBM's intro-to-DP screener — the candidate's first chance to demonstrate they recognize Fibonacci, can derive the recurrence on the whiteboard, and can collapse the memoization to two scalar variables for O(1) space.

    3 free resourcesSolve →
  • #102mediumfrequently asked

    102. Binary Tree Level Order Traversal

    Binary Tree Level Order Traversal is IBM's BFS-on-trees screener. The interviewer is grading whether you reach for an explicit queue, whether you use the queue-size snapshot trick to delimit levels, and whether you handle the empty-tree edge case cleanly.

    3 free resourcesSolve →
  • #121easyfoundational

    121. Best Time to Buy and Sell Stock

    Best Time to Buy and Sell Stock is IBM's array-traversal screener for SWE phone screens and the Watson/Research data-engineering track. The interviewer is grading whether you can derive the running-minimum invariant on a single pass instead of falling into the brute-force double loop.

    3 free resourcesSolve →
  • #125easyfoundational

    125. Valid Palindrome

    Valid Palindrome is IBM's go-to string-parsing screener. The bar is whether you can articulate the two-pointer in-place approach, handle non-alphanumeric characters in the spec, and avoid the O(n) extra-space trap of building a normalized copy.

    3 free resourcesSolve →
  • #136easyfrequently asked

    136. Single Number

    Single Number is IBM's XOR-trick screener. The interviewer is grading whether you reach for the bitwise XOR pattern, articulate why it works (a XOR a = 0, a XOR 0 = a, XOR is commutative), and ship it in O(n) time with O(1) space.

    3 free resourcesSolve →
  • #139mediumfrequently asked

    139. Word Break

    Word Break is IBM's DP-on-strings screener. The interviewer is grading whether you recognize the 'can-be-split' DP recurrence, whether you build the Set for O(1) word lookup, and whether you bound the inner loop by the maximum word length to avoid pathological inputs.

    3 free resourcesSolve →
  • #141easyfrequently asked

    141. Linked List Cycle

    Linked List Cycle is IBM's Floyd's-tortoise-and-hare screener. The interviewer is grading whether you reach for the two-pointer technique unprompted, articulate why the fast pointer catches the slow one inside a cycle, and ship O(1) extra space.

    4 free resourcesSolve →
  • #146mediumcompany favorite

    146. LRU Cache

    LRU Cache is IBM's data-structure-design screener — relevant to IBM Cloud / DB2 / storage teams where eviction policies matter daily. The interviewer is grading whether you reach for hash map + doubly linked list together, articulate why neither suffices alone, and ship O(1) for both get and put.

    4 free resourcesSolve →
  • #200mediumfrequently asked

    200. Number of Islands

    Number of Islands is IBM's graph-traversal screener — a 2D grid where each connected region of land cells counts as one island. The interviewer is grading whether you pick BFS or DFS deliberately, articulate the stack-depth risk on huge maps, and handle the in-place vs visited-set trade.

    3 free resourcesSolve →
  • #206easyfoundational

    206. Reverse Linked List

    Reverse Linked List is IBM's canonical pointer warm-up across SWE phone screens. The interviewer is grading whether you can walk a singly linked list with three pointers without losing the tail and whether you can articulate the recursive variant's stack cost.

    3 free resourcesSolve →
  • #207mediumfrequently asked

    207. Course Schedule

    Course Schedule is IBM's cycle-detection-in-directed-graph screener — directly relevant to dependency-graph problems in IBM Cloud orchestration and DB2 query planning. The interviewer is grading whether you reach for topological sort (Kahn's or DFS-coloring), whether you handle disconnected nodes, and whether you finish in O(V+E).

    4 free resourcesSolve →
  • #215mediumfrequently asked

    215. Kth Largest Element in an Array

    Kth Largest Element is IBM's heap/quickselect screener. The interviewer is grading whether you ship the O(n log k) min-heap solution under time pressure, whether you mention Quickselect for O(n) average, and whether you handle the duplicate-friendly definition correctly.

    4 free resourcesSolve →
  • #217easyfoundational

    217. Contains Duplicate

    Contains Duplicate is IBM's hash-set screener for SWE interns and SWE-1 phone screens. The interviewer is grading whether you reach for a Set in one pass, whether you can short-circuit early, and whether you name the sort vs hash space-time tradeoff cleanly.

    3 free resourcesSolve →
  • #238mediumfrequently asked

    238. Product of Array Except Self

    Product of Array Except Self is IBM's prefix/suffix-array screener. The interviewer is grading whether you avoid the forbidden division operator, derive the two-pass left/right product technique, and ship it in O(1) extra space using the output array as your scratch.

    3 free resourcesSolve →
  • #242easyfrequently asked

    242. Valid Anagram

    Valid Anagram is IBM's hash-map screener. The interviewer is grading whether you can pick the right counting structure (array vs Map), handle the Unicode follow-up gracefully, and stay O(n) instead of falling into the O(n log n) sort trap.

    3 free resourcesSolve →
  • #322mediumfrequently asked

    322. Coin Change

    Coin Change is IBM's unbounded-knapsack DP screener. The interviewer is grading whether you recognize the unbounded variant (each coin reusable), whether you ship the O(amount * coins) bottom-up DP, and whether you handle the impossible case (amount > 0 but no combination works) cleanly.

    3 free resourcesSolve →
  • #704easyfoundational

    704. Binary Search

    Binary Search is IBM's correctness screener — the interviewer is grading whether you can write a bug-free binary search on the whiteboard, handle the overflow-safe midpoint, and articulate the loop-invariant. Surprisingly few candidates ship this on the first attempt.

    4 free resourcesSolve →

Related interview-prep guides

Interview Platforms

HireVue Tech Interview Guide: The 2026 Playbook for Async Video Rounds

HireVue is the category-leading async video interview platform. Candidates record answers solo, on the clock, and a combined AI-plus-human review layer scores the recording days later. For 2026 tech jobseekers, the format is different enough from live interviews to need its own playbook. This guide is that playbook.

Interview Platforms

HackerRank Tech Interview Guide 2026: What It Tests, How It Tracks You, and the Modern Setup

HackerRank is still the volume leader in first-round technical screens for 2026 tech hiring. A browser-sandboxed coding environment that logs every keystroke, paste event, and tab-focus change inside its own tab. This guide covers what it tests, the boundary of what it can and cannot detect, and how a modern desktop setup pairs with a HackerRank session without leaking into the screen-share.

Interview Platforms

Codility for Tech Interviews in 2026: The Complete Guide for Candidates

Codility is the dominant algorithmic-assessment platform across European tech hiring. Heavy in the UK, Germany, Netherlands, Nordics, and Poland where the company was founded. It scores candidates on both correctness and time complexity, runs 60-to-120-minute timed tests, and ships three products: Tests, CodeCheck, and CodeLive. This guide is what 2026 candidates need to know.

IBM Coding Interview Questions — Full Solutions — InterviewChamp.AI