摘要: // Best Time to Buy and Sell Stock 1class Solution { public: int maxProfit(vector& prices) { if(prices.size()==0) return 0; int maxres=prices[prices.size()-1]; ... 阅读全文
posted @ 2017-10-29 16:56 PirateLHX 阅读(146) 评论(0) 推荐(0)
摘要: 正常解法 以上是正常解法,但认真分析可以发现其复杂度是O(n^2),原因很简单,首先先逐个查找去掉某一个字符的字符串是不是回文序列,查找需要n次,同时字符串与reverse后字符串的比较的次数也为n次,由此可见算法复杂度是n^2,这在leetcode上运行时会出现严重的超时,故采取第二种简单的做法, 阅读全文
posted @ 2017-10-29 13:38 PirateLHX 阅读(189) 评论(4) 推荐(0)