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 5272e5e

Browse files
committed
[20221110] solve the easy problem with rust
1 parent 491aa72 commit 5272e5e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
impl Solution {
2+
pub fn build_array(nums: Vec<i32>) -> Vec<i32> {
3+
let mut result: Vec<i32> = Vec::with_capacity(nums.len());
4+
for i in 0..nums.len() as usize {
5+
result.push(nums[nums[i] as usize]);
6+
}
7+
result
8+
}
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
impl Solution {
2+
pub fn get_concatenation(nums: Vec<i32>) -> Vec<i32> {
3+
let mut result = Vec::new();
4+
for i in 0..2 {
5+
for num in &nums {
6+
result.push(*num);
7+
}
8+
}
9+
result
10+
}
11+
}

0 commit comments

Comments
(0)

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