PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This multipart question evaluates proficiency with tree-based data structures and array-based algorithmic problem solving, focusing on reasoning about which nodes are visible from a binary tree's right side and identifying unique zero-sum triplets in an integer array; it tests concepts such as tree traversal, duplicate handling, and algorithmic complexity analysis. These problems are commonly asked to assess algorithmic problem-solving ability, manipulation of fundamental data structures, and attention to edge cases and performance, and they fall under the Coding & Algorithms category with a focus on practical application of algorithmic concepts supported by conceptual understanding of data structures and complexity.

  • easy
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve Tree View and Triplet Sum

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are asked to solve two coding problems. **Problem 1: Return the nodes visible from the right** Given the root of a binary tree, return the values of the nodes that would be visible if the tree were viewed from its right side. Return the values from top to bottom. Example: ```text Input: 1 / \ 2 3 \ \ 5 4 Output: [1, 3, 4] ``` Constraints: - The number of nodes is in the range `[0, 10^4]`. - Node values are integers. **Problem 2: Find unique triplets with zero sum** Given an integer array `nums`, return all unique triplets `[a, b, c]` such that `a + b + c = 0`. The solution set must not contain duplicate triplets. The order of triplets and the order of numbers inside each triplet do not matter. Example: ```text Input: nums = [-1, 0, 1, 2, -1, -4] Output: [[-1, -1, 2], [-1, 0, 1]] ``` Constraints: - `3 <= nums.length <= 3000` - `-10^5 <= nums[i] <= 10^5`

Quick Answer: This multipart question evaluates proficiency with tree-based data structures and array-based algorithmic problem solving, focusing on reasoning about which nodes are visible from a binary tree's right side and identifying unique zero-sum triplets in an integer array; it tests concepts such as tree traversal, duplicate handling, and algorithmic complexity analysis. These problems are commonly asked to assess algorithmic problem-solving ability, manipulation of fundamental data structures, and attention to edge cases and performance, and they fall under the Coding & Algorithms category with a focus on practical application of algorithmic concepts supported by conceptual understanding of data structures and complexity.

Part 1: Right Side View of a Binary Tree

You are given a binary tree serialized as a Python list in level-order, where `None` represents a missing child. Return the values of the nodes visible when the tree is viewed from the right side, from top to bottom.

Constraints

  • The number of nodes is in the range [0, 10^4].
  • Node values are integers.
  • The input list is a valid level-order serialization of a binary tree.
  • `None` indicates that a child is missing.

Examples

Input: [1, 2, 3, None, 5, None, 4]

Expected Output: [1, 3, 4]

Explanation: From the right, you see 1 at level 0, 3 at level 1, and 4 at level 2.

Input: [1, 2, 3, 4, None, None, None]

Expected Output: [1, 3, 4]

Explanation: Although 4 is on the left subtree, it is still the only visible node at its depth from the right.

Input: []

Expected Output: []

Explanation: An empty tree has no visible nodes.

Input: [7]

Expected Output: [7]

Explanation: A single-node tree is visible from every side.

Hints

  1. A level-order traversal lets you process one depth level at a time.
  2. At each level, the last node you visit is the one visible from the right.

Part 2: Find Unique Triplets With Zero Sum

Given an integer array `nums`, return all unique triplets `[a, b, c]` such that `a + b + c = 0`. The result must not contain duplicate triplets. For deterministic grading, return each triplet in nondecreasing order, and return the full list of triplets in lexicographic order.

Constraints

  • 3 <= nums.length <= 3000
  • -10^5 <= nums[i] <= 10^5
  • The solution set must not contain duplicate triplets.

Examples

Input: [-1, 0, 1, 2, -1, -4]

Expected Output: [[-1, -1, 2], [-1, 0, 1]]

Explanation: These are the only two unique triplets whose sum is zero.

Input: [0, 0, 0, 0]

Expected Output: [[0, 0, 0]]

Explanation: Even though there are many ways to pick three zeros, the triplet should appear only once.

Input: [1, 2, -2, -1]

Expected Output: []

Explanation: No three numbers add up to zero.

Input: [-2, 0, 1, 1, 2]

Expected Output: [[-2, 0, 2], [-2, 1, 1]]

Explanation: There are exactly two unique zero-sum triplets.

Hints

  1. Sorting the array turns the problem into finding pairs with a target for each fixed first number.
  2. After finding a valid triplet, move both pointers and skip repeated values to avoid duplicates.
Last updated: May 19, 2026

Loading coding console...

PracHub

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

Related Coding Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)