Skip to content

Instantly share code, notes, and snippets.

@Ifihan
Created April 10, 2025 21:34
Show Gist options
  • Save Ifihan/a3abd9e8b21ce7d51b6ce58ceffcf900 to your computer and use it in GitHub Desktop.
Save Ifihan/a3abd9e8b21ce7d51b6ce58ceffcf900 to your computer and use it in GitHub Desktop.
Count the Number of Powerful Integers

Question

Approach

I tired two approaches. First was brute foce (first check for the powerful integer, check if it's greater than the limit, then check if it's a suffix. This works but it doesn't scale. Then the next method I came up with was using a Queue and BFS for "prepend" and ge the candidate numbers and check. That didn't pass all testcases so I just ran to the editorial to see what they have and it was pretty interesting. Combination was my go to.

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment