Fill and Sort Packed Missing-Number Grids
Updated
Problem statement
packed has four rows and 4k columns. Every consecutive four-column block is one 4 by 4 logical grid containing the strings 1 through 16, except that exactly one value is replaced by ?.
Fill every missing value, sort the logical grids by that numeric value ascending, and return the grids packed side by side in the new order.
Function
fillAndSortGrids(packed: String[][]) → String[][]Examples
Example 1
packed = [["1","2","3","4","?","2","3","4"],["5","6","7","8","5","6","7","8"],["9","10","11","12","9","10","11","12"],["13","14","15","?","13","14","15","16"]]return = [["1","2","3","4","1","2","3","4"],["5","6","7","8","5","6","7","8"],["9","10","11","12","9","10","11","12"],["13","14","15","16","13","14","15","16"]]The filled grids are reordered by missing value.
Example 2
packed = [["1","2","3","4"],["5","6","?","8"],["9","10","11","12"],["13","14","15","16"]]return = [["1","2","3","4"],["5","6","7","8"],["9","10","11","12"],["13","14","15","16"]]A single logical grid is filled without movement.
Constraints
1 <= k <= 1000packed.length == 4andpacked[r].length == 4k.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Bouncing Diagonal WeightsCapital One · OACapital One interview questions
- Sort Concentric Matrix Borders ClockwiseByteDance · OAByteDance interview questions
- Sort Concentric Matrix RingsxAI · OAxAI interview questions
- Minimum Cost Path with TeleportationsAmazon · OA
- Best Meeting PointWalmart · OAWalmart interview questions
- Longest Increasing Path in a MatrixNutanix · OANutanix interview questions
- Sparse Matrix Addition and MultiplicationPinterest · PHONE SCREENPinterest interview questions
- Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
- Map Black Cells to Covering 2x2 BlocksSquare · PHONE SCREEN