Google L4 round 3 question
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-05-09Added By Anonymous
Source: Link
1You're given an array of size 14. You need to determine if the array is "gold".
2What does "gold" mean?
3You must use all 14 numbers exactly once.
4
5There must be:
61 pair (two identical numbers),
74 sets, where each set is either:
8A triplet of identical numbers [x, x, x], OR
9A consecutive increasing triplet [x, x+1, x+2].
10
11🧪 Step 2: Try Examples and Work Through
12✅ Example 1:
13
14nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9]
15Let's try to divide this:
16
17Pair: [1, 1]
18
19Set 1: [2, 2, 2] — triplet
20Set 2: [3, 3, 3] — triplet
21Set 3: [4, 5, 6] — consecutive
22Set 4: [7, 8, 9] — consecutive
23
24✅ Yes, this array is "gold".
25
26follow up - So instead of 14 number you are given 13 number ,
27
28You return -1 if you cannot enter any number to make it golden array, and if you can return the number itself.