PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/NVIDIA

Solve anagram grouping and in-place allocator

Last updated: Mar 29, 2026

Quick Overview

This two-part question evaluates algorithmic problem-solving across string grouping and constrained in-place memory allocation, testing string-processing and data-organization skills as well as low-level memory layout reasoning under strict O(1) extra-space limits.

  • medium
  • NVIDIA
  • Coding & Algorithms
  • Software Engineer

Solve anagram grouping and in-place allocator

Company: NVIDIA

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are asked to solve **two coding tasks**. ## 1) Group anagrams Given an array of strings `strs`, group the strings that are anagrams of each other. - Two strings are anagrams if they contain the same characters with the same counts (order can differ). - Return the groups in any order. **Input:** `strs: string[]` **Output:** `string[][]` where each inner array is one anagram group. **Constraints (typical):** - `1 <= len(strs) <= 10^5` - Each string length `<= 100` - Characters are lowercase English letters (unless otherwise stated). --- ## 2) Implement `allocate()` / `free()` with no extra space You have a fixed memory pool represented by an array `mem` of **32 slots**: - `mem` has length `N = 32`. - Each `mem[i]` is a **64-bit unsigned value**. - Each allocated slot stores exactly one 64-bit value. Implement the following API: - `init(mem)`: initialize the pool so all slots are free. - `allocate(x) -> handle`: stores value `x` into one free slot and returns a `handle` (an integer index `0..31`). If no space is available, return `-1`. - `free(handle)`: marks the slot at `handle` as free. **Key constraint:** - You may not use additional data structures proportional to `N` (no separate boolean/bitmap arrays, hash sets, etc.). Only **O(1)** extra variables are allowed beyond the given `mem` array. **Clarifications to state/assume in your solution (as an interviewer would):** - Whether `free()` may be called on an invalid or already-freed handle, and what to do in that case. - Whether all 64 bits are available for user data, or whether you are allowed to reserve some bits for metadata. Design for good time complexity (ideally O(1) per operation).

Quick Answer: This two-part question evaluates algorithmic problem-solving across string grouping and constrained in-place memory allocation, testing string-processing and data-organization skills as well as low-level memory layout reasoning under strict O(1) extra-space limits.

Related Interview Questions

  • Return all file paths via DFS - NVIDIA (easy)
  • Implement a disk space manager with eviction - NVIDIA (medium)
  • Implement short algorithms on logs, grids, and strings - NVIDIA (hard)
  • Implement encode/decode for list of strings - NVIDIA (easy)
  • Solve small string and API tasks - NVIDIA (medium)
NVIDIA logo
NVIDIA
Dec 21, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0
Loading...

You are asked to solve two coding tasks.

1) Group anagrams

Given an array of strings strs, group the strings that are anagrams of each other.

  • Two strings are anagrams if they contain the same characters with the same counts (order can differ).
  • Return the groups in any order.

Input: strs: string[]

Output: string[][] where each inner array is one anagram group.

Constraints (typical):

  • 1 <= len(strs) <= 10^5
  • Each string length <= 100
  • Characters are lowercase English letters (unless otherwise stated).

2) Implement allocate() / free() with no extra space

You have a fixed memory pool represented by an array mem of 32 slots:

  • mem has length N = 32 .
  • Each mem[i] is a 64-bit unsigned value .
  • Each allocated slot stores exactly one 64-bit value.

Implement the following API:

  • init(mem) : initialize the pool so all slots are free.
  • allocate(x) -> handle : stores value x into one free slot and returns a handle (an integer index 0..31 ). If no space is available, return -1 .
  • free(handle) : marks the slot at handle as free.

Key constraint:

  • You may not use additional data structures proportional to N (no separate boolean/bitmap arrays, hash sets, etc.). Only O(1) extra variables are allowed beyond the given mem array.

Clarifications to state/assume in your solution (as an interviewer would):

  • Whether free() may be called on an invalid or already-freed handle, and what to do in that case.
  • Whether all 64 bits are available for user data, or whether you are allowed to reserve some bits for metadata.

Design for good time complexity (ideally O(1) per operation).

Comments (0)

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 7,500+ 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.