Leetcode 650 Solution

This article provides solution to leetcode question 650 (2-keys-keyboard)

https://leetcode.com/problems/2-keys-keyboard

Solution

class Solution: def minSteps(self, n: int) -> int: ans = 0 m = 2 while n > 1: while n % m == 0: ans += m n //= m m += 1 return ans