FastPrepUsers Active in Both January and February
Problems/Users Active in Both January and February

Users Active in Both January and February

Mygate logoMygate● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Mygate phone screen for a full-time role. The task is to find users who were active in both January and February. The report leaves out the year, the activity schema, and the result rules. We filled those in.

Our version is about 90% the same as the reported question.

The activity table records user activity events. Each row counts as one activity, and activity_date is a calendar date with no time or timezone conversion.

Find every user who has at least one activity in January 2025 and at least one activity in February 2025. Return one user_id row per qualifying user, sorted by user_id in ascending order.

Repeated events on the same date count as activity, but must not create duplicate result rows. Activity outside those two months, including the same months in another year, does not 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.

activity

One row per user activity event.

ColumnTypeNullableDescription
event_idPKIntegerNo—
user_idIntegerNo—
activity_dateDateNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
user_idIntegerNo—

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

Constraints

  • The table contains between 0 and 10^4 rows.
  • event_id is unique and between 1 and 10^9.
  • user_id is an integer between 1 and 10^9.
  • activity_date is a valid date between 2020-01-01 and 2030-12-31.

More Mygate Phone Screen questions

  • Employees Earning More Than Their ManagerPHONE SCREEN · Seen Sep 2026
  • Maximum Subarray SumPHONE SCREEN · Seen Sep 2026
  • Reverse a Linked ListPHONE SCREEN · Seen Sep 2026
  • Elements Occurring More Than n/3 TimesPHONE SCREEN · Seen Jan 2025
  • Frog Jump: Minimum EnergyPHONE SCREEN · Seen Jan 2025
  • Left View of a Binary TreePHONE SCREEN · Seen Jan 2025
  • Two SumPHONE SCREEN · Seen Aug 2024
  • Minimum in a Rotated Sorted ArrayPHONE SCREEN · Seen Jul 2024
  • Minimum Subarray SumPHONE SCREEN · Seen Sep 2023
  • Remove the Nth Node from the EndPHONE SCREEN · Seen Sep 2023

Similar questions at other companies

  • Second Highest SalaryPaytm · PHONE SCREENPaytm interview questions
  • Employees Who Earn More Than Their ManagersNykaa · PHONE SCREENNykaa interview questions
  • Employees Who Joined More Than a Week AgoNewgen Software · PHONE SCREEN
  • Departments Without EmployeesDell Technologies · PHONE SCREENDell Technologies interview questions
  • Second-Highest Distinct SalaryChubb · PHONE SCREENChubb interview questions
  • Swap Two Gender ValuesInfosys · PHONE SCREENInfosys interview questions
  • Find Rows Common to Two TablesSalesforce · PHONE SCREENSalesforce interview questions
  • Count Records Present in A but Not BCapital One · PHONE SCREENCapital One interview questions
  • Customer Order Count Distribution by CountryApple · PHONE SCREENApple interview questions
  • Classify Tree Nodes with SQLOracle · PHONE SCREENOracle interview questions
All Mygate interview questionsSee Mygate hiring insights