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
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Functional Programming
  3. Recursion
  4. String Mingling
  5. Discussions

String Mingling

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • abhiranjan
    Challenge Author
    6 years ago+ 0 comments

    @serhii_nesteruk, :: has constant complexity, while ++ is linear.

    In your code you are applying ++ n times. First on the list of length 1, then 2, then 3, and so on. So overall complexity will be

    O(1) + O(2) + ... + O(n-1) ~= O(n^2)
    
    0|
    ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature