diff --git a/problems/0027.移除元素.md b/problems/0027.移除元素.md index 3d43a199..ce9eccf0 100644 --- a/problems/0027.移除元素.md +++ b/problems/0027.移除元素.md @@ -5,7 +5,7 @@

参与本项目,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!

-## 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, 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) {