mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
更新 0202.快乐数 排版格式修复
This commit is contained in:
@ -28,7 +28,7 @@
|
||||
6^2 + 8^2 = 100
|
||||
1^2 + 0^2 + 0^2 = 1
|
||||
|
||||
# 思路
|
||||
## 思路
|
||||
|
||||
这道题目看上去貌似一道数学问题,其实并不是!
|
||||
|
||||
@ -80,10 +80,10 @@ public:
|
||||
|
||||
|
||||
|
||||
# 其他语言版本
|
||||
## 其他语言版本
|
||||
|
||||
### Java:
|
||||
|
||||
Java:
|
||||
```java
|
||||
class Solution {
|
||||
public boolean isHappy(int n) {
|
||||
@ -107,8 +107,9 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Python:
|
||||
### Python:
|
||||
(版本一)使用集合
|
||||
|
||||
```python
|
||||
class Solution:
|
||||
def isHappy(self, n: int) -> bool:
|
||||
@ -205,7 +206,8 @@ class Solution:
|
||||
seen.append(n)
|
||||
return True
|
||||
```
|
||||
Go:
|
||||
### Go:
|
||||
|
||||
```go
|
||||
func isHappy(n int) bool {
|
||||
m := make(map[int]bool)
|
||||
@ -225,7 +227,7 @@ func getSum(n int) int {
|
||||
}
|
||||
```
|
||||
|
||||
javaScript:
|
||||
### JavaScript:
|
||||
|
||||
```js
|
||||
var isHappy = function (n) {
|
||||
@ -303,7 +305,7 @@ var isHappy = function(n) {
|
||||
};
|
||||
```
|
||||
|
||||
TypeScript:
|
||||
### TypeScript:
|
||||
|
||||
```typescript
|
||||
function isHappy(n: number): boolean {
|
||||
@ -322,7 +324,7 @@ function isHappy(n: number): boolean {
|
||||
};
|
||||
```
|
||||
|
||||
Swift:
|
||||
### Swift:
|
||||
|
||||
```swift
|
||||
// number 每个位置上的数字的平方和
|
||||
@ -355,7 +357,8 @@ func isHappy(_ n: Int) -> Bool {
|
||||
}
|
||||
```
|
||||
|
||||
PHP:
|
||||
### PHP:
|
||||
|
||||
```php
|
||||
class Solution {
|
||||
/**
|
||||
@ -386,7 +389,8 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Rust:
|
||||
### Rust:
|
||||
|
||||
```Rust
|
||||
use std::collections::HashSet;
|
||||
impl Solution {
|
||||
@ -416,7 +420,8 @@ impl Solution {
|
||||
}
|
||||
```
|
||||
|
||||
C:
|
||||
### C:
|
||||
|
||||
```C
|
||||
typedef struct HashNodeTag {
|
||||
int key; /* num */
|
||||
@ -473,8 +478,8 @@ object Solution {
|
||||
}
|
||||
```
|
||||
|
||||
### C#:
|
||||
|
||||
C#:
|
||||
```csharp
|
||||
public class Solution {
|
||||
private int getSum(int n) {
|
||||
@ -500,3 +505,4 @@ public class Solution {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
Reference in New Issue
Block a user