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.
For those getting failures in testcase #7, #8, #9 and using Java,
try thinking about the number of times you really need to rotate and limit your algorithm EVERYWHERE for it. There is enough hint in the other comments- mostly regarding modulo.
I figured I needed to limit when I got the timeouts and I tried with modulo. What I didn't realize was that inspite of using modulo deep within my code, I still had code that was executing unnecessarily from one of the parent loops.
If you have all the other cases passing, the only way to get through #7,#8,#9 is optimize optimize optimize.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Matrix Layer Rotation
You are viewing a single comment's thread. Return to all comments →
For those getting failures in testcase #7, #8, #9 and using Java, try thinking about the number of times you really need to rotate and limit your algorithm EVERYWHERE for it. There is enough hint in the other comments- mostly regarding modulo.
I figured I needed to limit when I got the timeouts and I tried with modulo. What I didn't realize was that inspite of using modulo deep within my code, I still had code that was executing unnecessarily from one of the parent loops.
If you have all the other cases passing, the only way to get through #7,#8,#9 is optimize optimize optimize.