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.
- Lily's Homework
- Discussions
Lily's Homework
Lily's Homework
Sort by
recency
|
30 Discussions
|
Please Login in order to post a comment
Java 8 - used stream to create a set if index that are sorted.
Python
I try to find cycles by comparing the list to sorted array. i check forwards and backwards and find which one has the min. O(n log n) space, 0(n) space ` def lilysHomework(arr): # Write your code here sorted_arr = arr.copy() sorted_arr.sort() arr_map = {v: k for k, v in enumerate(sorted_arr)} visited = [0] * len(arr)
Here is HackerRank Lily's Homework problem solution in Python java c++ c and javascript
My solution only passed test case 0, 7, 10 and 11. Does anyone know why?