File tree 9 files changed +175
-28
lines changed
1900-1999/1929.Concatenation of Array
2200-2299/2235.Add Two Integers
9 files changed +175
-28
lines changed Original file line number Diff line number Diff line change @@ -81,20 +81,6 @@ class Solution {
81
81
}
82
82
```
83
83
84
- ### ** JavaScript**
85
-
86
- ``` js
87
- /**
88
- * @param {number[]} nums
89
- * @return {number[]}
90
- */
91
- var getConcatenation = function (nums ) {
92
- let ans = nums .slice ();
93
- ans .splice (nums .length , 0 , ... nums);
94
- return ans;
95
- };
96
- ```
97
-
98
84
### ** C++**
99
85
100
86
``` cpp
@@ -117,6 +103,54 @@ func getConcatenation(nums []int) []int {
117
103
}
118
104
```
119
105
106
+ ### ** JavaScript**
107
+
108
+ ``` js
109
+ /**
110
+ * @param {number[]} nums
111
+ * @return {number[]}
112
+ */
113
+ var getConcatenation = function (nums ) {
114
+ let ans = nums .slice ();
115
+ ans .splice (nums .length , 0 , ... nums);
116
+ return ans;
117
+ };
118
+ ```
119
+
120
+ ### ** TypeScript**
121
+
122
+ ``` ts
123
+ function getConcatenation(nums : number []): number [] {
124
+ return [... nums , ... nums ];
125
+ }
126
+ ```
127
+
128
+ ### ** Rust**
129
+
130
+ ``` rust
131
+ impl Solution {
132
+ pub fn get_concatenation (nums : Vec <i32 >) -> Vec <i32 > {
133
+ nums . repeat (2 )
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### ** C**
139
+
140
+ ``` c
141
+ /* *
142
+ * Note: The returned array must be malloced, assume caller calls free().
143
+ */
144
+ int *getConcatenation (int * nums, int numsSize, int * returnSize) {
145
+ int * ans = malloc(sizeof(int) * numsSize * 2);
146
+ for (int i = 0; i < numsSize; i++) {
147
+ ans[ i] = ans[ i + numsSize] = nums[ i] ;
148
+ }
149
+ * returnSize = numsSize * 2;
150
+ return ans;
151
+ }
152
+ ```
153
+
120
154
### **...**
121
155
122
156
```
Original file line number Diff line number Diff line change @@ -66,20 +66,6 @@ class Solution {
66
66
}
67
67
```
68
68
69
- ### ** JavaScript**
70
-
71
- ``` js
72
- /**
73
- * @param {number[]} nums
74
- * @return {number[]}
75
- */
76
- var getConcatenation = function (nums ) {
77
- let ans = nums .slice ();
78
- ans .splice (nums .length , 0 , ... nums);
79
- return ans;
80
- };
81
- ```
82
-
83
69
### ** C++**
84
70
85
71
``` cpp
@@ -102,6 +88,54 @@ func getConcatenation(nums []int) []int {
102
88
}
103
89
```
104
90
91
+ ### ** JavaScript**
92
+
93
+ ``` js
94
+ /**
95
+ * @param {number[]} nums
96
+ * @return {number[]}
97
+ */
98
+ var getConcatenation = function (nums ) {
99
+ let ans = nums .slice ();
100
+ ans .splice (nums .length , 0 , ... nums);
101
+ return ans;
102
+ };
103
+ ```
104
+
105
+ ### ** TypeScript**
106
+
107
+ ``` ts
108
+ function getConcatenation(nums : number []): number [] {
109
+ return [... nums , ... nums ];
110
+ }
111
+ ```
112
+
113
+ ### ** Rust**
114
+
115
+ ``` rust
116
+ impl Solution {
117
+ pub fn get_concatenation (nums : Vec <i32 >) -> Vec <i32 > {
118
+ nums . repeat (2 )
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### ** C**
124
+
125
+ ``` c
126
+ /* *
127
+ * Note: The returned array must be malloced, assume caller calls free().
128
+ */
129
+ int *getConcatenation (int * nums, int numsSize, int * returnSize) {
130
+ int * ans = malloc(sizeof(int) * numsSize * 2);
131
+ for (int i = 0; i < numsSize; i++) {
132
+ ans[ i] = ans[ i + numsSize] = nums[ i] ;
133
+ }
134
+ * returnSize = numsSize * 2;
135
+ return ans;
136
+ }
137
+ ```
138
+
105
139
### **...**
106
140
107
141
```
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Note: The returned array must be malloced, assume caller calls free().
3
+ */
4
+ int * getConcatenation (int * nums , int numsSize , int * returnSize ) {
5
+ int * ans = malloc (sizeof (int ) * numsSize * 2 );
6
+ for (int i = 0 ; i < numsSize ; i ++ ) {
7
+ ans [i ] = ans [i + numsSize ] = nums [i ];
8
+ }
9
+ * returnSize = numsSize * 2 ;
10
+ return ans ;
11
+ }
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn get_concatenation ( nums : Vec < i32 > ) -> Vec < i32 > {
3
+ nums. repeat ( 2 )
4
+ }
5
+ }
Original file line number Diff line number Diff line change
1
+ function getConcatenation ( nums : number [ ] ) : number [ ] {
2
+ return [ ...nums , ...nums ] ;
3
+ }
Original file line number Diff line number Diff line change @@ -89,6 +89,32 @@ func sum(num1 int, num2 int) int {
89
89
}
90
90
```
91
91
92
+ ### ** TypeScript**
93
+
94
+ ``` ts
95
+ function sum(num1 : number , num2 : number ): number {
96
+ return num1 + num2 ;
97
+ }
98
+ ```
99
+
100
+ ### ** Rust**
101
+
102
+ ``` rust
103
+ impl Solution {
104
+ pub fn sum (num1 : i32 , num2 : i32 ) -> i32 {
105
+ num1 + num2
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### ** C**
111
+
112
+ ``` c
113
+ int sum (int num1, int num2) {
114
+ return num1 + num2;
115
+ }
116
+ ```
117
+
92
118
### **...**
93
119
94
120
```
Original file line number Diff line number Diff line change @@ -79,6 +79,32 @@ func sum(num1 int, num2 int) int {
79
79
}
80
80
```
81
81
82
+ ### ** TypeScript**
83
+
84
+ ``` ts
85
+ function sum(num1 : number , num2 : number ): number {
86
+ return num1 + num2 ;
87
+ }
88
+ ```
89
+
90
+ ### ** Rust**
91
+
92
+ ``` rust
93
+ impl Solution {
94
+ pub fn sum (num1 : i32 , num2 : i32 ) -> i32 {
95
+ num1 + num2
96
+ }
97
+ }
98
+ ```
99
+
100
+ ### ** C**
101
+
102
+ ``` c
103
+ int sum (int num1, int num2) {
104
+ return num1 + num2;
105
+ }
106
+ ```
107
+
82
108
### **...**
83
109
84
110
```
Original file line number Diff line number Diff line change
1
+ int sum (int num1 , int num2 ) {
2
+ return num1 + num2 ;
3
+ }
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn sum ( num1 : i32 , num2 : i32 ) -> i32 {
3
+ num1 + num2
4
+ }
5
+ }
You can’t perform that action at this time.
0 commit comments