随笔分类 -  Leetcode (C++)

上一页 1 ··· 5 6 7 8 9 10 下一页

21.Merge Two Sorted Lists (List)
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def... 阅读全文

posted @ 2015-07-30 18:33 joannae 阅读(213) 评论(0) 推荐(0)

20.Valid Parentheses (Stack)
摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文

posted @ 2015-07-29 21:09 joannae 阅读(290) 评论(0) 推荐(0)

19.Remove Nth Node From End of List(List; Two-Pointers)
摘要:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文

posted @ 2015-07-29 20:41 joannae 阅读(177) 评论(0) 推荐(0)

18.4Sum (Map)
摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文

posted @ 2015-07-29 20:05 joannae 阅读(249) 评论(0) 推荐(0)

17.Letter Combinations of a Phone Number(Back-Track)
摘要:Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho 阅读全文

posted @ 2015-07-25 21:48 joannae 阅读(266) 评论(0) 推荐(0)

16.3Sum Closest (Two-Pointers)
摘要:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文

posted @ 2015-07-25 15:47 joannae 阅读(173) 评论(0) 推荐(0)

15.3Sum (Two-Pointers)
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文

posted @ 2015-07-25 06:48 joannae 阅读(164) 评论(0) 推荐(0)

14.Longest Common Prefix (String)
摘要:Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vector& st... 阅读全文

posted @ 2015-07-24 06:13 joannae 阅读(237) 评论(0) 推荐(0)

13.Roman to Integer (HashTable)
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Improve: 使用两个数组代替map,更节省空间。 阅读全文

posted @ 2015-07-23 20:28 joannae 阅读(159) 评论(0) 推荐(0)

9.Palindrome Number (INT)
摘要:Determine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { if(x = 1){ ... 阅读全文

posted @ 2015-07-22 01:27 joannae 阅读(224) 评论(0) 推荐(0)

12. Integer to Roman (HashTable)
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 思路:罗马数字共有七个,即I(1),V(5),X(10),L(50),C(100), 阅读全文

posted @ 2015-07-21 06:24 joannae 阅读(140) 评论(0) 推荐(0)

11.Container With Most Water (Array; Two-Pointers)
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo 阅读全文

posted @ 2015-07-20 20:30 joannae 阅读(148) 评论(0) 推荐(0)

10.Regular Expression Matching (String; Back-Track,DP)
摘要:Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding elemen 阅读全文

posted @ 2015-07-18 07:02 joannae 阅读(244) 评论(0) 推荐(0)

8.String to Integer (atoi) (INT; Overflow)
摘要:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below a... 阅读全文

posted @ 2015-07-16 08:18 joannae 阅读(198) 评论(0) 推荐(0)

7.Reverse Integer (INT; Overflow)
摘要:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321思路:要注意溢出。用以下做法,会溢出。class Solution {public: int reverse(in... 阅读全文

posted @ 2015-07-15 15:58 joannae 阅读(171) 评论(0) 推荐(0)

6.ZigZag Conversion(Graph, traverse)
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文

posted @ 2015-07-15 09:13 joannae 阅读(385) 评论(0) 推荐(0)

5.Longest Palindromic Substring (String; DP, KMP)
摘要:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes 阅读全文

posted @ 2015-07-14 09:14 joannae 阅读(253) 评论(0) 推荐(0)

4. Median of Two Sorted Arrays(Array; Divide-and-Conquer)
摘要: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 阅读全文

posted @ 2015-07-12 16:11 joannae 阅读(275) 评论(0) 推荐(0)

3.Longest Substring Without Repeating Characters(string; HashTable)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo 阅读全文

posted @ 2015-07-11 06:03 joannae 阅读(255) 评论(0) 推荐(0)

2.Add Two Numbers (List)
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文

posted @ 2015-07-10 19:35 joannae 阅读(156) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 下一页

导航