One Line Java Solution


  • -10
    C
    public class Solution 
    {
        public int hammingWeight(int n) 
        {
            return Integer.bitCount(n);
        }
    }

  • 0

    Hahaha it works but why every downvoted it


  • 0
    B

    I vote for it since it is Java. Java provides better functionalities with sacrifice in efficiency.
    Why not use it if Java has done it for us?


Log in to reply
 

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