As the expression "repeated twice" sound a bit pleonastic to me, I cannot help imagining different interpretations, hence different algorithms.
1. A digit that is "repeated" can be a digit that appears two times or more in the sequence, anywhere. 1, 2, 3, 4, 2, 5, 2 has 2 repeated.
1a. With the meaning of (1.), "repeated twice" would mean appearing exactly two times, anywhere. 1, 2, 3, 4, 2, 5, 6 has 2 repeated twice.
1b. But doesn't it make more sense to say that when a digit is repeated two times, that means two copies in addition to the original. Hence, three instances ! With this interpretation 1, 2, 2, 7, 2, 4, 5 has 2 repeated twice.
2. Or "repeated" can be a digit that appears two times or more in a row in the sequence. 1, 2, 2, 2, 2, 2, 4, 5 has 2 repeated.
2a. With the meaning of (2.), "repeated twice" can be appearing exactly two times in a row, not more. 1, 2, 2, 4, 5 has 2 repeated twice. 1, 2, 2, 2, 4, 5 does not have 2 repeated twice.
2b. As in (1a.), consider two extra copies. Here 1, 2, 2, 2, 4, 5 has 2 repeated twice.
2c. But don't let's forget another interpretation: some digit can be repeated, as in (1.), and this occurs twice. I.e. 1, 2, 2, 2, 4, 3, 6, 2, 2, 9 has 2 repeated twice.
The algorithms:
1a. Compute the histogram of frequencies and find the bin where frequency = 2.
1b. Compute the histogram of frequencies and find the bin where frequency = 3.
2a. Keep a counter and keep the value of the previous digit. When you process a digit, if same as previous increment the counter; otherwise { if the counter is 2, stop } and reset the counter. In the end, check if the counter is 2.
2b. Keep a counter and keep the value of the previous digit. When you process a digit, if same as previous increment the counter; otherwise { if the counter is 3, stop } and reset the counter. In the end, check if the counter is 3.
2c. The hardest: compute an histogram of digit replications while keeping a counter and the value of the previous digit. When you process a digit, if same as previous increment the counter; otherwise, { if the counter is greater than 1, increment the corresponding bin } and reset the counter. In the end, if the counter is greater than 1, increment the corresponding bin. Find the bin where frequency = 2.
Important: following this analysis, none of the solutions proposed before are correct because they accept sequences longer than twice the same character.