Is 213ms (Java) acceptable?

  • 0

    I am new to Leetcode and actually I am new to programming. My solution to this question (one-bit) by Java costs 213ms. Is it considered acceptable or very slow? Leetcode provide a statistical graph showing ~99% of submissions work faster than mine. :(

    Thank you and my code is below.

    public class Solution {

    public int hammingWeight(int n) {
    	int count = 0;
    	while (n != 0) {
    		n = (n & (n - 1));
    	return count;


Log in to reply

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