← Walmart Interview Insights

Walmart·Mobile Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Walmart Labs mobile engineer screen, pretty much just one coding problem the whole time. Nothing crazy but it required thinking through the data structure carefully before writing anything.

Questions Asked (1)

Q1

Given a list of structs each containing a type, an id, and a num field, produce a mapping from type to an object holding the total sum of num values and a list of (id, num) pairs sorted by num.

Algorithms & Data StructuresData Modeling
Author's notes

Spent the first couple minutes just staring at the struct layout trying to figure out the cleanest way to accumulate.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the input format and output requirements, then propose a single-pass aggregation using a hash map keyed by type. For each type, maintain a running sum and a list of (id, num) pairs, sorting each list by num at the end or using an ordered structure.

Pro tip: Mention that on mobile, memory and performance matter, so avoid unnecessary intermediate collections and consider sorting in-place or using a priority queue if only top-k is needed. Also, discuss handling edge cases like empty input or duplicate ids.

1. Clarify requirements and constraints

Ask about input size, whether ids are unique per type, expected output format (e.g., object with sum and sorted list), and if sorting should be ascending or descending.

2. Choose data structures

Use a hash map (dictionary) mapping type to an object containing sum and a list of pairs. For sorting, decide between sorting each list after aggregation or maintaining a sorted list during insertion.

3. Iterate and aggregate

Loop through the list of structs, updating the sum and appending (id, num) to the corresponding type's list. This is O(n) time for aggregation.

4. Sort each type's list

For each type, sort the list of (id, num) pairs by num. If using a comparison sort, this is O(k log k) per type, where k is the number of entries for that type.

5. Return the mapping

Construct and return the final mapping from type to the object with total sum and sorted list. Discuss time and space complexity.

Key Points to Mention

  • Time complexity: O(n + Σ k_i log k_i) where n is total number of structs and k_i is count per type.
  • Space complexity: O(n) for storing the mapping and lists.
  • Handling edge cases: empty input, types with single entry, duplicate ids (if allowed).
  • Choice of sorting algorithm: built-in sort is usually fine, but for mobile consider stability and memory.
  • Potential optimization: if only top-k needed, use a heap instead of full sort.
  • Language-specific considerations: e.g., in Swift, use Dictionary and sort(by:), in Kotlin use groupBy and sortedBy.

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