Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 33c2e82

Browse files
authored
feat: add rust solution to lc problem: No.2562 (doocs#1213)
Signed-off-by: xiaolatiao <1628652790@qq.com>
1 parent 73532b4 commit 33c2e82

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

‎solution/2500-2599/2562.Find the Array Concatenation Value/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,25 @@ impl Solution {
197197
}
198198
```
199199

200+
```rust
201+
impl Solution {
202+
pub fn find_the_array_conc_val(nums: Vec<i32>) -> i64 {
203+
let mut ans = 0;
204+
let mut n = nums.len();
205+
206+
for i in 0..n / 2 {
207+
ans += format!("{}{}", nums[i], nums[n - i - 1]).parse::<i64>().unwrap();
208+
}
209+
210+
if n % 2 != 0 {
211+
ans += nums[n / 2] as i64;
212+
}
213+
214+
ans
215+
}
216+
}
217+
```
218+
200219
### **C**
201220

202221
```c

‎solution/2500-2599/2562.Find the Array Concatenation Value/README_EN.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,25 @@ impl Solution {
190190
}
191191
```
192192

193+
```rust
194+
impl Solution {
195+
pub fn find_the_array_conc_val(nums: Vec<i32>) -> i64 {
196+
let mut ans = 0;
197+
let mut n = nums.len();
198+
199+
for i in 0..n / 2 {
200+
ans += format!("{}{}", nums[i], nums[n - i - 1]).parse::<i64>().unwrap();
201+
}
202+
203+
if n % 2 != 0 {
204+
ans += nums[n / 2] as i64;
205+
}
206+
207+
ans
208+
}
209+
}
210+
```
211+
193212
### **C**
194213

195214
```c

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /