#力扣 LeetCode1688. 比赛中的配对次数 @FDDLC
发布日期:2021-06-30 21:05:02 浏览次数:2 分类:技术文章

本文共 274 字,大约阅读时间需要 1 分钟。

题目描述:

 

Java代码:

class Solution {    public int numberOfMatches(int n) {        int ans=0;        while(n!=1){            ans+=n/2;            n=(n+1)/2;        }        return ans;    }}

 

Java代码二:

class Solution {    public int numberOfMatches(int n) {        return n-1;    }}

 

 

转载地址:https://liuxingchang.blog.csdn.net/article/details/116432588 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:#Java:增强for循环的小问题:值传递与引用传递 @FDDLC
下一篇:#MyBatis:Param注解 @Param #dao方法中有多个参数 @FDDLC

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年05月01日 10时26分19秒