Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions solution/0000-0099/0061.Rotate List/Soution.rs

This file was deleted.

40 changes: 0 additions & 40 deletions solution/0000-0099/0061.Rotate List/Soution.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -158,55 +158,4 @@ impl Solution {

<!-- solution:end -->

<!-- solution:start -->

### 方法二

<!-- tabs:start -->

#### Rust

```rust
use std::collections::HashMap;

impl Solution {
pub fn is_fascinating(mut n: i32) -> bool {
let mut i = n * 2;
let mut j = n * 3;

let mut hash = HashMap::new();

while n != 0 {
let cnt = hash.entry(n % 10).or_insert(0);
*cnt += 1;
n /= 10;
}

while i != 0 {
let cnt = hash.entry(i % 10).or_insert(0);
*cnt += 1;
i /= 10;
}

while j != 0 {
let cnt = hash.entry(j % 10).or_insert(0);
*cnt += 1;
j /= 10;
}

for k in 1..=9 {
if !hash.contains_key(&k) || hash[&k] > 1 {
return false;
}
}

!hash.contains_key(&0)
}
}
```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ tags:

<!-- solution:start -->

### Solution 1
### Solution 1: Simulation

According to the problem description, we concatenate $n$, $2 \times n$, and $3 \times n$ into a string $s$, and then check whether $s$ contains each digit from $1$ to $9$ exactly once and does not contain any $0$.

The time complexity is $O(\log n)$, and the space complexity is $O(\log n)$. Here, $n$ is the given integer.

<!-- tabs:start -->

Expand Down Expand Up @@ -154,55 +158,4 @@ impl Solution {

<!-- solution:end -->

<!-- solution:start -->

### Solution 2

<!-- tabs:start -->

#### Rust

```rust
use std::collections::HashMap;

impl Solution {
pub fn is_fascinating(mut n: i32) -> bool {
let mut i = n * 2;
let mut j = n * 3;

let mut hash = HashMap::new();

while n != 0 {
let cnt = hash.entry(n % 10).or_insert(0);
*cnt += 1;
n /= 10;
}

while i != 0 {
let cnt = hash.entry(i % 10).or_insert(0);
*cnt += 1;
i /= 10;
}

while j != 0 {
let cnt = hash.entry(j % 10).or_insert(0);
*cnt += 1;
j /= 10;
}

for k in 1..=9 {
if !hash.contains_key(&k) || hash[&k] > 1 {
return false;
}
}

!hash.contains_key(&0)
}
}
```

<!-- tabs:end -->

<!-- solution:end -->

<!-- problem:end -->

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading