Miller-Rabin Primality Test and Caching III

Another application of MRP with caching. The caveat here is that using BigInteger implementation of MRP Test leads to TLE. Converting to Long does the trick. There is still usage of BigInteger for modular exponentiation (otherwise you'd have to implement your own, which can be a little tricky), but that doesn't seem to add much overhead to the solution. It is also interesting to use OpenAI ChatGPT 4.0 model to ask and learn for the detailed time complexity of this algorithm. It is amazing to see how fast MPR is - an impressive LogN. Answer from the bot is down below, as well s my code. Cheers, ACC. Analysis from OpenAI ChatGPT Model 4.0: Time Complexity: 🔸 Worst Case: O(n² log m) (where m is the largest number formed from the substring) 🔸 With caching and typical inputs, it behaves closer to O(n²) . Sum of Largest Prime Substrings - LeetCode Given a string s , find the sum of the 3 largest unique prime numbers that can be formed using any of its subs...