PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/NVIDIA

Implement short algorithms on logs, grids, and strings

Last updated: Jun 18, 2026

Quick Overview

This multi-part Coding & Algorithms question evaluates algorithmic problem-solving skills and mastery of core competencies including temporal window reasoning, greedy optimization under repeated operations, bracket-matching/parsing, log aggregation and parsing, and combinatorial placement on grids.

  • hard
  • NVIDIA
  • Coding & Algorithms
  • Software Engineer

Implement short algorithms on logs, grids, and strings

Company: NVIDIA

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Onsite

You are given several independent short coding tasks. For each task, implement the requested function(s). Assume standard library data structures are allowed. ## 1) Detect CPU temperature spikes You receive CPU temperature readings as a list of pairs `(timestamp, tempC)` sorted by `timestamp` ascending. Define a **spike** at reading `i` (time `t_i`, temperature `x_i`) if there exists some earlier reading `j < i` such that: - `t_i - t_j <= windowSeconds`, and - `x_i - x_j >= deltaC`. **Input:** - `readings: List[Tuple[int timestamp, int tempC]]` (timestamps are seconds) - `windowSeconds: int` - `deltaC: int` **Output:** - Return the list of timestamps `t_i` where reading `i` is a spike. **Constraints (example):** up to `2e5` readings. --- ## 2) Minimum possible sum after K operations Given an array of non-negative integers `a` and an integer `k`, you may perform the following operation exactly `k` times: - Choose an index `i` and replace `a[i]` with `ceil(a[i] / 2)`. **Goal:** minimize the final sum of the array. **Input:** `a: List[int]`, `k: int` **Output:** the minimum achievable sum after `k` operations. **Constraints (example):** `n` up to `2e5`, values up to `1e9`, `k` up to `2e5`. --- ## 3) Verify matching brackets in a mathematical expression Given a string `s` representing a mathematical expression containing characters including `()[]{}` and other non-bracket characters, determine whether the brackets are correctly matched and nested. **Input:** `s: str` **Output:** `True` if valid, else `False`. **Notes:** Non-bracket characters should be ignored. --- ## 4) Aggregate HTTP logs by status code You are given log lines. Each line contains a status code and a response time in milliseconds: Format: `"<statusCode> <responseTimeMs>"` Example: `"200 153"`, `"500 12"`. **Task:** aggregate by `statusCode`: - count of requests - average response time (as a floating-point value) **Input:** `logs: List[str]` **Output:** a mapping/dictionary `statusCode -> (count, avgResponseTime)`. **Edge cases:** empty input; malformed lines may be ignored (state and implement a consistent rule). --- ## 5) Tree planting on a grid (no adjacent trees) You are given an `m x n` grid `land` with: - `1` meaning an existing tree - `0` meaning empty land You may plant additional trees on empty cells, but **no two trees** (existing or newly planted) may be adjacent in the 4-neighborhood (up/down/left/right). **Task:** determine a set of cells to plant new trees that is **maximum in size**. **Input:** `land: List[List[int]]` **Output:** - `maxNewTrees: int`, the maximum number of new trees that can be planted - optionally (if asked), one valid resulting grid configuration **Constraints (example):** `m, n` up to ~`50` (state assumptions and optimize accordingly).

Quick Answer: This multi-part Coding & Algorithms question evaluates algorithmic problem-solving skills and mastery of core competencies including temporal window reasoning, greedy optimization under repeated operations, bracket-matching/parsing, log aggregation and parsing, and combinatorial placement on grids.

Related Interview Questions

  • Compute the Final Robot Score - NVIDIA (easy)
  • Return all file paths via DFS - NVIDIA (easy)
  • Implement a disk space manager with eviction - NVIDIA (medium)
  • Implement encode/decode for list of strings - NVIDIA (easy)
  • Implement matrix transpose and KV store - NVIDIA (medium)
NVIDIA logo
NVIDIA
Feb 11, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
16
0
Practice Read
Loading...

You are given several independent short coding tasks. For each task, implement the requested function(s). Assume standard library data structures are allowed.

1) Detect CPU temperature spikes

You receive CPU temperature readings as a list of pairs (timestamp, tempC) sorted by timestamp ascending.

Define a spike at reading i (time t_i, temperature x_i) if there exists some earlier reading j < i such that:

  • t_i - t_j <= windowSeconds , and
  • x_i - x_j >= deltaC .

Input:

  • readings: List[Tuple[int timestamp, int tempC]] (timestamps are seconds)
  • windowSeconds: int
  • deltaC: int

Output:

  • Return the list of timestamps t_i where reading i is a spike.

Constraints (example): up to 2e5 readings.

2) Minimum possible sum after K operations

Given an array of non-negative integers a and an integer k, you may perform the following operation exactly k times:

  • Choose an index i and replace a[i] with ceil(a[i] / 2) .

Goal: minimize the final sum of the array.

Input: a: List[int], k: int

Output: the minimum achievable sum after k operations.

Constraints (example): n up to 2e5, values up to 1e9, k up to 2e5.

3) Verify matching brackets in a mathematical expression

Given a string s representing a mathematical expression containing characters including ()[]{} and other non-bracket characters, determine whether the brackets are correctly matched and nested.

Input: s: str

Output: True if valid, else False.

Notes: Non-bracket characters should be ignored.

4) Aggregate HTTP logs by status code

You are given log lines. Each line contains a status code and a response time in milliseconds:

Format: "<statusCode> <responseTimeMs>"

Example: "200 153", "500 12".

Task: aggregate by statusCode:

  • count of requests
  • average response time (as a floating-point value)

Input: logs: List[str]

Output: a mapping/dictionary statusCode -> (count, avgResponseTime).

Edge cases: empty input; malformed lines may be ignored (state and implement a consistent rule).

5) Tree planting on a grid (no adjacent trees)

You are given an m x n grid land with:

  • 1 meaning an existing tree
  • 0 meaning empty land

You may plant additional trees on empty cells, but no two trees (existing or newly planted) may be adjacent in the 4-neighborhood (up/down/left/right).

Task: determine a set of cells to plant new trees that is maximum in size.

Input: land: List[List[int]]

Output:

  • maxNewTrees: int , the maximum number of new trees that can be planted
  • optionally (if asked), one valid resulting grid configuration

Constraints (example): m, n up to ~50 (state assumptions and optimize accordingly).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More NVIDIA•More Software Engineer•NVIDIA Software Engineer•NVIDIA Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.