PracHub
QuestionsCoachesLearningGuidesInterview Prep

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.

Best Value-for-Money Item

Return the smallest index with maximum rating/price ratio.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([10,20,5], [5,5,2])

Expected Output: 0

Explanation: Compare ratios exactly.

Input: ([2,4], [1,2])

Expected Output: 0

Explanation: Tie returns earliest.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.

Minutes Since Most Recent Departed Bus

Return minutes since latest departure strictly earlier than current time, or -1.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: (['11:20','15:00'], '16:00')

Expected Output: 60

Explanation: One hour since 15:00.

Input: (['10:00'], '10:00')

Expected Output: -1

Explanation: Strictly earlier excludes equal.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.

Maximum Straight-Line Grid Expression

Return the maximum value of a valid digit/operator expression along a rightward or downward path.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([['1','+','2'], ['9','-','3']],)

Expected Output: 9

Explanation: Right/down expressions.

Input: ([['5']],)

Expected Output: 5

Explanation: Single digit.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.

Dynamic Pair-Sum Queries

Process updates to secondary and pair-sum count queries with primary.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([1,2], [3,4], [[1,5],[0,0,4],[1,5]])

Expected Output: [2, None, 2]

Explanation: Query then update.

Input: ([1], [1,2,3], [[1,4]])

Expected Output: [1]

Explanation: Single primary.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.
Last updated: Jun 27, 2026

Loading coding console...

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
  • AI Coding 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

  • 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)