Aditya Birla Group interview prep
7 practice questions on the topics candidates reported from Aditya Birla Group interviews, with answers. The questions are ours; each one links to the interview report that names its topic.
Practise them as a timed round1 role open at Aditya Birla Group
DSA 6
-
An equilibrium index is a position where the sum of the elements before it equals the sum of the elements after it. Which index, counting from 0, is the equilibrium index of [1, 3, 5, 2, 2]?
- 1
- 2
- 3
- There is none
Show the answer
B. 2
At index 2 the left sum is 1 + 3 = 4 and the right sum is 2 + 2 = 4. To find it in O(n), take the total once, then walk the array keeping the left sum: the right sum at i is total - left - a[i].
This topic is named in a candidate’s interview report: SDE interview, 2023, on Code360.
-
How do you copy a linked list whose nodes have a next pointer and a random pointer, using O(1) extra space besides the copy?
- Insert each copy right after its original, set copy.random = original.random.next, then separate the two lists
- Store a map from each original node to its copy
- Copy the next pointers, then leave the random pointers pointing at the original list
- Sort the nodes by address first
Show the answer
A. Insert each copy right after its original, set copy.random = original.random.next, then separate the two lists
Interleaving puts each copy one step after its original, so the copy of any node X is X.next. That turns every random pointer into a one-step lookup with no hash map. A final pass restores the original list and links the copies.
This topic is named in a candidate’s interview report: SDE on-campus interview, 2023, on Code360.
-
How do you find the first and last positions of a target in a sorted array with duplicates in O(log n)?
- Binary search once, then walk left and right from the match
- Two binary searches: one that keeps going left after a match (lower bound) and one that keeps going right (upper bound)
- Scan the array from both ends
- Hash every value to its positions
Show the answer
B. Two binary searches: one that keeps going left after a match (lower bound) and one that keeps going right (upper bound)
Walking outwards from one match is O(n) when the target fills the array. Lower bound finds the first index with a value >= target and upper bound the first > target; the last position is one before that.
This topic is named in a candidate’s interview report: SDE interview, 2023, on Code360.
-
In [1, 4, 20, 3, 10, 5], which contiguous subarray sums to 33?
- [4, 20, 3]
- [20, 3, 10]
- [3, 10, 5]
- None
Show the answer
B. [20, 3, 10]
With no negative numbers a sliding window works: grow the right end, and shrink from the left while the sum is over the target. With negatives allowed, use prefix sums and a hash map of earlier sums instead.
This topic is named in a candidate’s interview report: SDE interview, 2023, on Code360.
-
How does Kosaraju's algorithm count the strongly connected components of a directed graph?
- One BFS from every vertex
- A DFS records vertices by finish time; then a DFS on the reversed graph, taking vertices in decreasing finish time, finds one component per new start
- It sorts the edges by weight
- It removes every cycle first
Show the answer
B. A DFS records vertices by finish time; then a DFS on the reversed graph, taking vertices in decreasing finish time, finds one component per new start
Reversing the edges keeps each component intact but cuts the paths between components, and the finish order makes each second-pass DFS start in a component no other unvisited component can reach. Two DFS passes: O(V + E).
This topic is named in a candidate’s interview report: SDE off-campus interview, 2023, on Code360.
-
Put a + or - before each number of [1, 1, 1, 1, 1]. How many sign choices make the total 3?
- 4
- 5
- 10
- 1
Show the answer
B. 5
The total is 3 when exactly one number is negative (4 - 1 = 3), and that one can be any of the five. In general, if P is the set given +, then sum(P) = (target + total) / 2, so it becomes counting subsets with that sum, a 0/1 knapsack DP.
This topic is named in a candidate’s interview report: SDE on-campus interview, 2023, on Code360.
Python 1
-
What does this print?
def squash(s): if len(s) < 2: return s if s[0] == s[1]: return squash(s[1:]) return s[0] + squash(s[1:]) print(squash("aazbbby"))- azby
- azbby
- aazby
- zy
Show the answer
A. azby
When the first two characters match, the first is dropped and the rest is processed; otherwise the first is kept. Runs collapse to one character, so aa, z, bbb, y become a, z, b, y. Slicing makes this O(n^2); an index-based loop is O(n).
This topic is named in a candidate’s interview report: SDE interview, 2023, on Code360.