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.
After some light research, it seems like SparseArrays are a memory lighter alternative to HashMaps in a subset of circumstances. However, HashMaps are faster and work for larger collections. I have no idea how to use SparseArrays, and since I already know how to use HashMaps, I also found the problem rather easy. I'm a little surprised the O(n^2) loop worked, but that's exactly the reason I came here (because at 1000x1000 it seemed feasible). This problem could use some improvement. Rather than re-classifying the difficulty, the problem statement and test cases should be improved to better illustrate the point, which may also raise the difficulty and block out the brute force method. Additionally, the problem statement would probably need to block the use of HashMaps, again, to illustrate the lesson on using SparseArrays.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →
After some light research, it seems like SparseArrays are a memory lighter alternative to HashMaps in a subset of circumstances. However, HashMaps are faster and work for larger collections. I have no idea how to use SparseArrays, and since I already know how to use HashMaps, I also found the problem rather easy. I'm a little surprised the O(n^2) loop worked, but that's exactly the reason I came here (because at 1000x1000 it seemed feasible). This problem could use some improvement. Rather than re-classifying the difficulty, the problem statement and test cases should be improved to better illustrate the point, which may also raise the difficulty and block out the brute force method. Additionally, the problem statement would probably need to block the use of HashMaps, again, to illustrate the lesson on using SparseArrays.