← Ericsson Interview Insights

Ericsson·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Ericsson software engineer coding round, two problems back to back in an hour. Nothing too wild but the heap question required you to actually know your data structures, not just fake it.

Questions Asked (2)

Q1

Given an integer numRows, generate the first numRows rows of Pascal's triangle and return them as a list of rows.

Algorithms & Data Structures
Author's notes

Knew this one the moment I read it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and edge cases, then explain the dynamic programming approach where each row is built from the previous row. Emphasize the O(numRows^2) time and space complexity, and offer to code it up.

Pro tip: Mention that you can optimize space by only keeping the previous row, but since the output requires all rows, O(numRows^2) space is unavoidable. This shows you understand trade-offs.

1. Clarify requirements and edge cases

Ask about constraints (e.g., numRows >= 0) and expected output format. Discuss handling numRows = 0 or 1.

2. Explain the recurrence relation

Describe how each element (except first and last) is the sum of the two elements above it in the previous row. This forms the basis of the algorithm.

3. Outline the iterative approach

Initialize an empty list. For each row i from 0 to numRows-1, create a new row of length i+1, set first and last to 1, and fill middle using previous row.

4. Analyze complexity

State that time complexity is O(numRows^2) because we generate each element once. Space complexity is also O(numRows^2) for the output, but auxiliary space can be O(numRows) if only previous row is kept.

5. Code and test

Write clean code with meaningful variable names. Test with small inputs like 0, 1, 2, 5 to verify correctness.

Key Points to Mention

  • Dynamic programming / iterative construction
  • Recurrence relation: row[i][j] = row[i-1][j-1] + row[i-1][j]
  • Edge cases: numRows = 0, 1
  • Time and space complexity analysis
  • Space optimization: only keep previous row for auxiliary space
  • Clean code and testing with examples

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

Q2

Given an array of integers and a value k, return any k values that appear most frequently in the array.

Algorithms & Data Structures
Author's notes

Started with a frequency map, no issues there.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a hash map to count the frequency of each element, then use a min-heap of size k or quickselect to find the k most frequent elements. Discuss trade-offs between approaches and handle edge cases like k larger than the number of unique elements.

Pro tip: Clarify whether the output order matters and if ties can be broken arbitrarily; also mention that for large datasets, a distributed approach like MapReduce could be used, showing awareness of scalability.

1. Clarify requirements and edge cases

Ask about input size, whether k is guaranteed valid, if the array can be empty, and if the order of the k elements matters. This shows attention to detail.

2. Choose an algorithm

Decide between sorting all unique elements by frequency (O(n log n)), using a min-heap of size k (O(n log k)), or quickselect (average O(n)). Explain your choice based on constraints.

3. Implement the solution

Write clean code: first build a frequency map, then apply your chosen method to extract the top k. Use appropriate data structures and handle edge cases.

4. Analyze complexity

State time and space complexity clearly. For heap approach: O(n log k) time, O(n) space. For quickselect: average O(n) time, O(n) space.

5. Test with examples

Walk through a small example, including edge cases like k=1, k=number of unique elements, or all elements the same. Verify correctness.

Key Points to Mention

  • Hash map for frequency counting
  • Min-heap of size k for efficient top-k extraction
  • Quickselect (average O(n)) as an alternative
  • Time and space complexity trade-offs
  • Handling ties and arbitrary order
  • Edge cases: empty array, k=0, k > unique elements

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