PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Solve frequency and tree-completeness problems

Last updated: Mar 29, 2026

Quick Overview

These two problems evaluate competency in frequency counting and selection algorithms for identifying top-k elements and in binary tree structure analysis and traversal for checking completeness, belonging to the Coding & Algorithms domain and the broader data structures and algorithms category.

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

Solve frequency and tree-completeness problems

Company: Meta

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem A: Return the *k* most frequent values You are given an integer array `nums` and an integer `k`. **Task:** Return the `k` distinct values that occur most frequently in `nums`. **Input** - `nums`: list of integers (length `n`) - `k`: integer, `1 <= k <= (# of distinct values in nums)` **Output** - A list of `k` integers: the values with highest frequency. **Notes / Constraints** - If multiple answers are possible due to ties, any valid order is acceptable. - Aim for better than `O(n log n)` if possible. --- ## Problem B: Check whether a binary tree is complete You are given the `root` of a binary tree. A binary tree is **complete** if: 1. Every level except possibly the last is completely filled, and 2. All nodes in the last level are as far left as possible. **Task:** Return `true` if the tree is complete; otherwise return `false`. **Input** - `root`: root node of a binary tree (each node has `val`, `left`, `right`) **Output** - Boolean: whether the tree is complete. **Constraints** - Up to ~`10^5` nodes.

Quick Answer: These two problems evaluate competency in frequency counting and selection algorithms for identifying top-k elements and in binary tree structure analysis and traversal for checking completeness, belonging to the Coding & Algorithms domain and the broader data structures and algorithms category.

Related Interview 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)
Meta logo
Meta
Feb 12, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
3
0
Loading...

Problem A: Return the k most frequent values

You are given an integer array nums and an integer k.

Task: Return the k distinct values that occur most frequently in nums.

Input

  • nums : list of integers (length n )
  • k : integer, 1 <= k <= (# of distinct values in nums)

Output

  • A list of k integers: the values with highest frequency.

Notes / Constraints

  • If multiple answers are possible due to ties, any valid order is acceptable.
  • Aim for better than O(n log n) if possible.

Problem B: Check whether a binary tree is complete

You are given the root of a binary tree.

A binary tree is complete if:

  1. Every level except possibly the last is completely filled, and
  2. All nodes in the last level are as far left as possible.

Task: Return true if the tree is complete; otherwise return false.

Input

  • root : root node of a binary tree (each node has val , left , right )

Output

  • Boolean: whether the tree is complete.

Constraints

  • Up to ~ 10^5 nodes.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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