Solve four OA coding problems
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: HR Screen
The online assessment reportedly contained four coding problems:
1. **Compare negative and positive counts**
Given a sorted integer array `nums` in nondecreasing order, return the larger of:
- the number of elements less than `0`
- the number of elements greater than `0`
Elements equal to `0` should not be counted in either group.
2. **Reach a destination with charging stations**
A drone must travel `target` units of distance. It starts with `startCharge` units of battery, and it consumes `1` unit of battery per unit of distance traveled. Along the route, `stations[i] = [position_i, charge_i]` describes a charging station at distance `position_i` from the start that can provide `charge_i` additional battery units. The stations are sorted by position. Return the minimum number of charging stops needed to reach the destination, or `-1` if the destination cannot be reached.
3. **Count objects placed on a grid**
You are given an `m x n` grid of characters `'X'` and `'.'`. Each object is formed by one or more contiguous `'X'` cells placed either horizontally in one row or vertically in one column. Different objects are separated by at least one `'.'` cell, so no two distinct objects touch horizontally or vertically. Return the total number of objects in the grid.
4. **Find the longest consecutive-value run**
Given an unsorted integer array `nums`, return the length of the longest set of consecutive integer values that appears in the array. The values do not need to be adjacent in the original array. Aim for an `O(n)` solution.
Quick Answer: This set of four problems evaluates core algorithmic competencies including array manipulation and counting in sorted arrays, resource-constrained optimization for reachability with recharge stations, grid-based connected-component identification, and detection of longest consecutive-value sequences, emphasizing data-structure selection, edge-case reasoning, and time/space complexity analysis. Commonly asked in Coding & Algorithms interviews to assess both conceptual understanding of algorithmic paradigms and practical application of efficient techniques under constraints, these questions measure algorithmic thinking, complexity analysis, and problem decomposition.