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.
- New Year Chaos
- Discussions
New Year Chaos
New Year Chaos
Sort by
recency
|
32 Discussions
|
Please Login in order to post a comment
Required knowladge: Inversions This question requires a rare topic, that I think is very unlikely to come up in interwies. Again a not so great questions for the 3 month prep pack.
kudos to the author of this site https://csanim.com/tutorials/hackerrank-solution-new-year-chaos
realy help me with optimized solution
Here are some hints for optimizing the code: 1. start by checking for too much chaos at the start of your loop through q 2. check for how many values skipped in front of each sticker. limiting the section checked to only 2 places in front or less.
Python 3 O(n) solution: Utilized sorting and then a dictionary for quick lookups:
How can the expected output from this q be 7?
q = [1, 2, 5, 3, 7, 8, 6, 4]