Find Valid SET Card Triples
Updated
Problem statement
Each card has four attributes: color, shape, number, and shading. Each attribute is encoded as 0, 1, or 2. You are given distinct cards in cards, where cards[i][a] is attribute a of card i.
Three cards form a valid SET if, for each of the four attributes independently, their values are either all the same or all different.
Return every valid triple of card indices [i, j, k] with i < j < k. Return triples in lexicographic order, comparing i, then j, then k. Return an empty array if no SET exists. Input cards are distinct, as in a standard deck; do not reorder them.
Function
findSets(cards: int[][]) → int[][]Examples
Example 1
cards = [[0,1,2,0],[0,0,1,1],[0,2,0,2]]return = [[0,1,2]]For each attribute, the three values are all equal or all different, so these three cards form one SET.
Example 2
cards = [[0,0,0,0],[1,1,1,1],[2,2,2,2],[0,1,2,0]]return = [[0,1,2]]The first three cards differ in every attribute. No triple containing card 3 satisfies the rule in every attribute.
Example 3
cards = [[0,0,0,0],[0,0,0,1],[0,0,1,0]]return = []Every possible triple has an attribute with exactly two equal values, so no valid SET exists.
Constraints
0 <= cards.length <= 81.- Every card has exactly
4attributes. - Every attribute is
0,1, or2. - No two cards have the same four attributes.
More Snowflake Phone Screen questions
- Design In-Memory File SystemPHONE SCREEN · Seen Nov 2026
- Merge Two Binary TreesPHONE SCREEN · Seen Nov 2026
- Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
- Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
- Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
- Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
- Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026
- Greedy Person-Cake Matching DistancePHONE SCREEN · Seen Nov 2026
- Tree Height After Child PromotionPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Count Overlapping Square PairsRamp · OARamp interview questions
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Two Tribes from Taller-Person CountsIntuit · OAIntuit interview questions
- Count One-Swap Number PairsCapital One · OACapital One interview questions
- Get Triplet CountIBM · OAIBM interview questions
- Count Reverse-Digit PairsVisa · OAVisa interview questions
- Count 2x2 Submatrices by Black CellsTikTok · OATikTok interview questions
- Get Triplet CountPoint72 · OAPoint72 interview questions
- Best Poker Category with a JokerScale AI · PHONE SCREEN · ONSITE INTERVIEWScale AI interview questions
- Find All Zip Rummy MeldsZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions