This is a verified interview question from Adobe. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "The Pair Sum (Easy Version) - Adobe Hackathon 2026" covers key patterns like Arrays.
"You are given two lists of commits from different branches of a version control system. Each commit in the lists consists of a commit ID, a timestamp, and a status indicating whether the commit was successful (status 1) or unsuccessful (status 0). Your task is to merge the commits from both lists into a single list, ensuring that: 1. Only successful commits are included in the merged list. 2. Commits should be sorted according to their timestamp. 3. If two commits have the same timestamp, commits from the first list should appear first. Your task is to merge the commits according to the rules above, and print the commit IDs of the merged commits in sorted order based on their timestamps. ### **Input Format** * The first line of the input contains an integer **N1** denoting the number of commits in the first list. * The next **N1** lines each contain a string **commitID**, an integer **timestamp**, and an integer **status**, separated by spaces. * The next line of the input contains an integer **N2** denoting the number of commits in the second list. * The next **N2** lines each contain a string **commitID**, an integer **timestamp**, and an integer **status**, separated by spaces. ### **Output Format** Print the commit IDs of merged commits one per line, in sorted order based on timestamp. ### **Constraints** * 1 <= (N1, N2) <= 10^2 * 1 <= Timestamps <= 10^3 * 1 <= |Commit IDs| < 10^3 --- ### **Sample Testcase 1** **Input** ```text 3 b8a5gt 1000 1 cd54yt 1500 1 kl35nv 1500 0 2 v4ui6b 1000 1 pw2bud 500 1 ``` **Output** ```text pw2bud b8a5gt v4ui6b cd54yt ``` **Explanation** In the lists provided above, we observe one failed commit with ID kl35nv. This commit is not considered in the final list of commits. The remaining commits are sorted based on their timestamps: pw2bud (500) comes before b8a5gt and v4ui6b (1000), and both b8a5gt and v4ui6b precede cd54yt (1500). Between b8a5gt and v4ui6b, although they share similar timestamps, b8a5gt originates from the first list, so it is placed before v4ui6b. Hence, the final list is pw2bud -> b8a5gt -> v4ui6b -> cd54yt. --- ### **Sample Testcase 2** **Input** ```text 4 rw1ts6 900 1 cc9n7r 1200 1 kp0zw3 700 0 y5bnm8 2000 1 4 rzq3dx 700 1 u521nc 1200 0 b8po89 4000 1 rw6cvz 800 1 ``` **Output** ```text rzq3dx rw6cvz rw1ts6 cc9n7r y5bnm8 b8po89 ``` **Explanation** In the lists provided above, we observe failed commits with ID kp0zw3 and u521nc. These commits will not be considered in the final list of commits. The remaining commits are sorted based on their timestamps: rzq3dx (700) < rw6cvz (800) < rw1ts6 (900) < cc9n7r (1200) < y5bnm8 (2000) < b8po89 (4000). Between cc9n7r and u521nc, although they share similar timestamps, cc9n7r originates from the first list, so it is placed before u521nc but u521nc is not considered because it is a failed commit. Hence, the final list is rzq3dx -> rw6cvz -> rw1ts6 -> cc9n7r -> y5bnm8 -> b8po89. "
Join thousands of developers practicing for Adobe.