Remove Duplicate Table Rows
Updated
Problem statement
The table items has a unique integer row_id and a non-null integer value in each row. Rows belong to the same duplicate group when their value fields are equal, even though their IDs differ.
Return the complete rows that would remain after removing duplicates: keep the row with the smallest row_id for each distinct value. Return the columns row_id and value, ordered by row_id ascending.
Your answer is the set of rows that remain. In SQL, submit one read-only SELECT query or read-only CTE. In Pandas, return a DataFrame. Do not change the input table.
| Column | Meaning |
|---|---|
row_id | Unique row identifier |
value | Integer used to identify duplicate groups |
Table schema
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.
items
Practice input table; equal value fields define duplicates.
| Column | Type | Nullable | Description |
|---|---|---|---|
| row_idPK | Integer | No | Unique row identifier. |
| value | Integer | No | Rows with the same value belong to one duplicate group. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| row_id | Integer | No | Unique row identifier. |
| value | Integer | No | Rows with the same value belong to one duplicate group. |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- For this exercise, assume
0 <= number of input rows <= 1000. 1 <= row_id <= 1000000, and every row_id is unique within the input table.-1000000 <= value <= 1000000.- Neither column contains NULL.
More JP Morgan Chase Onsite Interview questions
- LFU CacheONSITE INTERVIEW · Seen Nov 2026
- LRU CacheONSITE INTERVIEW · Seen Nov 2026
- Employees Above Average SalaryONSITE INTERVIEW · Seen Sep 2026
- Highest-Earning Employees By DepartmentONSITE INTERVIEW · Seen Sep 2026
- K Largest Integers in Descending OrderONSITE INTERVIEW · Seen Aug 2026
- Tile a Three-Row Board with DominoesONSITE INTERVIEW · Seen Jan 2026
- Two SumONSITE INTERVIEW · Seen Nov 2025
- Intersection of Two ListsONSITE INTERVIEW · Seen Jan 2025
- Maximum Subarray SumONSITE INTERVIEW · Seen Jan 2025
- Fibonacci NumberONSITE INTERVIEW · Seen Nov 2024
Similar questions at other companies
- Delete Duplicate Employee RecordsInfosys · ONSITE INTERVIEWInfosys interview questions
- Records Created or Updated in a Time WindowPelatro · ONSITE INTERVIEW
- Top Ten Employee SalariesSolytics Partners · ONSITE INTERVIEW
- Latest New JobSphere · ONSITE INTERVIEW
- Employees Whose Manager Left the CompanyZS · ONSITE INTERVIEWZS interview questions
- Retrieve Every Student RecordLSEG · ONSITE INTERVIEWLSEG interview questions
- Combine Winner and Loser NamesAmazon · ONSITE INTERVIEW
- Conditionally Insert or Update RecordsKlaviyo · ONSITE INTERVIEWKlaviyo interview questions
- Employees with Matching DepartmentsAMD · ONSITE INTERVIEWAMD interview questions
- New-User Devices That Opened an AppMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
Interview reports that mention this question
JP Morgan Chase interview experiences
- JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
- JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
- JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
- JP Morgan Chase Data and AI Intern Superday: 11 Experiences
- JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)