FastPrepCountry with the Most Events

Country with the Most Events

Notion logoNotion● MediumFULLTIMEPHONE SCREEN

Problem statement

Given user locations and an event log, return the country associated with the largest number of events.

Count every event. If several countries tie, return the alphabetically smallest country. Return exactly the columns country and event_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.

users

ColumnTypeNullableDescription
user_idPKIntegerNo—
countryTextNo—

events

ColumnTypeNullableDescription
event_idPKIntegerNo—
user_idIntegerNo—
event_typeTextNo—
event_timeTimestampNo—

Foreign key: user_id → users(user_id)

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
countryTextNo—
event_countIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • Every event references one listed user.
  • At least one event is present.
  • Country names compare by their stored case-sensitive text.

More Notion problems

See Notion hiring insights