Runtime: 20 ms
Memory Usage: 7.6 MB
https://leetcode.com/submissions/detail/321115997/
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
auto size = nums.size();
auto copyTo = 0;
for(int i = 0;i < size;)
{
nums[copyTo] = nums[i];
auto& current = nums[i];
do
{
++i;
}
while((i < size) && (current == nums[i]));
++copyTo;
}
return copyTo;
}
};
Runtime: 32 ms Your runtime beats 96.18 % of cpp submissions.
Memory Usage: 23.4 MB Your runtime beats 100 % of cpp submissions.
https://leetcode.com/submissions/detail/327569400/
Runtime: 16 ms (Your runtime beats 95.94 % of cpp submissions.)
Memory Usage: 14.7 MB (Your runtime beats 100 % of cpp submissions.)
https://leetcode.com/submissions/detail/327338526/
Rust see code
Runtime: 4 ms, faster than 70.71% of Rust online submissions for Median of Two Sorted Arrays.
Memory Usage: 2.2 MB, less than 28.57% of Rust online submissions for Median of Two Sorted Arrays.
https://leetcode.com/submissions/detail/433660231
Runtime: 104 ms
Memory Usage: 40.1 MB
https://leetcode.com/submissions/detail/292957724/
More LRU Cache Details
LRU Cache Tutorial
Runtime: 88 ms
Memory Usage: 15.2 MB
https://leetcode.com/submissions/detail/322571550/