# EY DSA Questions with Answers

4 previously-asked dsa questions from EY'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. Check whether a given number is prime.

**Answer:** Numbers below 2 are not prime. Otherwise test divisors from 2 up to the square root of n; if none divides it, it is prime. Time O(square root of n).

**Explanation:** Trial division up to the square root.

### 2. Compute the factorial of a number.

**Answer:** Multiply a running result from 1 to n iteratively, or use recursion factorial(n) = n * factorial(n-1) with base case 1. Use a 64-bit type to reduce overflow. Time O(n).

**Explanation:** Iterative or recursive product.

### 3. Reverse an array in place.

**Answer:** Swap elements from both ends moving inward with two pointers until they meet. Time O(n), space O(1).

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

### 4. Find the maximum element in an array.

**Answer:** Initialise max to the first element and update it while scanning the rest. Return max. Time O(n).

**Explanation:** Single pass tracking the maximum.

More EY preparation, including the full recruitment process: https://useastra.in/campus/ey
