We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #25: N-digit Fibonacci number
  4. Discussions

Project Euler #25: N-digit Fibonacci number

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • SOKS33
    5 years ago+ 4 comments

    Can easily be done using Python in ~3s for each TC without caring about integer length (because this is PAINFUL):

    Memoization is the key here: Precompute fibonacci until you reach a number with 5000 digits DON'T SAVE ALL FIBO NUMBERS Save the fibo index each time you increase the max size You now have an array of 5000 elements (each containing the right index) in about 3 seconds

    Hint : Use string length while searching for integer length

    for each test case, just print array[test_case]

    5|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature