Loading problem...
A civic analytics team maintains a two-column lookup table that records which cities belong to which states.
Table:
Your task is to build a filtered state-level summary.
For each state, compute:
Include only states that satisfy both:
Return columns in this exact order:
Sort the final result by:
Supported submission environments:
Cities:
| state | city |
|----------|------------|
| Asteria | Afton |
| Asteria | Arbor |
| Asteria | Apex |
| Asteria | Bayview |
| Borealis | Brookline |
| Borealis | Bridgeport |
| Borealis | Belltown |
| Borealis | Cedarfield |
| Cascade | Dover |
| Cascade | Elmwood |
| Cascade | Fairview |[
{"state":"Asteria","cities":"Afton, Apex, Arbor, Bayview","matching_letter_count":3},
{"state":"Borealis","cities":"Belltown, Bridgeport, Brookline, Cedarfield","matching_letter_count":3}
]Cascade has enough cities but no city starts with C, so it is excluded.
Cities:
| state | city |
|----------|------------|
| Elmstate | Eden |
| Elmstate | Eastgate |
| Elmstate | Everly |
| Elmstate | Harborview |
| Fjord | Falcon |
| Fjord | Flint |
| Fjord | Forest |
| Fjord | Granite |
| Galena | Grove |
| Galena | Garden |
| Galena | Hillside |[
{"state":"Elmstate","cities":"Eastgate, Eden, Everly, Harborview","matching_letter_count":3},
{"state":"Fjord","cities":"Falcon, Flint, Forest, Granite","matching_letter_count":3},
{"state":"Galena","cities":"Garden, Grove, Hillside","matching_letter_count":2}
]Elmstate and Fjord tie on matching count, so state name ascending is used.
Cities:
| state | city |
|---------|-----------|
| nova | Nexus |
| nova | Nadir |
| nova | Northbay |
| nova | Aurora |
| Orchid | Opal |
| Orchid | Olive |
| Orchid | Maple |
| Prairie | Pine |
| Prairie | Quartz |[
{"state":"nova","cities":"Aurora, Nadir, Nexus, Northbay","matching_letter_count":3},
{"state":"Orchid","cities":"Maple, Olive, Opal","matching_letter_count":2}
]Initial-letter matching is case-insensitive, so lowercase state names still match uppercase city initials.
Constraints