Reddit Question · Mar 2026

AWS coding interview from last year; Claude can't solve

69 upvotes 50 replies

Question Details

I failed my Amazon interview two years ago, but the coding question they asked kept bothering me afterward. During the interview, I tried to solve it using graph algorithms, which made it complicated.

Full Details

I failed my Amazon interview two years ago, but the coding question they asked kept bothering me afterward. During the interview, I tried to solve it using graph algorithms, which made it complicated. Later, I realized the solution was actually much simpler. Recently, I asked Claude the same question, but it still couldn’t arrive at the correct solution, which I found surprising. Here’s the problem—try solving it yourself and let me know whether Claude handled it efficiently. >## The Letter Set Reduction Problem >You are given a multiset of letters (a collection where duplicates are allowed), >and you want to reduce it to empty using two rules: >Rule 1 — Pair removal: If the multiset contains at least two copies of the same >letter, you may remove both. >e.g. {B, B} → {} >Rule 2 — Triple removal: If the multiset contains three consecutive letters, >you may remove all three. >e.g. {B, C, D} → {} > >You may apply the rules in any order, any number of times.

Return true if the >multiset can be reduced to empty, false otherwise. > >### Worked Example: {A, B, B, C, C, D} >One valid solution path: >{A, B, B, C, C, D} >→ apply Rule 2: remove {A, B, C} → {B, C, D} >→ apply Rule 2: remove {B, C, D} → {} ✅ >Another valid path: {A, B, B, C, C, D} → apply Rule 1: remove {B, B} → {A, C, C, D} → apply Rule 1: remove {C, C} → {A, D} → stuck ❌ (this path fails, but the answer is still true because the first path succeeded) >This illustrates that order matters — a wrong choice can lead to a dead end, >but as long as at least one path reaches empty, the answer is true. > >### Smaller Examples >{B, B} → true (remove pair {B,B} → empty) >{B, C, D, F, F} → true (remove triple {B,C,D} -> remove pair {F, F} → empty) >{A, B} → false (no rule able to reduce it to empty) >{A, C} → false (no rule will reduce it to empty) > >###

Constraints >- Letters are from A to Z >- The multiset can contain any number of letters >- You may apply the rules in any order you choose >- Both rules require the exact letters to be present in the multiset at the time of removal >Question Write a function reducible(multiset) that returns true if the multiset can be fully reduced to empty, and false otherwise.

UPDATE: I provided a spoiler hints in the comments. I feel like my job is safe - at least for now lol. Please let me know if Claude or any other ai gave the correct linear time solution without you providing it with a hint. Thank you all.

About This Question

This is a reported interview question from a amazon interview for a swe role during the coding round reported in 2026.

It covers the following topics: Graph .

Topics