- 博客(11)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode 537. Complex Number Multiplication(string转int,int转string)
题目:Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1: Input: “1+1i”, “1+1i” Output:
2017-03-30 19:45:21 457
原创 LeetCode 539. Minimum Time Difference
题目:Given a list of 24-hour clock time points in “Hour:Minutes” format, find the minimum minutes difference between any two time points in the list.Example 1: Input: [“23:59”,”00:00”] Output: 1 Note:
2017-03-30 13:45:15 328
原创 LeetCode 541. Reverse String II
这道题一开始看错了题目,以为只是把前2K个的k个字符反转就可以,后来wa了才发现是要把每一个2k个字符的前k个字符反转,改正了代码。class Solution {public: void inv(string &s, int t, int k){ int med = (k-t)/2 + t; for(int i = t; i <= med; i++)
2017-03-30 09:35:02 801
原创 LeetCode 53. Maximum Subarray
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. 例子:For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1]
2017-03-28 23:36:57 262
转载 浅谈C++中指针和引用的区别
看博客:http://www.cnblogs.com/dolphin0520/archive/2011/04/03/2004869.html
2017-03-27 16:49:10 180
原创 LeetCode 241. Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1 Input
2017-03-26 23:21:33 305
原创 LeetCode 4. Median of Two Sorted Arrays
这道题很经典啊,它归类在分治算法里面,感觉和求一堆数中的第k大差不多,只不过这里是有两个已经排好序的数组,所以比较麻烦一些。整体的思路如下: 1、要求出两个数列的中间数,可以转换成求第k小(大)的数; 2、要求第k小的数,可以分为将第一个数列的k/2个数和第二个数列的k/2个数进行对比,小的那一个数列的左边k/2个数就可以丢弃了,如此递归下去,递归的终止条件为:(1)如果有一个数列的长度为0,则
2017-03-26 22:41:31 250
原创 LeetCode 7.Reverse Integer/LeetCode 9.Palindrome Number
问题描述:Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Note:The input is assumed to be a 32-bit signed integer. Your function should return 0 when the rever
2017-03-20 13:49:17 488
转载 欢迎使用CSDN-markdown编辑器
欢迎使用Markdown编辑器写博客本Markdown编辑器使用[StackEdit][6]修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用
2017-03-20 13:44:31 357
原创 Leetcode240. Search a 2D Matrix II
题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right. Integers in ea
2017-03-08 20:10:42 3091
原创 Leetcode215. Kth Largest Element in an Array
这是一道分治的题目,去面网易的机器学习岗位的时候问了我这个问题,我那时候第一反应就是桶排序。。 ## 桶排序 ## 先附上桶排序的代码如下,应该注意两个地方:1、排序的数有可能是负数;2、排序的数有可能是重复的,比如[99 99],要找出第一大的数,这种情况对于判断第几大的时候要采用大于等于而不是直接用等于来判断。class Solution {public: int find
2017-03-05 22:48:33 358
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人