PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates competency in working with nested data structures and depth-based aggregation, measuring the ability to reason about hierarchical list contents and weighted summation; it falls under the Coding & Algorithms domain and targets practical implementation skills rather than purely theoretical understanding.

  • medium
  • Atlassian
  • Coding & Algorithms
  • Machine Learning Engineer

Compute inverse-depth weighted sum of a nested list

Company: Atlassian

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem You are given a **nested list** of integers, where each element is either: - an integer, or - a list that follows the same rule (i.e., a nested list). Define the **depth** of an integer as the number of lists that contain it. - Example: In `[1,[2,[3]]]`, the integer `1` has depth 1, `2` has depth 2, and `3` has depth 3. Let `D` be the **maximum depth** among all integers in the structure. Compute the **inverse-depth weighted sum** where each integer with depth `d` is weighted by: \[ weight(d) = D - d + 1 \] Return the total weighted sum. ## Examples - Input: `[1,[2,[3]]]` - Maximum depth `D=3` - Sum = `1*(3-1+1) + 2*(3-2+1) + 3*(3-3+1)` = `1*3 + 2*2 + 3*1 = 10` - Output: `10` - Input: `[[1,1],2,[1,1]]` - Maximum depth `D=2` - Output: `8` ## Constraints (reasonable interview constraints) - Total number of integers `N` up to ~1e4. - Total nested list elements (including lists) up to ~1e4. - Integers fit in 32-bit signed range. ## Function Signature (language-agnostic) `int inverseDepthSum(NestedList nested)`

Quick Answer: This question evaluates competency in working with nested data structures and depth-based aggregation, measuring the ability to reason about hierarchical list contents and weighted summation; it falls under the Coding & Algorithms domain and targets practical implementation skills rather than purely theoretical understanding.

Compute the inverse-depth weighted sum of integers in a nested Python list.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,[2,[3]]],)

Expected Output: 10

Explanation: Depths 1,2,3 produce inverse weights 3,2,1.

Input: ([[1,1],2,[1,1]],)

Expected Output: 8

Explanation: LeetCode-style example gives 8.

Input: ([],)

Expected Output: 0

Explanation: No integers gives zero.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Loading coding console...

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
  • AI Coding 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.

Related Coding Questions

  • Find a secret word using match feedback - Atlassian (hard)
  • Compute a moving average on a stream - Atlassian (hard)
  • Implement sliding-window rate limiter function - Atlassian (medium)
  • Implement sequential and parallel URL requests - Atlassian (medium)
  • Merge intervals and design rating APIs - Atlassian (medium)