【LeetCode從零單排】No27.Remove Element
題目
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
程式碼
public class Solution {
public int removeElement(int[] A, int elem) {
int next = 0;
for(int i = 0; i < A.length; i++) {
if(A[i] != elem) {
A[next++] = A[i];
}
}
return next;
}
}
/********************************
* 本文來自部落格 “李博Garvin“
* 轉載請標明出處:http://blog.csdn.net/buptgshengod
******************************************/
相關文章
- Mysql從零單排-1MySql
- 從零單排學Redis【黃金】Redis
- 從零單排學Redis【白銀】Redis
- 從零單排學Redis【鉑金一】Redis
- 從零單排學Redis【鉑金二】Redis
- SpringBoot從零單排 ------初級入門篇Spring Boot
- 【3y】從零單排學Redis【青銅】Redis
- 「從零單排canal 03」 canal原始碼分析大綱原始碼
- 「從零單排canal 05」 server模組原始碼解析Server原始碼
- 「從零單排canal 07」 parser模組原始碼解析原始碼
- 從零單排,使用 Netty 構建 IM 聊天室~Netty
- 「從零單排canal 06」 instance模組原始碼解析原始碼
- Laravel 從零單排系列教程 01 :Homestead 環境搭建Laravel
- 三分鐘從零單排js靜態檢查JS
- Spring AOP從零單排-織入時期原始碼分析Spring原始碼
- 「從零單排canal 04」 啟動模組deployer原始碼解析原始碼
- 「從零單排HBase 10」HBase叢集多租戶實踐
- 從零開始單排學設計模式「策略模式」黑鐵 II設計模式
- 從零開始單排學設計模式「UML類圖」定級賽設計模式
- 最新【從零單排】系列流出,教你如何實現字典儲存結構
- 從零開始單排學設計模式「裝飾模式」黑鐵 I設計模式
- 從零開始實現簡單 RPC 框架 3:配置匯流排 URLRPC框架
- [leetcode]remove-elementLeetCodeREM
- leetcode 283. 移動零(簡單)LeetCode
- 從零開始單排學設計模式「簡單工廠設計模式」黑鐵 III設計模式
- 從零單排Java 8(3) —— List結合Lambdas對排序的高階用法Java排序
- leetcode-27. Remove ElementLeetCodeREM
- Leetcode 27 Remove-ElementLeetCodeREM
- LeetCode Kth Largest Element in an ArrayLeetCode
- LeetCode 169. Majority ElementLeetCode
- 「從零單排canal 01」 canal 10分鐘入門(基於1.1.4版本)
- LeetCode C++ 703. Kth Largest Element in a Stream【Heap/Design】簡單LeetCodeC++
- [LeetCode] 230. Kth Smallest Element in a BSTLeetCode
- [LeetCode] Find First and Last Position of Element in SortedLeetCodeAST
- [LeetCode] 378. Kth Smallest Element in a Sorted MatrixLeetCode
- python leetcode 215. Kth Largest Element in an ArrayPythonLeetCode
- 從零打卡leetcode之day 1--兩數之和LeetCode
- 從零打卡leetcode之day 2---兩數相加LeetCode
- 「從零單排canal 02」canal叢集版 + admin控制檯 最新搭建姿勢(基於1.1.4版本)