Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 463 Bytes

28.md

File metadata and controls

22 lines (20 loc) · 463 Bytes
int numberOfMatches(int n) {
        
        int ans=0;
        while(n!=1)
        {
            if(n%2==0)
            {
                ans+=n/2;
                n=n/2;
            }
            else
            {
                ans+=(n-1)/2;
                n=n/2 +1;
            }
        }
        return ans;
    }