随笔分类 - Leetcode
Leetcode: Length of Last Word
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word ...
阅读全文
Leetcode: Remove Elements
摘要: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 mat...
阅读全文
Leetcode: Remove Duplicates from Sorted Array
摘要:没有想通为什么这个简单的问题竟然不是那么简单,太小看它了,以下是别人的很不错的solution: Solution: 做法是维护两个指针,一个保留当前有效元素的长度,一个从前往后扫,然后跳过那些重复的元素。因为数组是有序的,所以重复元素一定相邻,不需要额外记录。时间复杂度是O(n),空间复杂度O(1
阅读全文
浙公网安备 33010602011771号