[Leet Code] Countings bits

Input: 2
Output: [0,1,1]
Input: 5
Output: [0,1,1,2,1,2]
class Solution(object):
def countBits(self, num):
:type num: int
:rtype: List[int]
answer = []
for i in range(num+1):
binAnswer = list((format(i, "b")))
return answer




Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.

22 steps to reduce your AWS bill (Part 4— Networking)

Securely run Jupyter Notebook on desktop/server and access remotely with laptop — SSH

How to Get More Views for Your YouTube Channel Using ManyChat Bot + Integromat

University Management System Project in Python

The Noob’s approach !

The Four Pillars of Object Oriented Programming

CodeIgniter 4 Query Builder where() function and parameter structure with MySQL

The Unknown Unknowns in an Enterprise Digital Transformation

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew Boyd

Matthew Boyd

Learning, and posting my findings!

More from Medium


Merge Sorted Array🐧

Remove Duplicates from Sorted Array — LeetCode

13. Roman To Integer — Leetcode