+ 1

Suggest Method To reduce Time complexivity of this code

The resulting sequence is (0,0,1,0,2,0,2,2,1,…): the second element is 0 since 0 occurs only once in the sequence (0), the third element is 1 since the distance between the two occurrences of 0 in the sequence (0,0) is 1, the fourth element is 0 since 1 occurs only once in the sequence (0,0,1), and so on. Consider the N-th element of the sequence (denoted by x) and the first N elements of the sequence. Find the number of occurrences of x among these N elements. https://code.sololearn.com/cU1YVd4Aye05/?ref=app

2nd Nov 2019, 2:08 PM
Sgk101
Sgk101 - avatar
0 ответов