![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
没有撤退可言~
花有重开日,人无再少年
展开
-
力扣581. 最短无序连续子数组;力扣150. 逆波兰表达式求值
class Solution {public: int findUnsortedSubarray(vector<int>& nums) { vector<int> vec(nums.begin(),nums.end()); sort(vec.begin(),vec.end()); int i = 0; ...原创 2020-01-29 21:56:41 · 156 阅读 · 0 评论 -
力扣125. 验证回文串;力扣443. 压缩字符串
class Solution {public: bool isPalindrome(string s) { if (s.size() == 0) return true; size_t size = s.size(); int i = 0; int j = size - 1; int flag = 0; while (i <= j) { w...原创 2020-01-29 21:51:44 · 165 阅读 · 0 评论 -
力扣8. 字符串转换整数 (atoi);力扣34. 在排序数组中查找元素的第一个和最后一个位置
class Solution {public: int myAtoi(string str) { size_t size = str.size(); int flag = 0; int i = 0; while (i < size) { if (str[i] == ' ') ++i; else if (str[i] == '+' || str[i] == ...原创 2020-01-29 21:17:44 · 171 阅读 · 0 评论 -
力扣66. 加一;力扣414. 第三大的数
class Solution {public: vector<int> plusOne(vector<int>& digits) { vector<int> vec; int flag = 0; int i = digits.size() - 1; vec.resize(digi...原创 2020-01-28 20:54:09 · 139 阅读 · 0 评论 -
力扣1. 两数之和;力扣67. 二进制求和
class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> vec; multimap<int, int> mmap; for (int i = 0; i < nums.size()...原创 2020-01-28 20:56:39 · 153 阅读 · 0 评论 -
力扣905. 按奇偶排序数组;力扣724. 寻找数组的中心索引
class Solution {public: vector<int> sortArrayByParity(vector<int>& A) { int i = 0; int j = A.size() - 1; while(i < j) { if(A[i] % 2...原创 2020-01-27 19:15:24 · 148 阅读 · 0 评论 -
力扣977. 有序数组的平方;力扣917. 仅仅反转字母
class Solution {public: vector<int> sortedSquares(vector<int>& A) { size_t size = A.size(); for(int i = 0; i < size; ++i) { A[i] = abs(A[i]...原创 2020-01-27 17:27:59 · 310 阅读 · 0 评论 -
力扣217. 存在重复元素;力扣925. 长按键入
class Solution {public: bool containsDuplicate(vector<int>& nums) { set<int> sset; for (int i = 0; i < nums.size(); ++i) { auto it = sset.insert(nums[i]); if (it.second...原创 2020-01-27 14:15:25 · 301 阅读 · 0 评论 -
力扣58: 最后一个单词的长度;力扣88: 合并两个有序数组
class Solution {public: int lengthOfLastWord(string s) { if (s.size() == 0) return 0; int count = 0; int i = s.size() - 1; while (i >= 0 && s[i] == ' ') ...原创 2020-01-27 14:08:09 · 95 阅读 · 0 评论 -
力扣383: 赎金信;力扣9:回文数
class Solution {public: bool canConstruct(string ransomNote, string magazine) { multiset<char> sset; for (int i = 0; i < magazine.size(); ++i) { sset.insert(magazine[i]); } ...原创 2020-01-27 14:05:34 · 204 阅读 · 0 评论 -
力扣27:移除元素;力扣35: 搜索插入位置
class Solution {public: int removeElement(vector<int>& nums, int val) { size_t size = nums.size(); if(size == 0) return 0; int i = 0; //一个标记...原创 2020-01-27 14:01:51 · 188 阅读 · 0 评论 -
力扣709:转换成小写字母;力扣189:旋转数组
class Solution {public: string toLowerCase(string str) { size_t size = str.size(); while(size--) { if('A' <= str[size] && str[size] <= 'Z') ...原创 2020-01-27 13:53:57 · 187 阅读 · 0 评论 -
两数之和(无序数组中找固定和);两数相加(两个链表涉及到的大数相加)
首先想到是肯定是暴力破解法:class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> vec; for(int i = 0; i < nums.size();++i) {...原创 2020-01-11 15:37:04 · 236 阅读 · 0 评论