
leetcode
cqx5555
这个作者很懒,什么都没留下…
展开
-
LeetCode 4. Median of Two Sorted Arrays
DescriptionThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Examp原创 2018-01-13 18:09:55 · 253 阅读 · 0 评论 -
leetcode Two Sum easy
题目链接:点击打开链接题意:给你一个数组以及一个目标数target, 返回两个数的下标使得这两个数的和为targe. 题目假设有且仅有一组答案。思路:枚举两个数的下标暴力求解即可。代码:class Solution {public: vector twoSum(vector& nums, int target) {原创 2016-11-07 11:33:45 · 311 阅读 · 0 评论 -
LeetCode 44.Wildcard Matching题目解析
descriptionImplement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The ma原创 2018-01-08 11:51:30 · 243 阅读 · 0 评论 -
LeetCode 37.Sudoku Solver题目解析
DescriptionWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.原创 2018-01-09 19:15:48 · 358 阅读 · 0 评论 -
LeetCode 769. Max Chunks to Make Sorted I题目解析
转载源:戳这儿转载自:显然arr[i]表示第i个位置应该放置的目标位置,例如对于arr = [1, 0, 2, 3, 4],arr[0] = 1表示第0个位置的1应该放置在位置1。有了这个结论在考虑答案的一个片段s-t,s-t内的所有数的目标位置都小于等于t。例如对于片段0-1,他两的目标位置分别为[1, 0],均小于等于1。有了这个结论,我们只需使用扫描法找出所有片段转载 2018-01-28 16:26:59 · 546 阅读 · 0 评论 -
LeetCode 765. Couples Holding Hands题目解析
转载源:点击打开链接class Solution {public: int minSwapsCouples(vector<int>& row) { vector<int> pos(row.size(), 0); //记录第i个人在row数组中的位置 for(int i=0; i<row.size(); i++) ...转载 2018-02-11 11:46:40 · 1320 阅读 · 0 评论 -
LeetCode 770. Basic Calculator IV题目解析
转载源:戳这里题目解析此题是LeetCode 772的加强版,我们依然使用递归下降法来解决这个问题,文法如下:exp := exp +|- additive | additiveadditive := additive * factor | additivefactor := num | (exp) | variable(变量)我们使用vector<string>类型来表示表达式的结果...转载 2018-01-26 12:47:08 · 1611 阅读 · 0 评论