LeetCode 753: Cracking the Safe
Constant members
n and k can be constant, so long as

you remove them from being parameters to crackSafe
you add them as parameters to a constructor
the constructor uses inline initialization syntax, i.e. n(n)

Basically, your two member functions should - in their current form - be bare functions outside of a class, since the class member variables only really have transient meaning. For this to make sense as a class, n and k would only make sense as &quot;permanent&quot; attributes per instance.