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.
I think that your space complexity is not O(1) but O(n) because you are creating an array of size n which is not given in the input. So, you are basically creating an array for solving your question, so the auxilliary time complexity is O(n). Please correct me if I am wrong!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
I think that your space complexity is not O(1) but O(n) because you are creating an array of size n which is not given in the input. So, you are basically creating an array for solving your question, so the auxilliary time complexity is O(n). Please correct me if I am wrong!