PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Find balanced subarray and increasing tree path

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array and tree algorithm skills, testing competency in identifying longest balanced subarrays in binary sequences and locating maximal strictly increasing downward paths in binary trees.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Find balanced subarray and increasing tree path

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given **two coding problems**. ## Problem 1: Longest balanced subarray (0/1) Given an integer array `nums` of length `n` where each element is either `0` or `1`, return the **maximum length** of a contiguous subarray that contains an **equal number of `0`s and `1`s**. **Input:** `nums: int[]` (each `nums[i] ∈ {0,1}`) **Output:** `int` = maximum length **Constraints (typical):** `1 ≤ n ≤ 2e5` --- ## Problem 2: Longest increasing downward path in a binary tree (return the path) Given the root of a binary tree where each node has an integer value, find a **downward path** (must follow parent → child pointers) such that for every adjacent pair on the path: - `child.value > parent.value` (strictly increasing) Return the **entire path** (e.g., as a list/array of node values in order from start to end) that has the **maximum length**. If multiple longest paths exist, you may return **any one** of them. **Input:** `root: TreeNode` with fields `val`, `left`, `right` **Output:** `int[]` (or `List<int>`) representing the node values along the chosen maximum-length increasing path **Constraints (typical):** up to `2e5` nodes.

Quick Answer: This question evaluates array and tree algorithm skills, testing competency in identifying longest balanced subarrays in binary sequences and locating maximal strictly increasing downward paths in binary trees.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Nov 2, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0

You are given two coding problems.

Problem 1: Longest balanced subarray (0/1)

Given an integer array nums of length n where each element is either 0 or 1, return the maximum length of a contiguous subarray that contains an equal number of 0s and 1s.

Input: nums: int[] (each nums[i] ∈ {0,1})

Output: int = maximum length

Constraints (typical): 1 ≤ n ≤ 2e5

Problem 2: Longest increasing downward path in a binary tree (return the path)

Given the root of a binary tree where each node has an integer value, find a downward path (must follow parent → child pointers) such that for every adjacent pair on the path:

  • child.value > parent.value (strictly increasing)

Return the entire path (e.g., as a list/array of node values in order from start to end) that has the maximum length.

If multiple longest paths exist, you may return any one of them.

Input: root: TreeNode with fields val, left, right

Output: int[] (or List<int>) representing the node values along the chosen maximum-length increasing path

Constraints (typical): up to 2e5 nodes.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,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.