← Navan Interview Insights

Navan·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Navan coding screen for a software engineer role. One algorithmic problem, pretty focused, felt like a straightforward session but the edge case clarification mid-problem was a bit of a curveball.

Questions Asked (1)

Q1

Given an array of positive prices and a discount percentage, apply the discount only to the single most expensive item (first occurrence if tied), then return the floor of the total sum.

Algorithms & Data Structures
Author's notes

My first instinct was to sort, which would've blown the O(n) requirement.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem constraints and edge cases (e.g., empty array, discount range). Then, in a single pass, find the index of the maximum price (first occurrence) and compute the total sum. Finally, subtract the discount amount from the total and return the floor.

Pro tip: Mention that you can avoid floating-point errors by computing the discounted total as total - (max_price * discount / 100) using integer arithmetic where possible, and only apply floor at the end.

1. Clarify requirements and edge cases

Confirm the discount is a percentage (0-100), the array may be empty, and ties go to the first occurrence. Discuss handling of negative or zero prices if not specified.

2. Find the most expensive item

Iterate through the array to find the maximum price and its first index. Track the index to handle ties correctly.

3. Compute the total sum

While iterating, also accumulate the sum of all prices. This can be done in the same pass as finding the maximum.

4. Apply discount and floor

Calculate the discount amount as (max_price * discount) / 100. Subtract this from the total sum, then take the floor of the result.

5. Test with examples

Walk through a few test cases, including ties, empty array, and 0% or 100% discount, to verify correctness.

Key Points to Mention

  • Time complexity: O(n) single pass, space complexity: O(1)
  • Handling ties: first occurrence of maximum
  • Edge cases: empty array, discount 0 or 100, negative prices (if allowed)
  • Floating-point precision: use integer arithmetic or round carefully
  • Floor operation: apply only at the end to avoid compounding errors
  • Potential for using built-in functions like max() and sum() but be aware of multiple passes

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.