File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 11| 题目 | 题解 | 难度 | 推荐指数 |
22| ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | -------- |
3- | [ 90. 子集 II] ( https://leetcode-cn.com/problems/subsets-ii/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/subsets-ii/solution/gong-shui-san-xie-yi-ti-shuang-jie-hui-s-g77q/ ) | 中等 | 🤩🤩🤩🤩 |
43| [ 137. 只出现一次的数字 II] ( https://leetcode-cn.com/problems/single-number-ii/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/single-number-ii/solution/gong-shui-san-xie-yi-ti-san-jie-ha-xi-bi-fku8/ ) | 中等 | 🤩🤩🤩 |
54| [ 190. 颠倒二进制位] ( https://leetcode-cn.com/problems/reverse-bits/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/reverse-bits/solution/yi-ti-san-jie-dui-cheng-wei-zhu-wei-fen-ub1hi/ ) | 简单 | 🤩🤩🤩 |
65| [ 191. 位1的个数] ( https://leetcode-cn.com/problems/number-of-1-bits/ ) | [ LeetCode 题解链接] ( https://leetcode-cn.com/problems/number-of-1-bits/solution/yi-ti-san-jie-wei-shu-jian-cha-you-yi-to-av1r/ ) | 简单 | 🤩🤩🤩 |
Original file line number Diff line number Diff line change @@ -41,10 +41,10 @@ Tag : 「位运算」
4141
4242### 「位数检查」解法
4343
44- ![ image.png] ( https://pic.leetcode-cn.com/1616375441-WGCssd-image.png )
45-
4644一个朴素的做法是,对 ` int ` 的每一位进行检查,并统计 $1$ 的个数。
4745
46+ ![ image.png] ( https://pic.leetcode-cn.com/1616375441-WGCssd-image.png )
47+
4848代码:
4949``` Java []
5050public class Solution {
@@ -64,8 +64,6 @@ public class Solution {
6464
6565### 「右移统计」解法
6666
67- ![ image.png] ( https://pic.leetcode-cn.com/1616375636-fXCFNF-image.png )
68-
6967对于方法一,即使 $n$ 的高位均为是 $0$,我们也会对此进行循环检查。
7068
7169因此另外一个做法是:通过 ` n & 1 ` 来统计当前 $n$ 的最低位是否为 $1$,同时每次直接对 $n$ 进行右移并高位补 0。
@@ -74,6 +72,8 @@ public class Solution {
7472
7573这样的做法,可以确保只会循环到最高位的 $1$。
7674
75+ ![ image.png] ( https://pic.leetcode-cn.com/1616375636-fXCFNF-image.png )
76+
7777代码:
7878``` Java []
7979public class Solution {
@@ -124,10 +124,10 @@ public class Solution {
124124
125125### 「分组统计」解法
126126
127- ![ image.png] ( https://pic.leetcode-cn.com/1616378128-yBWadF-image.png )
128-
129127以上三种解法都是 $O(k)$ 的,事实上我们可以通过分组统计的方式,做到比 $O(k)$ 更低的复杂度。
130128
129+ ![ image.png] ( https://pic.leetcode-cn.com/1616378128-yBWadF-image.png )
130+
131131代码:
132132``` Java []
133133public class Solution {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Tag : 「位运算」、「分治」
2323输入:11111111111111111111111111111101
2424输出:31
2525解释:输入的二进制串 11111111111111111111111111111101 中,共有 31 位为 '1'。
26- ```
26+ ```
2727
2828提示:
2929* 输入必须是长度为 32 的 二进制串 。
@@ -32,10 +32,10 @@ Tag : 「位运算」、「分治」
3232
3333### 「位数检查」解法
3434
35- 
36-
3735一个朴素的做法是,对 ` int ` 的每一位进行检查,并统计 $1$ 的个数。
3836
37+ ![ image.png] ( https://pic.leetcode-cn.com/1616375441-WGCssd-image.png )
38+
3939代码:
4040``` Java []
4141public class Solution {
@@ -55,8 +55,6 @@ public class Solution {
5555
5656### 「右移统计」解法
5757
58- ![ image.png] ( https://pic.leetcode-cn.com/1616375636-fXCFNF-image.png )
59-
6058对于方法一,即使 $n$ 的高位均为是 $0$,我们也会对此进行循环检查。
6159
6260因此另外一个做法是:通过 ` n & 1 ` 来统计当前 $n$ 的最低位是否为 $1$,同时每次直接对 $n$ 进行右移并高位补 0。
@@ -65,6 +63,8 @@ public class Solution {
6563
6664这样的做法,可以确保只会循环到最高位的 $1$。
6765
66+ ![ image.png] ( https://pic.leetcode-cn.com/1616375636-fXCFNF-image.png )
67+
6868代码:
6969``` Java []
7070public class Solution {
@@ -115,10 +115,10 @@ public class Solution {
115115
116116### 「分组统计」解法
117117
118- ![ image.png] ( https://pic.leetcode-cn.com/1616378128-yBWadF-image.png )
119-
120118以上三种解法都是 $O(k)$ 的,事实上我们可以通过分组统计的方式,做到比 $O(k)$ 更低的复杂度。
121119
120+ ![ image.png] ( https://pic.leetcode-cn.com/1616378128-yBWadF-image.png )
121+
122122代码:
123123``` Java []
124124public class Solution {
You can’t perform that action at this time.
0 commit comments