# L&T Technology Services DSA Questions with Answers

6 previously-asked dsa questions from L&T Technology Services's hiring process, each with the correct answer and a worked explanation. Written against the company's actual test pattern.

_Source: Astra (https://useastra.in). Updated 2026-09-05._

### 1. Find the GCD and LCM of two numbers.

**Answer:** Compute the GCD with the Euclidean algorithm: gcd(a, b) = gcd(b, a mod b) until b is 0. Then LCM = (a * b) / gcd. Divide before multiplying to avoid overflow.

**Explanation:** Euclidean GCD, then LCM from the product.

### 2. Reverse an array in place.

**Answer:** Use two indices at the start and end, swap the elements, and move them toward the centre until they meet. Time O(n), space O(1).

**Explanation:** Two-pointer in-place swap.

### 3. Check whether a number is even or odd without using the modulo operator.

**Answer:** Use the bitwise AND: if n AND 1 is 0 the number is even, otherwise it is odd, because the least significant bit determines parity. Time O(1).

**Explanation:** Least significant bit via n AND 1.

### 4. Find the maximum product of any two numbers in an array.

**Answer:** Track the two largest and the two smallest values (two negatives can multiply to a large positive). The answer is the greater of largest times second-largest and smallest times second-smallest. Time O(n).

**Explanation:** Consider the top two and bottom two values.

### 5. Implement a stack using an array.

**Answer:** Maintain an array and a top index starting at -1. push increments top and stores the value; pop returns the top element and decrements top; check for overflow and underflow. All operations are O(1).

**Explanation:** Array with a top index; push and pop in O(1).

### 6. Count how many times a given digit appears in an integer.

**Answer:** Repeatedly take n mod 10 to inspect the last digit, increment a counter when it matches the target digit, then do n = n / 10 until n is 0. Handle the sign. Time O(number of digits).

**Explanation:** Inspect each digit with modulo and divide.

More L&T Technology Services preparation, including the full recruitment process: https://useastra.in/campus/ltts
