LeetCode
文章平均质量分 50
云桥落羽
这个作者很懒,什么都没留下…
展开
-
LeetCode-4 两个排序数组的中位数
C++ class Solution { private: int min(int v1, int v2) { if (v1 > v2) { return v2; } return v1; } double getKth(vector<int>& nums1, vector<int>& nums2, int begin1,...原创 2018-10-03 20:18:46 · 116 阅读 · 0 评论 -
LeetCode-5 最长回文子串
C++ class Solution { public: string longestPalindrome(string s) { int length = s.length(); int longset = 1; int index = 0; int right = 1; int left = 1; ...原创 2018-10-05 16:50:11 · 127 阅读 · 0 评论 -
LeetCode-6 Z字形变换
C++ class Solution { public: string convert(string s, int numRows) { if(numRows==1){return s;} int length = s.length(); int nums = (numRows<<1) - 2; string ...原创 2018-10-05 18:00:31 · 151 阅读 · 0 评论 -
LeetCode-7 反转整数
C++ class Solution { private: const static int MAX_INT = 2147483647; public: int reverse(int x) { bool mark = false; if(x < 0){ mark = true; x *= -1...原创 2018-10-05 18:25:42 · 136 阅读 · 0 评论 -
LeetCode-8 字符串转整数
C++ class Solution { private: string subEmpty(string& s){ int length = s.length(); int begin = 0; int end = length; for(int i=0;i<length;i++){ i...原创 2018-10-10 13:00:03 · 121 阅读 · 0 评论 -
LeetCode-9 回文数
C++ class Solution { public: bool isPalindrome(int x) { if(x < 0){ return false; } int temp = x; int y = 0; while(temp > 0){ ...原创 2018-10-10 13:29:44 · 131 阅读 · 0 评论 -
LeetCode-11 盛最多水的容器
C++ class Solution { public: int maxArea(vector<int>& height) { int begin = 0; int end = height.size() - 1; int res = 0; while(begin!=end){ ...原创 2018-10-21 13:20:30 · 145 阅读 · 0 评论 -
LeetCode-12 整数转罗马数字
C++ class Solution { private: const char* l1[10] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}; const char* l2[10] = {""原创 2018-10-21 14:20:14 · 150 阅读 · 0 评论 -
LeetCode-13 罗马数字转整数
C++ class Solution { public: int romanToInt(string s) { int length = s.length(); int res = 0; for(int i=0;i<length;i++){ if(s[i]=='M'){ res...原创 2018-10-21 23:14:31 · 210 阅读 · 0 评论 -
LeetCode-3 无重复字符的最长子串
C++ class Solution { public: int lengthOfLongestSubstring(string s) { int num = s.length(); int result = 0; int begin = 0; for (int end = 0; end < num; end++) { for (int index = begin...原创 2018-10-03 17:39:37 · 120 阅读 · 0 评论 -
LeetCode-2 两数相加
C++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNo...原创 2018-10-03 00:37:56 · 162 阅读 · 0 评论 -
LeetCode-1 两数之和
C /** * Note: The returned array must be malloced, assume caller calls free(). */ int* twoSum(int* nums, int numsSize, int target) { int *result = (int *)malloc(2*sizeof(int)); // 嵌套遍历 fo...原创 2018-10-01 11:02:02 · 102 阅读 · 0 评论 -
LeetCode-14 最长公共前缀
C++ class Solution { public: string longestCommonPrefix(vector<string>& strs) { if(strs.size()==0){return "";} string res = ""; int size = strs.size(); ...原创 2018-10-22 00:09:26 · 177 阅读 · 0 评论