saptarshisarkar20 / Hacktoberfest2023

This repo is for participating into the Hacktoberfest 2023
35 stars 196 forks source link

Counting Bits - Problem Solving #72

Open saptarshisarkar20 opened 11 months ago

saptarshisarkar20 commented 11 months ago

What to Do?

Star 🌟 the repo Fork 🌿 the repo Location Go to folder Pull Here/LeetCode/CountingBits

File name Take your GitHub username id like "hrithik339", "hacker-boy", etc or anything which you have. Then add a programming language extension after this (link for C++ add .cpp and for python add.py) Only files with the correct file name will be accepted


Problem Statement

Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.

Example 1:

Input: n = 2 Output: [0,1,1]

Explanation: 0 --> 0 1 --> 1 2 --> 10

Example 2:

Input: n = 5 Output: [0,1,1,2,1,2]

Explanation: 0 --> 0 1 --> 1 2 --> 10 3 --> 11 4 --> 100 5 --> 101

Constraints:

0 <= n <= 105

Follow up:

It is very easy to come up with a solution with a runtime of O(n log n). Can you do it in linear time O(n) and possibly in a single pass? Can you do it without using any built-in function (i.e., like __builtin_popcount in C++)?

Function

class Solution {
public:
    vector<int> countBits(int n) {

    }
};
class Solution:
    def countBits(self, n: int) -> List[int]:
class Solution {
    public int[] countBits(int n) {

    }
}
RashiJyotishi commented 11 months ago

please assign this issue to me.

aditi10701 commented 11 months ago

Please assign this to me

Shikhar007-bot commented 11 months ago

hey saptarshisarkar20 can you please assign this to me

sdas2k3 commented 11 months ago

Hey @saptarshisarkar20 I want to work on this issue...Please assign this issue to me

Shankhadweep commented 11 months ago

@saptarshisarkar20 I want to work on this issue...Please assign this to me

Ashima2003 commented 11 months ago

I wish to contribute. Kindly assign me this issue.

sethisagar commented 11 months ago

I want to contribute. Kindly assign me this issue.

DebapriyaJha commented 11 months ago

Hello, I'm relatively new to open source and GitHub. I'm eager to learn and improve my skills, and I believe working on this issue will be a valuable experience for me. could you please assign it to me

DebapriyaJha commented 11 months ago

I have solved the problem with all the given requirements. Please @saptarshisarkar20 review my code and suggest any changes that need to be done and accept my PR under the Hacktoberfest 2023 tag.

anshul-132002 commented 11 months ago

Kindly assign this task to me...

harshal8869 commented 11 months ago

I want to work on this issue . Kindly assign this task to me.

mehakbasrani commented 11 months ago

Please assign it to me

vivek5200 commented 11 months ago

Hey @saptarshisarkar20 , I am eager to contribute to the Counting Bits problem and request access to the respective repository. I am well-versed in dynamic programming and eager to provide valuable insights. Please assign Me to this Problem.

shaman-004 commented 11 months ago

i want to contribute pls assign this to me

Preetam-Das26 commented 10 months ago

Hi I want to contribute to this issue.

jannnniik commented 10 months ago

Hello i would like to work on this problem would be nice if you could ad me to the assigment

mallikarjuna4406 commented 10 months ago

hi saptarshisarkar20, can you please assign this to me?

udaygarg8188 commented 10 months ago

Hi, can you please assign this to me?