Skip to content

Instantly share code, notes, and snippets.

@sreeprasad
Created August 13, 2019 06:37
Show Gist options
  • Save sreeprasad/b0aac8bdc255e773efc28a1d5e48ee89 to your computer and use it in GitHub Desktop.
Save sreeprasad/b0aac8bdc255e773efc28a1d5e48ee89 to your computer and use it in GitHub Desktop.
public int moves(int N, int M) {
int x = (N+1)/2;
int result = ((x+M-1)/M)*M;
if(result>N) result = -1;
System.out.printf("%d\n", result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment