leetcode 字符串类型题】的更多相关文章

1,Vaild Palindrome bool isPalindrome(string& s) { transform(s.begin(), s.end(), s.begin(), tolower); // 把字符全部转换成小写 ; ; while (left < right) { if (!isalnum(s[left])) ++left; else if (!isalnum(s[right])) --right; else if (s[left] != s[right]) return…
链表测试框架示例: // leetcodeList.cpp : 定义控制台应用程序的入口点.vs2013 测试通过 // #include "stdafx.h" #include <Windows.h> #include <iostream> using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(nullptr){}; }; v…
1,Triangle int mininumTotal(vector<vector<int>>& triangle) { ; i >= ; --i) { ; j < i + ; ++j) { // 从下往上依次保存当前路径的最小值,上层只会用到下层的最小值 triangle[i][j] += min(triangle[i + ][j], triangle[i + ][j + ]); } } ][]; } triangle 2,Maximum SubArray /…
树的测试框架: // leetcodeTree.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include <queue> #include <stack> #include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right;…
1,removeDuplicates(I) int removeDuplicatesI(vector<int>& nums){ // 重新组织数组,同 removeDuplicates2IV ; ;i<nums.size();++i){ && nums[i] == nums[i-]) continue; nums[index++] = nums[i]; } return index; } int removeDuplicatesII(vector<int&g…
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <Windows.h> #include <iostream> #include <vector> #include <string> #include <unordered_set> #include <unordered_map> #include <al…
[python]Leetcode每日一题-扰乱字符串 [题目描述] 使用下面描述的算法可以扰乱字符串 s 得到字符串 t : 如果字符串的长度为 1 ,算法停止 如果字符串的长度 > 1 ,执行下述步骤: 在一个随机下标处将字符串分割成两个非空的子字符串.即,如果已知字符串 s ,则可以将其分成两个子字符串 x 和 y ,且满足 s = x + y . 随机 决定是要「交换两个子字符串」还是要「保持这两个子字符串的顺序不变」.即,在执行这一步骤之后,s 可能是 s = x + y 或者 s =…
LeetCode 第 3 题(Longest Substring Without Repeating Characters) Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "b…
[leetcode 字符串处理]Compare Version Numbers @author:wepon @blog:http://blog.csdn.net/u012162613 1.题目 Compare two version numbers version1 and version1. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume…
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">leetcode第188题,Best Time to Buy and Sell Stock IV题目如下:</span> https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/ Say you hav…