LogIn
I don't have account.

KLA Software Engineer Interview Experience (DSA Round) | Two Coding Questions | July 2026

Deepak Patel
319 Views

I recently appeared for the KLA Software Engineer interview and I wanted to share my complete interview experience. While preparing, I couldn't find many recent interview experiences that included both the coding questions and the complete approach, so I hope this blog helps anyone preparing for KLA's DSA rounds.

The interview was conducted over a video call using an online coding platform. After a brief introduction, the interviewer directly moved to coding questions. The entire discussion was very interactive. Rather than expecting me to jump straight into coding, the interviewer wanted to understand my thought process, why I selected a particular data structure and how I handled edge cases.

Overall, the interview lasted around an hour and consisted of two coding problems, both of which required identifying the correct algorithmic pattern rather than simply writing code.

Question 1: Smallest Negative Balance

Problem Statement

Every transaction was represented as a string in the following format:

borrower lender amount

Example:


alex blake 2
case blake 2
alex case 4
blake alex 5

The borrower loses the amount while the lender gains the same amount.

After processing all the transactions, we had to return:

  • The person (or people) having the smallest negative balance.
  • If multiple people had the same smallest negative balance, return them in lexicographical order.
  • If nobody had a negative balance, return "No negative balance person found."

My Thought Process

Initially, I thought about maintaining balances in an array, but since names were strings and new people could appear at any time, an array wasn't suitable.

The interviewer asked me which data structure would provide constant-time updates for each transaction. That immediately suggested using a HashMap. The idea was simple:

  • borrower → subtract amount
  • lender → add amount

Once every transaction was processed, I needed another traversal to find the minimum negative balance.

The interviewer also reminded me to think about edge cases:

  • What if everyone's balance becomes zero or positive?
  • What if multiple people have the same minimum negative balance?

After discussing these scenarios, I modified my approach accordingly.

My Approach

  1. Create a HashMap to store each person's balance.
  2. Process every transaction.
  3. Find the minimum balance that is strictly less than zero.
  4. If no negative balance exists, return the required message.
  5. Otherwise collect every person having that balance.
  6. Sort names alphabetically.

Dry Run

Input


alex blake 2
case blake 2
alex case 4
blake alex 5

Balances become

Person Balance
Alex -1
Blake -1
Case +2

Minimum negative balance = -1

Answer

[alex, blake]
class Result {

    public static List<String> findPeople(String[] transactions) {

        Map<String, Integer> balance = new HashMap<>();

        for (String transaction : transactions) {
            String[] parts = transaction.split("\\s+");
            String borrower = parts[0];
            String lender = parts[1];
            int amount = Integer.parseInt(parts[2]);

            balance.put(
                borrower,
                balance.getOrDefault(borrower, 0) - amount
            );
            balance.put(
                lender,
                balance.getOrDefault(lender, 0) + amount
            );
        }

        int minNegative = Integer.MAX_VALUE;
        for (int value : balance.values()) {
            if (value < 0) {
                minNegative = Math.min(minNegative, value);
            }
        }
        if (minNegative == Integer.MAX_VALUE) {
            return Collections.emptyList();
        }
        List<String> answer = new ArrayList<>();
        for (Map.Entry<String, Integer> entry : balance.entrySet()) {
            if (entry.getValue() == minNegative) {
                answer.add(entry.getKey());
            }
        }
        Collections.sort(answer);
        return answer;
    }
}

Complexity

Time Complexity

O(n + k log k)

where

  • n = transactions
  • k = number of people with minimum balance

Space Complexity

O(k)

Interview Discussion

After finishing the code, the interviewer asked:

  • Why HashMap?
  • Why not TreeMap?
  • Can sorting be avoided?
  • Why did you ignore positive balances while finding the minimum?

Fortunately, I had already considered these edge cases during the discussion.

Question 2: Watchtowers of the Ring Wall

The second question was much more interesting.

The problem described a circular wall containing watchtowers. Every tower had a signal fire of a particular height. For every tower, I had to find the first strictly taller tower while moving clockwise.

If no taller tower existed anywhere on the circular wall, return -1.

Example

Input

5 3 8

Output

8 8 -1

My Initial Thought

My first idea was simply checking every tower clockwise.

For every tower
    check next tower
    check next tower
    ...

until a taller tower is found

The interviewer immediately asked the complexity.

O(n²)

Since the constraints allowed up to 10000 towers, that solution wouldn't pass. At that moment I recognized the pattern. This was actually Next Greater Element in a Circular Array.

My Optimal Approach

The standard Next Greater Element problem uses a monotonic decreasing stack. The only additional challenge here was that the array was circular. Instead of physically creating another array, I traversed the array twice.

2*n-1


0

Using

index = i % n

allowed me to simulate wrapping around. While traversing

  • remove every element smaller than or equal to current
  • stack top becomes answer
  • push current element

Dry Run

Input

5 3 8

Processing from right to left

Stack

[]

8
8 3
8 5

Answers become


8
8
-1

Output

[8,8,-1]
class Result {

    public static List<Integer> getWatchTowers(List<Integer> nums) {

        int n = nums.size();
        int[] ans = new int[n];
        Arrays.fill(ans, -1);
        Deque<Integer> stack = new ArrayDeque<>();

        for (int i = 2 * n - 1; i >= 0; i--) {
            int curr = nums.get(i % n);
            while (!stack.isEmpty() &&
                    stack.peek() <= curr) {
                stack.pop();
            }
            if (i < n) {
                ans[i] =
                        stack.isEmpty()
                        ? -1
                        : stack.peek();
            }
            stack.push(curr);
        }

        List<Integer> result = new ArrayList<>();
        for (int x : ans) {
            result.add(x);
        }
        return result;
    }
}

Complexity

Time

O(n)

Space

O(n)

The interviewer also asked me why this solution is O(n). I explained that although there is a while loop, every element is pushed exactly once and popped at most once. Therefore the total number of stack operations remains linear.

Follow-up Questions

Once both coding problems were completed, we discussed several follow-up questions. Some of them included:

  • Why is the stack maintained in decreasing order?
  • Why is the array traversed twice?
  • What happens if duplicate values exist?
  • Can the circular array be solved without traversing twice?
  • How would you test these solutions?

The interviewer seemed more interested in understanding whether I knew why the algorithms worked rather than simply memorizing them.

Overall Experience

I really enjoyed this interview.

Both questions were based on well-known DSA concepts, but they were presented as real-world problems instead of direct LeetCode questions.

  • The first problem tested HashMap usage, simulations and edge-case handling.

  • The second problem tested pattern recognition. If you have solved problems like:

    • Next Greater Element
    • Daily Temperatures
    • Stock Span
    • Largest Rectangle in Histogram

then identifying the monotonic stack approach becomes much easier.

The interviewer was friendly throughout the discussion and frequently asked follow-up questions to understand my reasoning. I made sure to explain every design decision before writing code and I believe that helped create a positive discussion.

Preparation Tips

If you're preparing for KLA's Software Engineer interview, I recommend focusing on these topics:

  • HashMap-based simulation problems
  • Monotonic Stack
  • Next Greater Element (including Circular Array)
  • Sliding Window
  • Binary Search on Answer
  • Graph Traversals (BFS/DFS)
  • Priority Queue / Heap
  • Union Find (DSU)
  • Dynamic Programming fundamentals

One thing I learned from this interview is that explaining your approach clearly is just as important as writing the correct code. The interviewer repeatedly focused on my reasoning, edge cases and complexity analysis before evaluating the implementation.

Overall, I found the DSA round to be well designed and fair. If you're comfortable with common interview patterns and practice explaining your thought process aloud, you'll be in a good position to perform well.

I hope this interview experience helps anyone preparing for KLA. Best of luck with your preparation!

Responses (1)

Write a response

CommentHide Comments
~ Ashwin Suresh⏱️18 July 2026

Thank you for sharing the experience Deepak, This will really help in my preparation Journey!