# Zoho DSA Questions with Answers

6 previously-asked dsa questions from Zoho'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. Group a list of strings into sets of anagrams.

**Answer:** For each word, compute a canonical key (the sorted characters, or a character-count signature) and group words sharing the same key in a hash map. Return the grouped lists. Time O(n * k log k) for word length k.

**Explanation:** Group by sorted-character key.

### 2. Find the length of the longest substring without repeating characters.

**Answer:** Use a sliding window with a set or last-seen index map. Expand the right end; when a repeat appears, move the left end past the previous occurrence. Track the maximum window length. Time O(n).

**Explanation:** Sliding window with last-seen positions.

### 3. Implement a queue using two stacks.

**Answer:** Use an input stack for enqueue. For dequeue, if the output stack is empty, pop everything from the input stack into it (reversing order), then pop from the output stack. Amortised O(1) per operation.

**Explanation:** Two stacks; move on demand.

### 4. Find the missing and the repeating number in an array containing 1 to n.

**Answer:** Use sum and sum of squares equations, or mark visited indices by negating values, or XOR. Solve the two equations for the missing and repeating numbers. Time O(n), space O(1).

**Explanation:** Math equations or index marking.

### 5. Rotate an n by n matrix by 90 degrees clockwise in place.

**Answer:** Transpose the matrix (swap element [i][j] with [j][i]), then reverse each row. This rotates it 90 degrees clockwise in place. Time O(n^2), space O(1).

**Explanation:** Transpose then reverse each row.

### 6. Find the first non-repeating character in a stream of characters.

**Answer:** Maintain a count map and a queue of candidate characters. As each character arrives, update the count and remove from the front of the queue any character whose count exceeds 1; the front is the current answer. Amortised O(1) per character.

**Explanation:** Count map plus a queue of candidates.

More Zoho preparation, including the full recruitment process: https://useastra.in/campus/zoho
