Ola Coding Interview Questions
100 Ola coding interview problems with full optimal solutions — 32 easy, 60 medium, 8 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Ola interviewer values, and a FAQ section.
Showing 60 problems of 100
- #26mediumfoundational
26. House Robber
Maximize loot from a line of houses where you cannot rob two adjacent ones.
- #31mediumfoundational
31. Add Two Numbers
Add two numbers represented as linked lists in reverse-digit order.
- #32mediumfoundational
32. Longest Substring Without Repeating Characters
Find the length of the longest substring without repeating characters.
- #33mediumfoundational
33. Longest Palindromic Substring
Find the longest palindromic substring of a string.
- #34mediumfoundational
34. Container With Most Water
Find two lines that together with the x-axis form a container holding the most water.
- #35mediumfoundational
35. 3Sum
Find all unique triplets in an array that sum to zero.
- #36mediumfoundational
36. Letter Combinations of a Phone Number
Return all possible letter combinations that a phone number string could represent.
- #37mediumfoundational
37. Remove Nth Node From End of List
Remove the nth node from the end of a linked list in one pass.
- #38mediumfoundational
38. Generate Parentheses
Generate all combinations of n pairs of well-formed parentheses.
- #39mediumfoundational
39. Swap Nodes in Pairs
Swap every two adjacent nodes of a linked list.
- #40mediumfoundational
40. Next Permutation
Rearrange numbers into the next lexicographically greater permutation.
- #41mediumfoundational
41. Search in Rotated Sorted Array
Search for a target in a rotated sorted array in O(log n).
- #42mediumfoundational
42. Find First and Last Position of Element in Sorted Array
Find the start and end indices of a target in a sorted array in O(log n).
- #43mediumfoundational
43. Valid Sudoku
Determine if a partially-filled 9x9 Sudoku board is valid.
- #44mediumfoundational
44. Combination Sum
Find all unique combinations of candidates that sum to a target.
- #45mediumfoundational
45. Combination Sum II
Find all unique combinations summing to a target where each candidate is used at most once.
- #46mediumfoundational
46. Multiply Strings
Multiply two non-negative integers represented as strings without using BigInt.
- #47mediumfoundational
47. Permutations
Return all possible permutations of a distinct integer array.
- #48mediumfoundational
48. Rotate Image
Rotate an n x n 2D matrix by 90 degrees clockwise in-place.
- #49mediumfoundational
49. Group Anagrams
Group strings that are anagrams of each other.
- #50mediumfoundational
50. Spiral Matrix
Return all elements of a 2D matrix in spiral order.
- #51mediumfoundational
51. Jump Game
Determine if you can reach the last index of an array given max jump lengths at each index.
- #52mediumfoundational
52. Merge Intervals
Merge a collection of overlapping intervals.
- #53mediumfoundational
53. Unique Paths
Count distinct paths from the top-left to the bottom-right of an m x n grid moving only right or down.
- #54mediumfoundational
54. Minimum Path Sum
Find the minimum-cost top-left-to-bottom-right path in a grid.
- #55mediumfoundational
55. Simplify Path
Simplify a Unix-style absolute path.
- #57mediumfoundational
57. Set Matrix Zeroes
Zero out the row and column of every zero in a matrix, in-place.
- #58mediumfoundational
58. Search a 2D Matrix
Search for a target in a row-and-column-sorted matrix.
- #59mediumfoundational
59. Sort Colors
Sort an array of 0s, 1s, and 2s in-place in one pass.
- #61mediumfoundational
61. Combinations
Return all combinations of k numbers chosen from 1..n.
- #62mediumfoundational
62. Subsets
Return all subsets of a distinct integer array.
- #63mediumfoundational
63. Word Search
Determine if a word exists in a 2D board by visiting adjacent cells.
- #64mediumfoundational
64. Remove Duplicates from Sorted Array II
Allow each unique element to appear at most twice in a sorted array, in-place.
- #65mediumfoundational
65. Search in Rotated Sorted Array II
Search for a target in a rotated sorted array that may contain duplicates.
- #66mediumfoundational
66. Remove Duplicates from Sorted List II
Delete all nodes that have duplicate numbers from a sorted linked list.
- #67mediumfoundational
67. Partition List
Partition a linked list around a value, preserving relative order.
- #68mediumfoundational
68. Decode Ways
Count the number of ways to decode a digit string into letters A-Z.
- #69mediumfoundational
69. Reverse Linked List II
Reverse a linked list between positions left and right.
- #70mediumfoundational
70. Restore IP Addresses
Generate all valid IP addresses that can be formed from a string of digits.
- #71mediumfoundational
71. Unique Binary Search Trees II
Generate every structurally unique BST that stores values 1..n.
- #72mediumfoundational
72. Unique Binary Search Trees
Count the number of structurally unique BSTs that store values 1..n.
- #73mediumfoundational
73. Validate Binary Search Tree
Determine whether a binary tree is a valid binary search tree.
- #74mediumfoundational
74. Binary Tree Level Order Traversal
Return the level-order traversal of a binary tree.
- #75mediumfoundational
75. Binary Tree Zigzag Level Order Traversal
Return the zigzag level-order traversal of a binary tree.
- #76mediumfoundational
76. Construct Binary Tree from Preorder and Inorder Traversal
Rebuild a binary tree from its preorder and inorder traversals.
- #77mediumfoundational
77. Construct Binary Tree from Inorder and Postorder Traversal
Rebuild a binary tree from its inorder and postorder traversals.
- #78mediumfoundational
78. Binary Tree Level Order Traversal II
Return the bottom-up level-order traversal of a binary tree.
- #79mediumfoundational
79. Convert Sorted List to Binary Search Tree
Convert a sorted linked list into a height-balanced BST.
- #81mediumfoundational
81. Best Time to Buy and Sell Stock II
Maximize profit from many buy/sell transactions of a stock.
- #82mediumfoundational
82. Longest Consecutive Sequence
Find the length of the longest consecutive integer sequence in an unsorted array.
- #83mediumfoundational
83. Word Break
Decide if a string can be segmented into dictionary words.
- #84mediumfoundational
84. LRU Cache
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
- #85mediumfoundational
85. Maximum Product Subarray
Find the contiguous subarray with the largest product.
- #86mediumfoundational
86. Find Minimum in Rotated Sorted Array
Find the minimum element of a rotated sorted array with distinct values.
- #87mediumfoundational
87. Number of Islands
Count the number of connected '1' islands in a 2D grid.
- #88mediumfoundational
88. Course Schedule
Decide if all courses can be finished given prerequisite pairs (cycle detection).
- #89mediumfoundational
89. Implement Trie (Prefix Tree)
Implement a Trie supporting insert, search, and startsWith.
- #90mediumfoundational
90. Kth Largest Element in an Array
Find the kth largest element in an unsorted array.
- #92mediumfoundational
92. Lowest Common Ancestor of a Binary Tree
Find the lowest common ancestor of two nodes in a binary tree.
- #93mediumfoundational
93. Product of Array Except Self
Compute an array where each index is the product of all others.