saptarshisarkar20 / Hacktoberfest2023

This repo is for participating into the Hacktoberfest 2023
34 stars 195 forks source link

Counting Bits - Problem Solving #72

Open saptarshisarkar20 opened 1 year ago

saptarshisarkar20 commented 1 year 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 1 year ago

please assign this issue to me.

aditi10701 commented 1 year ago

Please assign this to me

Shikhar007-bot commented 1 year ago

hey saptarshisarkar20 can you please assign this to me

sdas2k3 commented 1 year ago

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

Shankhadweep commented 1 year ago

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

Ashima2003 commented 1 year ago

I wish to contribute. Kindly assign me this issue.

sethisagar commented 1 year ago

I want to contribute. Kindly assign me this issue.

DebapriyaJha commented 1 year 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 1 year 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 1 year ago

Kindly assign this task to me...

harshal8869 commented 1 year ago

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

mehakbasrani commented 1 year ago

Please assign it to me

vivek5200 commented 1 year 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 1 year ago

i want to contribute pls assign this to me

Preetam-Das26 commented 1 year ago

Hi I want to contribute to this issue.

jannnniik commented 1 year ago

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

mallikarjuna4406 commented 1 year ago

hi saptarshisarkar20, can you please assign this to me?

udaygarg8188 commented 1 year ago

Hi, can you please assign this to me?