Top 5 Info Edge Coding Interview Questions from 2025
Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Info Edge. If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!
Problem #1: Find the Maximum Factor Score of Array
You are given an integer array nums. The factor score of an array is defined as the product of the LCM and GCD of all elements of that array. Return the maximum factor score of nums after removing at most one element from it. Note that both the LCM and GCD of a single number are the number itself, and the factor score of an empty array is 0. Example 1: Input: nums = [2,4,8,16] Output: 64 Explanation: On removing 2, the GCD of the rest of the elements is 4 while the LCM is 16, which gives a maximum factor score of 4 * 16 = 64. Example 2: Input: nums = [1,2,3,4,5] Output: 60 Explanation: The maximum factor score of 60 can be obtained without removing any elements. Example 3: Input: nums = [3] Output: 9 Constraints: 1 <= nums.length <= 100 1 <= nums[i] <= 30
Topics: Array, Math, Number Theory
Problem #2: Count Almost Equal Pairs I
You are given an array nums consisting of positive integers. We call two integers x and y in this problem almost equal if both integers can become equal after performing the following operation at most once: Choose either x or y and swap any two digits within the chosen number. Return the number of indices i and j in nums where i < j such that nums[i] and nums[j] are almost equal. Note that it is allowed for an integer to have leading zeros after performing an operation. Example 1: Input: nums = [3,12,30,17,21] Output: 2 Explanation: The almost equal pairs of elements are: 3 and 30. By swapping 3 and 0 in 30, you get 3. 12 and 21. By swapping 1 and 2 in 12, you get 21. Example 2: Input: nums = [1,1,1,1,1] Output: 10 Explanation: Every two elements in the array are almost equal. Example 3: Input: nums = [123,231] Output: 0 Explanation: We cannot swap any two digits of 123 or 231 to reach the other. Constraints: 2 <= nums.length <= 100 1 <= nums[i] <= 106
Topics: Array, Hash Table, Sorting, Counting, Enumeration
Problem #3: Two Out of Three
Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order. Example 1: Input: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3] Output: [3,2] Explanation: The values that are present in at least two arrays are: - 3, in all three arrays. - 2, in nums1 and nums2. Example 2: Input: nums1 = [3,1], nums2 = [2,3], nums3 = [1,2] Output: [2,3,1] Explanation: The values that are present in at least two arrays are: - 2, in nums2 and nums3. - 3, in nums1 and nums2. - 1, in nums1 and nums3. Example 3: Input: nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5] Output: [] Explanation: No value is present in at least two arrays. Constraints: 1 <= nums1.length, nums2.length, nums3.length <= 100 1 <= nums1[i], nums2[j], nums3[k] <= 100
Topics: Array, Hash Table, Bit Manipulation
Problem #4: Bus Routes
You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever. You will start at the bus stop source (You are not on any bus initially), and you want to go to the bus stop target. You can travel between bus stops by buses only. Return the least number of buses you must take to travel from source to target. Return -1 if it is not possible. Example 1: Input: routes = [[1,2,7],[3,6,7]], source = 1, target = 6 Output: 2 Explanation: The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6. Example 2: Input: routes = [[7,12],[4,5,15],[6],[15,19],[9,12,13]], source = 15, target = 12 Output: -1 Constraints: 1 <= routes.length <= 500. 1 <= routes[i].length <= 105 All the values of routes[i] are unique. sum(routes[i].length) <= 105 0 <= routes[i][j] < 106 0 <= source, target < 106
Topics: Array, Hash Table, Breadth-First Search
Problem #5: Subrectangle Queries
Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods: 1. updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) Updates all values with newValue in the subrectangle whose upper left coordinate is (row1,col1) and bottom right coordinate is (row2,col2). 2. getValue(int row, int col) Returns the current value of the coordinate (row,col) from the rectangle. Example 1: Input ["SubrectangleQueries","getValue","updateSubrectangle","getValue","getValue","updateSubrectangle","getValue","getValue"] [[[[1,2,1],[4,3,4],[3,2,1],[1,1,1]]],[0,2],[0,0,3,2,5],[0,2],[3,1],[3,0,3,2,10],[3,1],[0,2]] Output [null,1,null,5,5,null,10,5] Explanation SubrectangleQueries subrectangleQueries = new SubrectangleQueries([[1,2,1],[4,3,4],[3,2,1],[1,1,1]]); // The initial rectangle (4x3) looks like: // 1 2 1 // 4 3 4 // 3 2 1 // 1 1 1 subrectangleQueries.getValue(0, 2); // return 1 subrectangleQueries.updateSubrectangle(0, 0, 3, 2, 5); // After this update the rectangle looks like: // 5 5 5 // 5 5 5 // 5 5 5 // 5 5 5 subrectangleQueries.getValue(0, 2); // return 5 subrectangleQueries.getValue(3, 1); // return 5 subrectangleQueries.updateSubrectangle(3, 0, 3, 2, 10); // After this update the rectangle looks like: // 5 5 5 // 5 5 5 // 5 5 5 // 10 10 10 subrectangleQueries.getValue(3, 1); // return 10 subrectangleQueries.getValue(0, 2); // return 5 Example 2: Input ["SubrectangleQueries","getValue","updateSubrectangle","getValue","getValue","updateSubrectangle","getValue"] [[[[1,1,1],[2,2,2],[3,3,3]]],[0,0],[0,0,2,2,100],[0,0],[2,2],[1,1,2,2,20],[2,2]] Output [null,1,null,100,100,null,20] Explanation SubrectangleQueries subrectangleQueries = new SubrectangleQueries([[1,1,1],[2,2,2],[3,3,3]]); subrectangleQueries.getValue(0, 0); // return 1 subrectangleQueries.updateSubrectangle(0, 0, 2, 2, 100); subrectangleQueries.getValue(0, 0); // return 100 subrectangleQueries.getValue(2, 2); // return 100 subrectangleQueries.updateSubrectangle(1, 1, 2, 2, 20); subrectangleQueries.getValue(2, 2); // return 20 Constraints: There will be at most 500 operations considering both methods: updateSubrectangle and getValue. 1 <= rows, cols <= 100 rows == rectangle.length cols == rectangle[i].length 0 <= row1 <= row2 < rows 0 <= col1 <= col2 < cols 1 <= newValue, rectangle[i][j] <= 10^9 0 <= row < rows 0 <= col < cols
Topics: Array, Design, Matrix