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
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ tags:
```python
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
for a in range(1, n):
for a in count(1):
b = n - a
if "0" not in str(a) + str(b):
if "0" not in f"{a}{b}":
return [a, b]
```

Expand Down Expand Up @@ -159,6 +159,22 @@ function getNoZeroIntegers(n: number): number[] {
}
```

#### Rust

```rust
impl Solution {
pub fn get_no_zero_integers(n: i32) -> Vec<i32> {
for a in 1..n {
let b = n - a;
if !a.to_string().contains('0') && !b.to_string().contains('0') {
return vec![a, b];
}
}
vec![]
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand All @@ -178,14 +194,14 @@ function getNoZeroIntegers(n: number): number[] {
```python
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
def f(x):
def f(x: int) -> bool:
while x:
if x % 10 == 0:
return False
x //= 10
return True

for a in range(1, n):
for a in count(1):
b = n - a
if f(a) and f(b):
return [a, b]
Expand Down Expand Up @@ -281,6 +297,32 @@ function getNoZeroIntegers(n: number): number[] {
}
```

#### Rust

```rust
impl Solution {
pub fn get_no_zero_integers(n: i32) -> Vec<i32> {
fn f(mut x: i32) -> bool {
while x > 0 {
if x % 10 == 0 {
return false;
}
x /= 10;
}
true
}

for a in 1..n {
let b = n - a;
if f(a) && f(b) {
return vec![a, b];
}
}
vec![]
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ The time complexity is $O(n \times \log n)$, where $n$ is the integer given in t
```python
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
for a in range(1, n):
for a in count(1):
b = n - a
if "0" not in str(a) + str(b):
if "0" not in f"{a}{b}":
return [a, b]
```

Expand Down Expand Up @@ -138,6 +138,22 @@ function getNoZeroIntegers(n: number): number[] {
}
```

#### Rust

```rust
impl Solution {
pub fn get_no_zero_integers(n: i32) -> Vec<i32> {
for a in 1..n {
let b = n - a;
if !a.to_string().contains('0') && !b.to_string().contains('0') {
return vec![a, b];
}
}
vec![]
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand All @@ -157,14 +173,14 @@ The time complexity is $O(n \times \log n)$, where $n$ is the integer given in t
```python
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
def f(x):
def f(x: int) -> bool:
while x:
if x % 10 == 0:
return False
x //= 10
return True

for a in range(1, n):
for a in count(1):
b = n - a
if f(a) and f(b):
return [a, b]
Expand Down Expand Up @@ -260,6 +276,32 @@ function getNoZeroIntegers(n: number): number[] {
}
```

#### Rust

```rust
impl Solution {
pub fn get_no_zero_integers(n: i32) -> Vec<i32> {
fn f(mut x: i32) -> bool {
while x > 0 {
if x % 10 == 0 {
return false;
}
x /= 10;
}
true
}

for a in 1..n {
let b = n - a;
if f(a) && f(b) {
return vec![a, b];
}
}
vec![]
}
}
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
for a in range(1, n):
for a in count(1):
b = n - a
if "0" not in str(a) + str(b):
if "0" not in f"{a}{b}":
return [a, b]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
impl Solution {
pub fn get_no_zero_integers(n: i32) -> Vec<i32> {
for a in 1..n {
let b = n - a;
if !a.to_string().contains('0') && !b.to_string().contains('0') {
return vec![a, b];
}
}
vec![]
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
def f(x):
def f(x: int) -> bool:
while x:
if x % 10 == 0:
return False
x //= 10
return True

for a in range(1, n):
for a in count(1):
b = n - a
if f(a) and f(b):
return [a, b]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
impl Solution {
pub fn get_no_zero_integers(n: i32) -> Vec<i32> {
fn f(mut x: i32) -> bool {
while x > 0 {
if x % 10 == 0 {
return false;
}
x /= 10;
}
true
}

for a in 1..n {
let b = n - a;
if f(a) && f(b) {
return vec![a, b];
}
}
vec![]
}
}