C# Cheating LOLOL


  • 0
    public class Solution {
        public int HammingWeight(uint n) {
            
            string s = Convert.ToString(n, 2);
            int numOnes =0;
            for(int i = 0;i<s.Length;i++)
            {
                if(s[i] == '1')
                {
                    numOnes+=1;
                }
            }
            return numOnes;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.