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 47f059e

Browse files
feat: update solutions (doocs#2257)
1 parent 6d4c1d4 commit 47f059e

File tree

4 files changed

+68
-92
lines changed

4 files changed

+68
-92
lines changed

‎solution/0000-0099/0009.Palindrome Number/README.md‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,29 +171,6 @@ impl Solution {
171171
}
172172
```
173173

174-
```js
175-
/**
176-
* @param {number} x
177-
* @return {boolean}
178-
*/
179-
var isPalindrome = function (x) {
180-
if (x < 0 || (x > 0 && x % 10 === 0)) {
181-
return false;
182-
}
183-
let y = 0;
184-
for (; y < x; x = ~~(x / 10)) {
185-
y = y * 10 + (x % 10);
186-
}
187-
return x === y || x === ~~(y / 10);
188-
};
189-
```
190-
191-
<!-- tabs:end -->
192-
193-
### 方法二
194-
195-
<!-- tabs:start -->
196-
197174
```rust
198175
impl Solution {
199176
pub fn is_palindrome(mut x: i32) -> bool {
@@ -211,6 +188,23 @@ impl Solution {
211188
}
212189
```
213190

191+
```js
192+
/**
193+
* @param {number} x
194+
* @return {boolean}
195+
*/
196+
var isPalindrome = function (x) {
197+
if (x < 0 || (x > 0 && x % 10 === 0)) {
198+
return false;
199+
}
200+
let y = 0;
201+
for (; y < x; x = ~~(x / 10)) {
202+
y = y * 10 + (x % 10);
203+
}
204+
return x === y || x === ~~(y / 10);
205+
};
206+
```
207+
214208
```php
215209
class Solution {
216210
/**

‎solution/0000-0099/0009.Palindrome Number/README_EN.md‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -161,29 +161,6 @@ impl Solution {
161161
}
162162
```
163163

164-
```js
165-
/**
166-
* @param {number} x
167-
* @return {boolean}
168-
*/
169-
var isPalindrome = function (x) {
170-
if (x < 0 || (x > 0 && x % 10 === 0)) {
171-
return false;
172-
}
173-
let y = 0;
174-
for (; y < x; x = ~~(x / 10)) {
175-
y = y * 10 + (x % 10);
176-
}
177-
return x === y || x === ~~(y / 10);
178-
};
179-
```
180-
181-
<!-- tabs:end -->
182-
183-
### Solution 2
184-
185-
<!-- tabs:start -->
186-
187164
```rust
188165
impl Solution {
189166
pub fn is_palindrome(mut x: i32) -> bool {
@@ -201,6 +178,23 @@ impl Solution {
201178
}
202179
```
203180

181+
```js
182+
/**
183+
* @param {number} x
184+
* @return {boolean}
185+
*/
186+
var isPalindrome = function (x) {
187+
if (x < 0 || (x > 0 && x % 10 === 0)) {
188+
return false;
189+
}
190+
let y = 0;
191+
for (; y < x; x = ~~(x / 10)) {
192+
y = y * 10 + (x % 10);
193+
}
194+
return x === y || x === ~~(y / 10);
195+
};
196+
```
197+
204198
```php
205199
class Solution {
206200
/**

‎solution/2800-2899/2862.Maximum Element-Sum of a Complete Subset of Indices/README.md‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ class Solution:
8181
return ans
8282
```
8383

84+
```java
85+
class Solution {
86+
public long maximumSum(List<Integer> nums) {
87+
long ans = 0;
88+
int n = nums.size();
89+
for (int k = 1; k <= n; ++k) {
90+
long t = 0;
91+
for (int j = 1; k * j * j <= n; ++j) {
92+
t += nums.get(k * j * j - 1);
93+
}
94+
ans = Math.max(ans, t);
95+
}
96+
return ans;
97+
}
98+
}
99+
```
100+
84101
```java
85102
class Solution {
86103
public long maximumSum(List<Integer> nums) {
@@ -156,27 +173,4 @@ function maximumSum(nums: number[]): number {
156173

157174
<!-- tabs:end -->
158175

159-
### 方法二
160-
161-
<!-- tabs:start -->
162-
163-
```java
164-
class Solution {
165-
public long maximumSum(List<Integer> nums) {
166-
long ans = 0;
167-
int n = nums.size();
168-
for (int k = 1; k <= n; ++k) {
169-
long t = 0;
170-
for (int j = 1; k * j * j <= n; ++j) {
171-
t += nums.get(k * j * j - 1);
172-
}
173-
ans = Math.max(ans, t);
174-
}
175-
return ans;
176-
}
177-
}
178-
```
179-
180-
<!-- tabs:end -->
181-
182176
<!-- end -->

‎solution/2800-2899/2862.Maximum Element-Sum of a Complete Subset of Indices/README_EN.md‎

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ class Solution {
103103
}
104104
```
105105

106+
```java
107+
class Solution {
108+
public long maximumSum(List<Integer> nums) {
109+
long ans = 0;
110+
int n = nums.size();
111+
for (int k = 1; k <= n; ++k) {
112+
long t = 0;
113+
for (int j = 1; k * j * j <= n; ++j) {
114+
t += nums.get(k * j * j - 1);
115+
}
116+
ans = Math.max(ans, t);
117+
}
118+
return ans;
119+
}
120+
}
121+
```
122+
106123
```cpp
107124
class Solution {
108125
public:
@@ -152,27 +169,4 @@ function maximumSum(nums: number[]): number {
152169

153170
<!-- tabs:end -->
154171

155-
### Solution 2
156-
157-
<!-- tabs:start -->
158-
159-
```java
160-
class Solution {
161-
public long maximumSum(List<Integer> nums) {
162-
long ans = 0;
163-
int n = nums.size();
164-
for (int k = 1; k <= n; ++k) {
165-
long t = 0;
166-
for (int j = 1; k * j * j <= n; ++j) {
167-
t += nums.get(k * j * j - 1);
168-
}
169-
ans = Math.max(ans, t);
170-
}
171-
return ans;
172-
}
173-
}
174-
```
175-
176-
<!-- tabs:end -->
177-
178172
<!-- end -->

0 commit comments

Comments
(0)

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