Birlasoft interview prep
7 practice questions on the topics candidates reported from Birlasoft interviews, with answers. The questions are ours; each one links to the interview report that names its topic.
DSA 2
-
What is the length of the longest subarray of [15, -2, 2, -8, 1, 7, 10, 23] whose sum is 0?
- 2
- 4
- 5
- 3
Show the answer
C. 5
[-2, 2, -8, 1, 7] sums to 0. With prefix sums, two equal prefix sums mean the elements between them add to 0, so store the first index of each prefix sum in a hash map and the answer is the widest gap: O(n).
This topic is named in a candidate’s interview report: Graduate trainee on-campus interview, 2019, on Code360.
-
In how many ways can "rabbit" be read as a subsequence of "rabbbit" (deleting characters, keeping order)?
- 1
- 6
- 2
- 3
Show the answer
D. 3
"rabbbit" has three b's and "rabbit" needs two of them, in order: choose 2 of 3, which is 3. The general DP: ways[i][j] = ways[i-1][j] plus ways[i-1][j-1] when s[i] equals t[j], in O(n * m).
This topic is named in a candidate’s interview report: Graduate trainee on-campus interview, 2019, on Code360.
Python 3
-
What does this print?
s = "Birlasoft Engineering" print("".join(c for c in s if c.lower() not in "aeiou"))- Brlsft ngnrng
- Brlsft Engnrng
- BRLSFT NGNRNG
- Birlasoft Engineering
Show the answer
A. Brlsft ngnrng
Lower-casing each character before the check also removes the capital E. Spaces are not vowels, so the space stays. Building the result with join is O(n); adding to a string in a loop can be O(n^2) in some languages.
This topic is named in a candidate’s interview report: Trainee engineer on-campus interview, 2023, on GeeksforGeeks.
-
What does this print?
a = [4, 1, 4, 3, 1, 9] print(sorted(set(a)))- [4, 1, 3, 9]
- [1, 3, 4, 9]
- [1, 1, 3, 4, 4, 9]
- {1, 3, 4, 9}
Show the answer
B. [1, 3, 4, 9]
set drops the duplicates (and has no order of its own), and sorted returns a new sorted list. O(n log n) overall. To keep the original first-seen order instead, use list(dict.fromkeys(a)).
This topic is named in a candidate’s interview report: Trainee engineer on-campus interview, 2023, on GeeksforGeeks.
-
What does this print?
def fb(n): if n % 15 == 0: return "FizzBuzz" if n % 3 == 0: return "Fizz" if n % 5 == 0: return "Buzz" return str(n) print(" ".join(fb(n) for n in [9, 10, 15, 7]))- Fizz Buzz Fizz 7
- 9 10 15 7
- Fizz Buzz Buzz 7
- Fizz Buzz FizzBuzz 7
Show the answer
D. Fizz Buzz FizzBuzz 7
15 is divisible by both 3 and 5, so the combined check has to come first: put n % 3 first and 15 would print Fizz. 9 is Fizz, 10 is Buzz and 7 is neither.
This topic is named in a candidate’s interview report: Intern interview, 2023, on Code360.
DBMS and SQL 2
-
Why is a DBMS preferred over keeping data in plain files?
- It gives concurrent access with transactions, constraints that keep data consistent, indexes and a query language, and recovery after a crash
- Files cannot hold text
- A DBMS always uses less disk space
- Files cannot be backed up
Show the answer
A. It gives concurrent access with transactions, constraints that keep data consistent, indexes and a query language, and recovery after a crash
With plain files every program has to handle locking, duplicates, partial writes and searching by itself. A DBMS does that once: ACID transactions, keys and constraints, indexed queries in SQL, and logs to recover.
This topic is named in a candidate’s interview report: Graduate trainee on-campus interview, 2019, on Code360.
-
emp has (1, Asha, 10), (2, Ravi, 20), (3, Meena, NULL) as (id, name, dept_id). dept has (10, Sales) and (30, HR). How many rows does this return?
SELECT e.name, d.name FROM emp e INNER JOIN dept d ON e.dept_id = d.id;- 3
- 1
- 2
- 0
Show the answer
B. 1
An inner join keeps only pairs that match on both sides. Only Asha (dept 10) has a matching dept row; Ravi's 20 matches nothing, Meena's NULL never equals anything, and HR has no employee. A LEFT JOIN would return all three employees.
This topic is named in a candidate’s interview report: Trainee engineer on-campus interview, 2023, on GeeksforGeeks.