Created
May 29, 2019 06:16
-
-
Save bbagwang/a5891541fec6c408abda588b5d194882 to your computer and use it in GitHub Desktop.
Hoppoing Jack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int MaxStepHGT(int n, int k) | |
{ | |
int score = 0; | |
bool badstep = false; | |
for (int i = 0; i <= n; i++) | |
{ | |
score += i; | |
if (score == k) | |
{ | |
badstep = true; | |
} | |
} | |
if (badstep) | |
return score - 1; | |
else | |
return score; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment