Colored Cloud Statistics in a Ragged Grid
Updated
Problem statement
Given a picture grid as an array of strings, return how many clouds each color has and the size of the largest cloud.
Character '0' is sky, and each digit from '1' through '9' is a cloud color. Rows may have different lengths. Positions past the end of a shorter row count as sky.
Cells of the same color that touch horizontally or vertically belong to the same cloud. A cloud's size is its number of cells.
Return a String array with one entry "color|cloudCount" for every color present, in increasing color order. Its last entry is "MAX|largestCloudSize". If the picture has no cloud cells, return only "MAX|0".
Function
analyzeColoredClouds(grid: String[]) → String[]Examples
Example 1
grid = ["1102","11022","003"]return = ["1|1","2|1","3|1","MAX|4"]The four color-1 cells form one cloud, the three color-2 cells form one cloud, and the single color-3 cell forms one cloud. The largest size is 4.
Example 2
grid = ["101","1","1011"]return = ["1|3","MAX|3"]Missing cells in the short middle row count as sky, so the color-1 cells split into three clouds. The left column is the largest cloud, with size 3.
Example 3
grid = ["000","","00"]return = ["MAX|0"]No row contains a colored cell.
Constraints
1 <= grid.length <= 300.0 <= grid[i].length <= 300; row lengths may differ.- The total number of cells across all rows is at most
90000. - Every character is a digit from
'0'through'9'.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Render a Stable Comment HierarchyBobyard · PHONE SCREEN
- Generate All Contiguous Protein ChainsBenchling · PHONE SCREENBenchling interview questions
- Render a Comment HierarchyAmazon · ONSITE INTERVIEW
- Query Whether an Island Size ExistsMeta · ONSITE INTERVIEWMeta interview questions
- Validate BST Node DescriptionsAirbnb · OAAirbnb interview questions
- Detonate the Maximum BombsZomato / Eternal · PHONE SCREENZomato / Eternal interview questions
- Task Build Order and File-Change RerunsVanta · PHONE SCREEN
- Pairs of Songs With Total Durations Divisible by 120Cashfree Payments · PHONE SCREEN
- Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)