By: Iliya Yordanov on: Mon 04 of Sep, 2006 [09:53 UTC] (15739 reads)
|
Contest 9: Digits Distance
Difficulty: Beginner
Time frame: 4 Sept - 22 Sept - 2006
Status: Finished
Winners: Sean and Christoffer
|
|
(4415 bytes)
|
|
 |
Contest 9: Digits Distance
Difficulty: Beginners
Time Frame: 4 Sept -22 Sept - 2006
Status: Finished.
Managed by: Iliya Yordanov
Participants - 26 |
Problem
You will be given a string, which will look like that:
700056750753
Your task will be to find the longest distance between two equal digits. In this example. The distance is measured by the number of digits- for example, the distance between the first and the fourth digits is 2 (digit 2 and digit 3).
In the example above, the longest distance is between the first 7 and the 10th 7, with a distance of 8 digits, i.e. the number of digits between the 1st and the 10th 7s.
Note:
- Consider the input is always valid, and there is at least two equal digits.
- If you have input like 1111111 then the distance is the number of digits between the first and the last digit.
Discuss Contest 9 in the forums
Submission information:
Optimize for: speed
Function prototype (you must have that function!): public static long Contest9(String sequence);
Send only the function (and all helper functions, if any), to:admin@csharp-home.com
Write this as subject in your e-mail: Contest 9 Solution
End date: 22 Sept 2005 , 19:00h GMT Time
Results:
Winners: Sean and Christoffer
2nd place: aligokalppeker
View all results and source code here
See tests: here
Discuss Contest 9's results in the forums
If you have any questions and/or comments, please, send them to admin@csharp-home.com