PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Answer four array/time/grid query questions

Last updated: Mar 29, 2026

Quick Overview

This set of four problems evaluates array manipulation and comparison, time parsing and minute-difference calculation, linear path enumeration with expression evaluation on a grid, and dynamic pair-sum queries with point updates, testing core algorithmic problem-solving, parsing, and data-structure reasoning in the coding & algorithms domain.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Answer four array/time/grid query questions

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

You are given four independent coding questions. ## Q1) Best value-for-money item You are given two arrays of equal length `prices` and `ratings` (each `ratings[i]` is an integer from 1 to 5). Define the value-for-money score of item `i` as: - `score(i) = ratings[i] / prices[i]` Return the **index** of the item with the **maximum** score. If multiple items tie for the maximum score, return the **smallest index** among them. Assume `prices[i] > 0`. Use 0-based indices. --- ## Q2) Minutes since the most recent departed bus You are given: - `departure_times`: an array of strings, each in 24-hour format `"HH:MM"`, representing bus departure times within the same day (e.g., `["11:20", "15:00"]`). - `current_time`: a string `"HH:MM"` representing the current time within the same day. You must find the departure time that is the **latest time strictly earlier than** `current_time` (i.e., if a bus departs at exactly `current_time`, it is **not** considered “already departed”). Return how many minutes have passed since that departure: - `current_time - last_departure_time` in minutes If there is **no** departure time strictly earlier than `current_time`, return `-1`. --- ## Q3) Max value expression along a straight path in a grid You are given a 2D character matrix `puzzle` whose cells contain only: - a single digit character `'0'`–`'9'`, or - `'+'`, or - `'-'` You must choose a **path** that forms a **valid arithmetic expression** and return the **maximum** value achievable. Rules: 1. You may start at **any cell containing a digit**. 2. From the start, you must move in a **single straight direction only**: either - move **right** any number of steps (possibly stopping early), or - move **down** any number of steps (possibly stopping early). You **cannot change direction** once chosen. 3. Reading the characters along the visited cells in order yields an expression that must be valid: - It must **start with a digit**. - Digits and operators must **alternate** (no two consecutive digits, no two consecutive operators). - It must **end with a digit**. 4. Evaluate the expression using standard integer arithmetic with only `+` and `-` (equivalently, left-to-right evaluation since precedence is the same). Return the maximum evaluated result among all valid paths. (Assume at least one valid expression exists unless you decide to return something like negative infinity / null if none exists.) --- ## Q4) Dynamic pair-sum queries with updates You are given two integer arrays: - `primary` - `secondary` You are also given a list of operations `operations`, each operation is one of: - **Type 0 (update)**: `[0, index, val]` meaning set `secondary[index] = val`. - **Type 1 (query)**: `[1, targetSum]` meaning count the number of pairs `(i, j)` such that: - `0 <= i < len(primary)`, `0 <= j < len(secondary)`, and - `primary[i] + secondary[j] == targetSum` For each Type 1 operation, output its count. Return all Type 1 results in order as an array. Constraints are not specified; your solution should handle many operations efficiently (faster than recomputing all pairs on every query).

Quick Answer: This set of four problems evaluates array manipulation and comparison, time parsing and minute-difference calculation, linear path enumeration with expression evaluation on a grid, and dynamic pair-sum queries with point updates, testing core algorithmic problem-solving, parsing, and data-structure reasoning in the coding & algorithms domain.

Related Interview Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
Meta logo
Meta
Jan 6, 2026, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
13
0
Loading...

You are given four independent coding questions.

Q1) Best value-for-money item

You are given two arrays of equal length prices and ratings (each ratings[i] is an integer from 1 to 5).

Define the value-for-money score of item i as:

  • score(i) = ratings[i] / prices[i]

Return the index of the item with the maximum score. If multiple items tie for the maximum score, return the smallest index among them.

Assume prices[i] > 0. Use 0-based indices.

Q2) Minutes since the most recent departed bus

You are given:

  • departure_times : an array of strings, each in 24-hour format "HH:MM" , representing bus departure times within the same day (e.g., ["11:20", "15:00"] ).
  • current_time : a string "HH:MM" representing the current time within the same day.

You must find the departure time that is the latest time strictly earlier than current_time (i.e., if a bus departs at exactly current_time, it is not considered “already departed”).

Return how many minutes have passed since that departure:

  • current_time - last_departure_time in minutes

If there is no departure time strictly earlier than current_time, return -1.

Q3) Max value expression along a straight path in a grid

You are given a 2D character matrix puzzle whose cells contain only:

  • a single digit character '0' – '9' , or
  • '+' , or
  • '-'

You must choose a path that forms a valid arithmetic expression and return the maximum value achievable.

Rules:

  1. You may start at any cell containing a digit .
  2. From the start, you must move in a single straight direction only : either
    • move right any number of steps (possibly stopping early), or
    • move down any number of steps (possibly stopping early).
    You cannot change direction once chosen.
  3. Reading the characters along the visited cells in order yields an expression that must be valid:
    • It must start with a digit .
    • Digits and operators must alternate (no two consecutive digits, no two consecutive operators).
    • It must end with a digit .
  4. Evaluate the expression using standard integer arithmetic with only + and - (equivalently, left-to-right evaluation since precedence is the same).

Return the maximum evaluated result among all valid paths. (Assume at least one valid expression exists unless you decide to return something like negative infinity / null if none exists.)

Q4) Dynamic pair-sum queries with updates

You are given two integer arrays:

  • primary
  • secondary

You are also given a list of operations operations, each operation is one of:

  • Type 0 (update) : [0, index, val] meaning set secondary[index] = val .
  • Type 1 (query) : [1, targetSum] meaning count the number of pairs (i, j) such that:
    • 0 <= i < len(primary) , 0 <= j < len(secondary) , and
    • primary[i] + secondary[j] == targetSum

For each Type 1 operation, output its count. Return all Type 1 results in order as an array.

Constraints are not specified; your solution should handle many operations efficiently (faster than recomputing all pairs on every query).

Submit Your Answer to Earn 20XP

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