更新 027.移除元素 排版格式修复

This commit is contained in:
jinbudaily
2023-07-17 15:11:55 +08:00
parent 948aca860d
commit fdbc7442ac

View File

@ -5,7 +5,7 @@
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
## 27. 移除元素
# 27. 移除元素
[力扣题目链接](https://leetcode.cn/problems/remove-element/)
@ -159,8 +159,8 @@ public:
## 其他语言版本
### Java
Java
```java
class Solution {
public int removeElement(int[] nums, int val) {
@ -197,7 +197,7 @@ class Solution {
}
```
Python
### Python
``` python 3
@ -233,8 +233,8 @@ class Solution:
```
### Go
Go
```go
func removeElement(nums []int, val int) int {
length:=len(nums)
@ -275,7 +275,8 @@ func removeElement(nums []int, val int) int {
}
```
JavaScript:
### JavaScript:
```javascript
//时间复杂度O(n)
//空间复杂度O(1)
@ -290,7 +291,7 @@ var removeElement = (nums, val) => {
};
```
TypeScript
### TypeScript
```typescript
function removeElement(nums: number[], val: number): number {
@ -305,7 +306,7 @@ function removeElement(nums: number[], val: number): number {
};
```
Ruby:
### Ruby:
```ruby
def remove_element(nums, val)
@ -319,7 +320,8 @@ def remove_element(nums, val)
i
end
```
Rust:
### Rust:
```rust
impl Solution {
pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 {
@ -335,7 +337,7 @@ impl Solution {
}
```
Swift:
### Swift:
```swift
func removeElement(_ nums: inout [Int], _ val: Int) -> Int {
@ -351,7 +353,8 @@ func removeElement(_ nums: inout [Int], _ val: Int) -> Int {
}
```
PHP:
### PHP:
```php
class Solution {
/**
@ -375,7 +378,8 @@ class Solution {
}
```
C:
### C:
```c
int removeElement(int* nums, int numsSize, int val){
int slow = 0;
@ -391,7 +395,8 @@ int removeElement(int* nums, int numsSize, int val){
}
```
Kotlin:
### Kotlin:
```kotlin
fun removeElement(nums: IntArray, `val`: Int): Int {
var slowIndex = 0 // 初始化慢指针
@ -402,7 +407,8 @@ fun removeElement(nums: IntArray, `val`: Int): Int {
}
```
Scala:
### Scala:
```scala
object Solution {
def removeElement(nums: Array[Int], `val`: Int): Int = {
@ -418,7 +424,8 @@ object Solution {
}
```
C#:
### C#:
```csharp
public class Solution {
public int RemoveElement(int[] nums, int val) {