# PwC DSA Questions with Answers

4 previously-asked dsa questions from PwC'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. Write logic to find the largest of three numbers.

**Answer:** Compare the first two to find the larger, then compare that with the third. Return the greatest. Time O(1).

**Explanation:** Pairwise comparison.

### 2. Reverse a given string.

**Answer:** Use two pointers from both ends swapping characters until they meet, or build a new string from the last character to the first. Time O(n).

**Explanation:** Two-pointer or reverse build.

### 3. Determine whether a number is even or odd.

**Answer:** Check the remainder when dividing by 2: if n mod 2 is 0 it is even, otherwise odd. The bitwise n AND 1 also works. Time O(1).

**Explanation:** Remainder or least significant bit.

### 4. Find the sum of all numbers in a list.

**Answer:** Initialise a total to 0 and add each element in one pass. Return the total. Time O(n).

**Explanation:** Accumulate in a single pass.

More PwC preparation, including the full recruitment process: https://useastra.in/campus/pwc
