Skip to content

Commit

Permalink
1688
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 29, 2022
1 parent 4a25131 commit 9921a63
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions E_1688_CountofMatchesinTournament.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class Solution {
public int numberOfMatches(int n) {
int matches = 0;
while(n!=1) {
if (n % 2 == 0) { //çiftse
n = n / 2;
matches += n;

} else { //tekse
n = ((n - 1) / 2);
matches += n;
n = n + 1;
}
}
return matches;
}
}

0 comments on commit 9921a63

Please sign in to comment.