Checking Permutation Existence in Factorial Sum

🚀 Day 31 / 100 | Check Digitorial Permutation -Intuition: Permutation does not change the factorial sum. So instead of checking all permutations, compute the factorial sum once and check if its digits are the same as the original number’s digits. If both have same digits ,permutation exists and answer is true. -Approach: O(n) Check factorial for each digit. Traverse the number and calculate sum of factorial of digits. Store original number separately. Now compare digit frequency of original number and factorial sum If frequencies match ,return true Else, return false -Complexity: Time Complexity: O(n) n->number of digits in num. Space Complexity: O(1) #100DaysOfCode #Java #DSA #LeetCode

  • text

To view or add a comment, sign in

Explore content categories