李景旺的博客

www.jingwangl.com

16. 3Sum Closest

16. 3Sum Closest 和之前3Sum那道题思路一样,刚开始想的是不用每次计算误差,只需要在小于目标和大于目标的转折点出计算两次然后临界的时候计算一次即可,可是实际上和每次都计算误差速度一样的。。。 class Solution { public: int threeSum...

2018-09-24 17:20:36

阅读数:16

评论数:0

8. String to Integer (atoi)

8. String to Integer (atoi) class Solution { public: int myAtoi(string str) { int Max = (1<<31)-1, Min = -1&a...

2018-09-20 21:06:56

阅读数:8

评论数:0

15. 3Sum

15. 3Sum class Solution { public: vector<vector<int>> threeSum(vector<int>&am...

2018-09-08 23:57:19

阅读数:10

评论数:0

11. Container With Most Water

11. Container With Most Water 设置两个指针i j ,分别指向首尾两块板,然后向中间移动,那么宽度变小的情况下为了增大面积只有让高度变大,所以每次移动所指板较低的指针,然后计算面积,重复以上过程。 int max(int a,int b){ return ...

2018-08-27 12:30:35

阅读数:34

评论数:0

14. Longest Common Prefix

14. Longest Common Prefix char s[100000]; int min(int a,int b){ return a < b ? a : b; } char* longestCommonPrefix(char** strs, int s...

2018-08-26 23:47:05

阅读数:21

评论数:0

12. Integer to Roman

12. Integer to Roman char s[100]; char* intToRoman(int num) { char rs[] = "MDCLXVI"; int ts[] = { 1000,500,100,50,10,5,1 ...

2018-08-26 23:32:36

阅读数:21

评论数:0

13. Roman to Integer

13. Roman to Integer int romanToInt(char* s) { int dic[26]; dic['I'-'A'] = 1; dic['V'-'A'] = 5; dic['X'-'A'] = 10; dic['L'-'A'...

2018-08-26 22:32:08

阅读数:21

评论数:0

10. Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character. '*' Matches zero or more of the preceding elemen...

2018-03-30 21:56:59

阅读数:20

评论数:0

9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (...

2018-03-29 23:02:43

阅读数:18

评论数:0

7. Reverse Integer

Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123 Output: 321 Example 2:Input: -123 Output: -321 Example 3:Input: 120...

2018-03-28 18:05:49

阅读数:23

评论数:0

6. ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this patte...

2018-03-28 16:53:11

阅读数:9

评论数:0

5. Longest Palindromic Substring

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad&...

2018-03-25 12:36:18

阅读数:26

评论数:0

4. Median of Two Sorted Arrays

There 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 sh...

2018-03-24 18:13:02

阅读数:15

评论数:0

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 &...

2018-03-12 08:33:45

阅读数:24

评论数:0

2. Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes conta...

2018-03-11 20:05:45

阅读数:16

评论数:0

1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have ex...

2018-03-10 08:13:49

阅读数:20

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭