![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode学习
arella1101
念念不忘,终有回响。
展开
-
LeetCode 第四题答案 C++
class Solution {public:double find_mean(vector<int>&nums){ int me; double result; double er=2; if(nums.size()%2==0){ me=nums.size()/2; result= (nums[me-1]+...原创 2018-08-27 14:39:08 · 939 阅读 · 0 评论 -
LeetCode第三题答案 C++
class Solution {public: int lengthOfLongestSubstring(string s) { int flag=0; int count=0; int l=0; int result=1; int differ=0; if(s=="") return 0...原创 2018-08-24 17:27:06 · 1038 阅读 · 0 评论 -
LeetCode 第二题答案 C++
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution {public: ListNod...转载 2018-08-24 12:31:03 · 1142 阅读 · 0 评论 -
LeetCode第五题答案(time limite exceeded) C++ time limit exceeded
这个是最开始写的brutal answer. 遍历所有子串,算法效率不高,虽然结果正确,但在LeetCode上time limit exceeded。下一篇附上改进代码。class Solution {public: bool isPalindromic(string s){ for(int i=0;i<s.size();i++){ i...原创 2018-08-29 16:21:25 · 668 阅读 · 0 评论