LintCode hard
文章平均质量分 68
qq_34153219
这个作者很懒,什么都没留下…
展开
-
LintCode 86:Binary Search Tree Iterator
虽说是hard难度但是实际很简单。在构造时直接将树按inorder顺序保存入vector中,时间复杂度为O(N),空间复杂度为O(N),之后再获取node时的复杂度全都为O(1)。 class BSTIterator { vector inOrderList; vector::iterator p; void inOrderTree(TreeNode* node)原创 2017-02-22 19:20:47 · 426 阅读 · 0 评论 -
LintCode 81:Data Stream Median
维护了一个排好序的vector,每次用二分法插入数,插入的平均时间复杂度为O(logN)。 class Solution { void InsertAndSort(vector& sortVector,int num){ int low=0; int high=sortVector.size()-1; while(low<high)原创 2017-02-22 20:37:11 · 190 阅读 · 0 评论 -
LintCode54: String to Integer II
Description: Implement function atoi to convert a string to an integer. If no valid conversion could be performed, a zero value is returned. If the correct value is out of the range of repr原创 2017-10-04 10:11:02 · 199 阅读 · 0 评论 -
LintCode 192:Wildcard Matching
Description: Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matc原创 2017-10-16 15:38:57 · 187 阅读 · 0 评论