上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页
摘要: 出题人语死早,并没有叙述清楚 值得注意的是,“abc ”这个字符串是有单词存在的 所以从尾部判断的时候还要再看一下前边 class Solution { public: int lengthOfLastWord(string s) { int len = s.size(); int rear = l 阅读全文
posted @ 2021-01-25 21:56 然终酒肆 阅读(36) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int maxSubArray(vector<int>& nums) { int res = nums[0]; int sum = 0; for( int num : nums ) { if(sum > 0) sum+=num; else sum = 阅读全文
posted @ 2021-01-25 21:26 然终酒肆 阅读(49) 评论(0) 推荐(0) 编辑
摘要: 迭代: class Solution { public: string countAndSay(int n) { string ans ="1"; n-=1; int s_index;//开始的索引 string temp; while(n--) { temp = ""; s_index =0; f 阅读全文
posted @ 2021-01-25 21:03 然终酒肆 阅读(49) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int removeDuplicates(vector<int>& nums) { int i = 0; int len = nums.size(); if(len==0) return 0; for(int j =1;j<len;j++ ) { i 阅读全文
posted @ 2021-01-22 23:42 然终酒肆 阅读(64) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : 阅读全文
posted @ 2021-01-22 23:25 然终酒肆 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 模拟面试的时候,遇到了这种题 确实是简单至极的题目 但是我 忘了栈用stl怎么写。又懒得用结构体写栈。 自己用vector造了一个栈。。。 我猜压根没像我这么写的 就很快乐 class Solution { public: bool isValid(string s) { if(s == "") r 阅读全文
posted @ 2021-01-21 23:32 然终酒肆 阅读(42) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string longestCommonPrefix(vector<string>& strs) { if(!strs.size()) return ""; else if(strs.size() == 1 ) return strs[0]; els 阅读全文
posted @ 2021-01-21 22:23 然终酒肆 阅读(55) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean isPalindrome(int x) { if(x < 0) return false; int cur = 0; int num = x; while(num != 0) { cur = cur * 10 + num % 10; n 阅读全文
posted @ 2021-01-18 14:52 然终酒肆 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 这是一道再水不过的题。但是这道题其实会引起一些思考的 这道题解法一定很多 初见这道题时,大多数人想的思路应该就是直接暴力 数字转字符串。但是这样未免太低级了。 在高级点就是,反转其实可以用栈。 一步一步用vector 推进去 或者用栈推进去然后输出就行了 中间要判断是否溢出,还有0和负号的一些处理 阅读全文
posted @ 2021-01-18 14:38 然终酒肆 阅读(61) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/knowledgesea/archive/2013/01/02/2841588.html 阅读全文
posted @ 2021-01-16 21:06 然终酒肆 阅读(52) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页