首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
比特位计数
[编程题]比特位计数
热度指数:120
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个非负整数
num
。对于
0 ≤ i ≤ num
范围中的每个数字
i
,计算其二进制数中的 1 的数目并将它们作为数组返回。
示例1
输入
2
输出
[0,1,1]
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(1)
分享
纠错
提交结果有问题?
0个回答
1篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
C++工程师
2020
映客
Java工程师
上传者:
小小
难度:
0条回答
1收藏
2942浏览
热门推荐
通过挑战的用户
牛客18326...
2023-02-09 16:44:35
菲尼克斯弗兰克
2022-07-19 13:06:14
廖佳庆
2022-07-15 12:21:30
牛客47310...
2022-07-09 00:55:44
mhn
2022-07-07 09:45:02
相关试题
看图回答
判断推理
2020
人力资源
安永
审计
税务服务
风险管理
管理咨询
行政管理
评论
(1)
来自
职能类模拟题2
以下代码的运行结果为():#inc...
算法工程师
映客
2020
评论
(2)
假定所有变量均已正确定义,则下列程...
算法工程师
映客
2020
评论
(0)
模型稀疏化(Pruning)技术主...
大模型概念
评论
(1)
以下哪种方法主要用于缓解大模型训练...
大模型概念
评论
(1)
比特位计数
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * * @param num int整型 * @return int整型一维数组 */ public int[] countBits (int num) { // write code here } }
class Solution { public: /** * * @param num int整型 * @return int整型vector */ vector
countBits(int num) { // write code here } };
# # # @param num int整型 # @return int整型一维数组 # class Solution: def countBits(self , num ): # write code here
/** * * @param num int整型 * @return int整型一维数组 */ function countBits( num ) { // write code here } module.exports = { countBits : countBits };
# # # @param num int整型 # @return int整型一维数组 # class Solution: def countBits(self , num ): # write code here
2
[0,1,1]