Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codility Frog River One
#2
I don't know what the task is, but a few things:

1. What's the worst case complexity for len(A)? If it's expensive, do you need to do it 3 times?

2. Remember that searching a list is linear, so doing that on each iteration of the loop (line 7) will be expensive as n grows. Does river need to be a list? If so, you might additionally want to keep the items in a set that you just use for keeping track of which items you've seen, since lookup in a set is done in constant time.
Reply


Messages In This Thread
Codility Frog River One - by Westerner - Jan-09-2021, 06:49 AM
RE: Codility Frog River One - by ndc85430 - Jan-09-2021, 07:27 AM
RE: Codility Frog River One - by deanhystad - Jan-09-2021, 06:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Frog Puzzle Random To Custom MoreMoney 4 655 Mar-26-2024, 08:38 AM
Last Post: MoreMoney
  Codility Binary Gap Exercise Westerner 2 1,886 Jan-08-2021, 09:20 PM
Last Post: Westerner

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020