PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Implement four coding challenges

Last updated: Mar 29, 2026

Quick Overview

This set of four problems evaluates algorithmic problem-solving and implementation skills across deterministic simulation (grid-based placement), dynamic interval/segment maintenance, incremental numeric tracking, and greedy array transformation, emphasizing correctness, state management, and complexity reasoning.

  • easy
  • Meta
  • Coding & Algorithms
  • Software Engineer

Implement four coding challenges

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

You are asked to solve the following four independent coding problems. --- ## 1) Block Placement Simulator (Tetris-like) You have an empty `n x m` grid (rows indexed top-to-bottom, columns left-to-right). You will place a sequence of pieces, each piece being one of five types `A/B/C/D/E`. Each piece type is defined by a fixed set of occupied cells in its own local coordinate system (e.g., a small boolean matrix or a list of `(dr, dc)` offsets). Pieces: - cannot be rotated or flipped, - must be placed fully within the grid, - cannot overlap already-occupied cells. **Placement rule (scan order):** For each incoming piece, find the first valid placement position by scanning candidate top-left anchors in priority order: 1) smallest row index (top to bottom), 2) within the same row, smallest column index (left to right). Place the piece at that first valid position. If no valid position exists, stop and return the grid/state according to the output requirement. **Task:** Implement the simulator that processes the piece sequence and produces the final grid (or alternatively the number of pieces placed), following the scan-order placement rule. --- ## 2) Longest Continuous Houses After Each Build On an integer number line, you build houses one by one at positions given by an array `queries`, in order. After each build, you must output the current length of the longest contiguous segment of built houses, where “contiguous” means consecutive integer positions. Example: if houses exist at `{2,3,4,10}`, the longest contiguous segment length is `3` (for `2-4`). Notes: - Coordinates can be very large (e.g., up to billions), - The number of builds is manageable, - Duplicate builds (building again at an already-built coordinate) should be handled (either ignored or specified by the problem). **Task:** Return an array `ans` where `ans[i]` is the longest contiguous segment length after processing `queries[0..i]`. --- ## 3) Rating Calculator (Max and Final Rating) You start with rating `1500`. You are given an integer array `diffs`, where `diffs[i]` is the rating change applied after the `i`-th event. Let `rating_0 = 1500` and `rating_{i+1} = rating_i + diffs[i]`. **Task:** Compute: 1) the maximum rating ever reached across the whole process (including the initial rating), and 2) the final rating after all changes. Return `(max_rating, final_rating)`. --- ## 4) Array Reduction Game Given an array of non-negative integers `a`: Repeat until all elements become `0`: 1) Find the leftmost index `i` such that `a[i] > 0`. Let `x = a[i]`. 2) Starting from index `i` and moving right, subtract `x` from each element while it is legal to do so (i.e., continue for indices `j = i, i+1, ...` as long as `a[j] >= x` at the moment you are about to subtract). Stop at the first position where the current value is `< x`. 3) Add `x` to an accumulator `result`. **Task:** Return `result`. (You may assume inputs are such that the process terminates; implement according to the exact step rules above.)

Quick Answer: This set of four problems evaluates algorithmic problem-solving and implementation skills across deterministic simulation (grid-based placement), dynamic interval/segment maintenance, incremental numeric tracking, and greedy array transformation, emphasizing correctness, state management, and complexity reasoning.

Related Interview Questions

  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Array, Matrix, and Recommendation Problems - Meta (medium)
  • Find a String Containing Another - Meta (medium)
  • Solve Subarray Sum and Local Minimum - Meta (hard)
  • Validate abbreviations and brackets - Meta (medium)
Meta logo
Meta
Feb 8, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
3
0

You are asked to solve the following four independent coding problems.

1) Block Placement Simulator (Tetris-like)

You have an empty n x m grid (rows indexed top-to-bottom, columns left-to-right). You will place a sequence of pieces, each piece being one of five types A/B/C/D/E.

Each piece type is defined by a fixed set of occupied cells in its own local coordinate system (e.g., a small boolean matrix or a list of (dr, dc) offsets). Pieces:

  • cannot be rotated or flipped,
  • must be placed fully within the grid,
  • cannot overlap already-occupied cells.

Placement rule (scan order): For each incoming piece, find the first valid placement position by scanning candidate top-left anchors in priority order:

  1. smallest row index (top to bottom),
  2. within the same row, smallest column index (left to right).

Place the piece at that first valid position. If no valid position exists, stop and return the grid/state according to the output requirement.

Task: Implement the simulator that processes the piece sequence and produces the final grid (or alternatively the number of pieces placed), following the scan-order placement rule.

2) Longest Continuous Houses After Each Build

On an integer number line, you build houses one by one at positions given by an array queries, in order. After each build, you must output the current length of the longest contiguous segment of built houses, where “contiguous” means consecutive integer positions.

Example: if houses exist at {2,3,4,10}, the longest contiguous segment length is 3 (for 2-4).

Notes:

  • Coordinates can be very large (e.g., up to billions),
  • The number of builds is manageable,
  • Duplicate builds (building again at an already-built coordinate) should be handled (either ignored or specified by the problem).

Task: Return an array ans where ans[i] is the longest contiguous segment length after processing queries[0..i].

3) Rating Calculator (Max and Final Rating)

You start with rating 1500. You are given an integer array diffs, where diffs[i] is the rating change applied after the i-th event.

Let rating_0 = 1500 and rating_{i+1} = rating_i + diffs[i].

Task: Compute:

  1. the maximum rating ever reached across the whole process (including the initial rating), and
  2. the final rating after all changes.

Return (max_rating, final_rating).

4) Array Reduction Game

Given an array of non-negative integers a:

Repeat until all elements become 0:

  1. Find the leftmost index i such that a[i] > 0 . Let x = a[i] .
  2. Starting from index i and moving right, subtract x from each element while it is legal to do so (i.e., continue for indices j = i, i+1, ... as long as a[j] >= x at the moment you are about to subtract). Stop at the first position where the current value is < x .
  3. Add x to an accumulator result .

Task: Return result.

(You may assume inputs are such that the process terminates; implement according to the exact step rules above.)

Comments (0)

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 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.