FastPrepSuccessful Logins from Multiple Countries

Successful Logins from Multiple Countries

Marshall Wace logoMarshall Wace● EasyFULLTIMEOA

Problem statement

You are given a table login_attempts with columns user_id (text), timestamp (timestamp), status (text), and country (text).

Return the users who have at least one SUCCESS login from each of at least two different countries. Only successful logins count, and repeated logins from one country still count as one country.

The result must have exactly one column named user_id, sorted alphabetically, with each qualifying user returned once. Consider every input row; there is no time-window filter.

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.

login_attempts

ColumnTypeNullableDescription
user_idTextNo—
timestampTimestampNo—
statusTextNo—
countryTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
user_idTextNo—

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

Constraints

  • The table contains between 0 and 1000 rows. Duplicate rows are allowed.
  • All input values are non-null.
  • User IDs contain only lowercase English letters. Countries are represented by two uppercase English letters.
  • status is either SUCCESS or FAILURE. Timestamps are valid timestamps and do not affect qualification.

More Marshall Wace problems

See Marshall Wace hiring insights