Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. Read a list of integers and find the longest sequence of equal elements. If several exist, print the leftmost.
  2. Examples
  3. Input Output
  4. 3 4 4 5 5 5 2 2 5 5 5
  5. 7 7 4 4 5 5 3 3 7 7
  6. 1 2 3 3 3 3
  7. Hints
  8. • Scan positions p from left to right and keep the start and length of the current sequence of equal numbers ending at p.
  9. • Keep also the currently best (longest) sequence (bestStart + bestLength) and update it after each step.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement