leetCode高频题刷题记录1;
2017-11-23 14:42
113 查看
以前没有怎么系统的学习过算法,数据结构等内容。越来越发心虚以后的工作去向,故在研一伊始,就准备朝着算法工程师的方向迈进。从数据结构到算法到机器学习到刷题,内容繁杂,仅作学习的记录;
leetCode 27题:RemoveElement:
Given an array and a value, remove all instances of that value
in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array
in-place with O(1) extra memory.
The order of elements can be changed. It doesn't matter what you leave beyond the new length;
leetCode 27题:RemoveElement:
Given an array and a value, remove all instances of that value
in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array
in-place with O(1) extra memory.
The order of elements can be changed. It doesn't matter what you leave beyond the new length;
class Solution { public int removeElement(int[] nums, int val) { int i = 0;
for(int j = 0; j< nums.lenght; j++){
if(nums[j] != val){
nums[i] = nums[j];
i ++;
}
}
return i; } }
相关文章推荐
- LeetCode高频148错题记录
- LeetCode解题记录(1)
- LeetCode刷题记录 Single Element in A Sorted Array
- LeetCode解题记录(3)
- leetcode刷题,总结,记录,备忘 225
- leetcode刷题,总结,记录,备忘 383
- 个人记录-LeetCode 93. Restore IP Addresses
- leetcode刷题。总结,记录,备忘 104
- leetcode小白解题记录——第十题
- leetCode刷题记录 Sort Colors
- leetcode刷题,总结,记录,备忘114
- 【Leetcode解题记录】3. Longest Substring Without Repeating Characte
- leetcode刷题,总结,记录,备忘300
- LeetCode 高频题目
- 个人记录-LeetCode 31. Next Permutation
- leetcode记录 226. Invert Binary Tree
- leetcode刷题,总结,记录,备忘 367
- 个人记录-LeetCode 39. Combination Sum
- leetcode小白解题记录——第十一题
- 个人记录-LeetCode 32. Longest Valid Parentheses