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 have no clue how to do this quicker???. I computed all permutations of a N digit number if the number had a perfect square root and all the permutations which were square roots as well were added to a list.
In the end I took the largest list and printed out the largest number in the list. Complexity was O(N)+O(mk!)
where N is input. m is number of perfect squares and k! to generate all permutations of the given number in m.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #98: Anagramic squares
You are viewing a single comment's thread. Return to all comments →
My code gets timed out for testcases 5 and above.
I have no clue how to do this quicker???. I computed all permutations of a N digit number if the number had a perfect square root and all the permutations which were square roots as well were added to a list.
In the end I took the largest list and printed out the largest number in the list. Complexity was O(N)+O(mk!)
where N is input. m is number of perfect squares and k! to generate all permutations of the given number in m.