Block Type with the Most Children
Problem statement
Each block can be a root or a direct child of another block. Return the parent block type whose blocks collectively have the largest number of direct children.
Do not count root blocks as children. If several parent types tie, return the alphabetically smallest type. Return block_type and child_count.
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
blocks
| Column | Type | Nullable | Description |
|---|---|---|---|
| block_idPK | Integer | No | — |
| parent_block_id | Integer | Yes | — |
| block_type | Text | No | — |
Foreign key: parent_block_id → blocks(block_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| block_type | Text | No | — |
| child_count | Integer | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
parent_block_idis null only for root blocks.- At least one child block is present.
- Count only direct parent-child relationships.