5
Answers

Detecting Cycles

Ankit Gupta

Ankit Gupta

12y
1.9k
1

Given a sequence, write a program to detect cycles within it.


A file containing a sequence of numbers (space delimited). The file can have multiple such lines. e.g

2 0 6 3 1 6 3 1 6 3 1
Ensure to account for numbers that have more than one digit eg. 12. If there is no sequence, ignore that line.
Print to stdout the first sequence you find in each line. Ensure that there are no trailing empty spaces on each line you print. e.g.
6 3 1
help me please.....!!
Answers (5)
Next Recommended Forum