随笔分类 -  LeetCode

摘要:bool cmp (int i,int j) { return (i>j);} class Solution { public: int hIndex(vector& citations) { int count = 0; sort(citations.begin(),citations.end(),cmp); for(int i = ... 阅读全文
posted @ 2018-08-18 16:10 Lokianyu 阅读(211) 评论(0) 推荐(0)
摘要:因为时间序列有序,从后往前遍历一次,总时间要么是前一个时间点减后一个时间点,要么是吃满中毒持续时间。 class Solution { public: int findPoisonedDuration(vector<int>& timeSeries, int duration) { int coun 阅读全文
posted @ 2018-08-17 22:22 Lokianyu 阅读(108) 评论(0) 推荐(0)
摘要:思路就是三重循环遍历即可,反正不卡时间复杂度(逃 class Solution { public: int triangleNumber(vector<int>& nums) { int count = 0; for(int i = 0; i < nums.size(); i++) for(int 阅读全文
posted @ 2018-08-17 21:58 Lokianyu 阅读(383) 评论(0) 推荐(0)