Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to represent the current (N, K) in terms of some (N-1, prevK). What is prevK ?
Solve with full IDE support and test cases