PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Atlassian

Compute inverse-depth weighted sum of a nested list

Last updated: Mar 29, 2026

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.

Related Interview Questions

  • Find a secret word using match feedback - Atlassian (hard)
  • Compute a moving average on a stream - Atlassian (hard)
  • Implement sequential and parallel URL requests - Atlassian (medium)
  • Implement sliding-window rate limiter function - Atlassian (medium)
  • Merge intervals and design rating APIs - Atlassian (medium)
Atlassian logo
Atlassian
Oct 11, 2025, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
4
0
Loading...

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+1weight(d) = D - d + 1weight(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)

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Atlassian•More Machine Learning Engineer•Atlassian Machine Learning Engineer•Atlassian Coding & Algorithms•Machine Learning 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.