Skip to content

Commit 1c5b536

Browse files
LetMeFly666Copilot
andauthored
update: 添加问题“788.旋转数字”的代码(并更新其题解) (#1561)
* 788: WA.cpp (#1560) + en - 是整个x和之前不同 * 788: AC.cpp (#1560) - AC,100.00%,85.19% * update: 添加问题“788.旋转数字”的代码(并更新其题解) (#1561) 2833: AC.cpp+py+java+go+rust (#1540) cpp - AC,18.64%,27.12% py - AC,100.00%,45.33% java - AC,100.00%,81.25% go - AC,100.00%,50.00% rust - AC,100.00%,40.00% rust.abs - AC,100.00%,60.00% --- newSolutions.py --- 看下这个源码,实现以下新增功能: 1. 写源码的时候,如果最后一行不是空行,则添加一个空行(python的Solution后面若只有一行tab或几个空格,不算一个空行,仍需添加空行) 2. 写源码文件的时候,若go函数中默认是4个空格,改为tab 2. 源码到题解的时候,删掉最后的空行(如有) 3. 源码到题解文件的时候,将go的缩进tab改为4个空格 --- 为了鲁棒性保证,这次本feature不上线了(#1543) --- Signed-off-by: LetMeFly666 <Tisfy@qq.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: 0->false --------- Signed-off-by: LetMeFly666 <Tisfy@qq.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 9816adc commit 1c5b536

5 files changed

Lines changed: 77 additions & 87 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-05-02 19:10:14
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-05-02 19:19:23
6+
*/
7+
#ifdef _DEBUG
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
private:
13+
static const int mask_diff = (1 << 2) | (1 << 5) | (1 << 6) | (1 << 9);
14+
static const int mask_ok = mask_diff | (1 << 0) | (1 << 1) | (1 << 8);
15+
16+
bool ok(int n) {
17+
bool has_diff = false;
18+
while (n) {
19+
int t = n % 10;
20+
if (!((1 << t) & mask_ok)) {
21+
return false;
22+
}
23+
if ((1 << t) & mask_diff) {
24+
has_diff = true;
25+
}
26+
n /= 10;
27+
}
28+
return has_diff;
29+
}
30+
public:
31+
int rotatedDigits(int n) {
32+
int ans = 0;
33+
for (int i = 1; i <= n; i++) {
34+
ans += ok(i);
35+
}
36+
return ans;
37+
}
38+
};

Solutions/LeetCode 0788.旋转数字.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 788.旋转数字
33
date: 2022-09-25 20:03:35
4-
tags: [题解, LeetCode, 中等, 数学, 动态规划, 暴力, 模拟]
4+
tags: [题解, LeetCode, 中等, 数学, 动态规划, 暴力, 模拟, 数位DP]
55
categories: [题解, LeetCode]
66
---
77

@@ -94,5 +94,41 @@ public:
9494
};
9595
```
9696
97+
#### C++ - 写法2
98+
99+
```cpp
100+
/*
101+
* @LastEditTime: 2026-05-02 19:19:23
102+
*/
103+
class Solution {
104+
private:
105+
static const int mask_diff = (1 << 2) | (1 << 5) | (1 << 6) | (1 << 9);
106+
static const int mask_ok = mask_diff | (1 << 0) | (1 << 1) | (1 << 8);
107+
108+
bool ok(int n) {
109+
bool has_diff = false;
110+
while (n) {
111+
int t = n % 10;
112+
if (!((1 << t) & mask_ok)) {
113+
return false;
114+
}
115+
if ((1 << t) & mask_diff) {
116+
has_diff = true;
117+
}
118+
n /= 10;
119+
}
120+
return has_diff;
121+
}
122+
public:
123+
int rotatedDigits(int n) {
124+
int ans = 0;
125+
for (int i = 1; i <= n; i++) {
126+
ans += ok(i);
127+
}
128+
return ans;
129+
}
130+
};
131+
```
132+
97133
> 同步发文于CSDN,原创不易,转载请附上[原文链接](https://blog.letmefly.xyz/2022/09/25/LeetCode%200788.%E6%97%8B%E8%BD%AC%E6%95%B0%E5%AD%97/)哦~
98134
> Tisfy:[https://letmefly.blog.csdn.net/article/details/127042249](https://letmefly.blog.csdn.net/article/details/127042249)

Solutions/Other-English-LearningNotes-SomeWords.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,8 @@ categories: [自用]
18931893
|distributorship|n. 分销权|
18941894
|||
18951895
|farmhand|n. 农场工人|
1896+
|||
1897+
|mob|n. 暴徒|
18961898

18971899
+ 这个web要是能设计得可以闭眼(完全不睁眼)键盘控制背单词就好了。
18981900
+ 也许可以加个AI用最近词编故事功能(返回接口中支持标注所使用单词高亮?)

test.rs

Lines changed: 0 additions & 79 deletions
This file was deleted.

toSay.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)