Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from typing import List, Union, Collection, Mapping, Optional
from abc import ABC, abstractmethod

class Solution:
def hammingWeight(self, n: int) -> int:
return bin(n).count('1')
12 changes: 12 additions & 0 deletions tests/test_150_questions_round_11/test_number_of_ones_round_11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import unittest
from src.my_project.interviews.top_150_questions_round_11\
.number_of_ones import Solution


class NumberOfOnesTestCase(unittest.TestCase):

def test_number_of_ones(self):
solution = Solution()
output = solution.hammingWeight(n=11)
target = 3
self.assertEqual(output, target)
Loading