Skip to content

Latest commit

 

History

History

leetcode

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Submissions

https://leetcode.com/xunilrj/

Algorithms

Remove Duplicates from Sorted Array

Runtime: 20 ms
Memory Usage: 7.6 MB
https://leetcode.com/submissions/detail/321115997/

alt text alt text

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;
    }
};

235. Lowest Common Ancestor of a Binary Search Tree

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/

alt text
alt text

See More

Lowest Common Ancestor of a Binary Tree

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/

alt text alt text

See More

Median of Two Sorted Arrays

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

alt text alt text

Data Structures

LRU Cache

Runtime: 104 ms
Memory Usage: 40.1 MB
https://leetcode.com/submissions/detail/292957724/

alt text
alt text

More LRU Cache Details
LRU Cache Tutorial

Stream processing

Sliding Window Median

Runtime: 88 ms
Memory Usage: 15.2 MB
https://leetcode.com/submissions/detail/322571550/

alt text
alt text

More LRU Cache Details