笔试题
文章平均质量分 64
愤怒的菜鸟_
修行之路。。。
展开
-
leetcode:Regular Expression Matching [10]
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st原创 2016-08-06 21:43:57 · 221 阅读 · 0 评论 -
leetcode:Container With Most Water [11]
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 endpoints of line i is at (i, ai) and (i,原创 2016-08-08 21:13:41 · 169 阅读 · 0 评论 -
leetcode:4Sum [18]
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 which gives the sum of target.Note: The solution原创 2016-08-15 10:14:46 · 187 阅读 · 0 评论 -
leetcode:Letter Combinations of a Phone Number [17]
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st原创 2016-08-15 10:13:40 · 151 阅读 · 0 评论 -
leetcode:Integer to Roman [12]
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.class Solution { public: string intToRoman(int num) { string thousand[原创 2016-08-08 21:15:31 · 224 阅读 · 0 评论 -
leetcode:Roman to Integer [13]
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution {public: int getVal(char a) { switch (a) { case 'I': return 1原创 2016-08-09 22:27:31 · 159 阅读 · 0 评论 -
leetcode:Longest Common Prefix [14]
Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vector& strs) { if (strs.size() == 0) return "";原创 2016-08-09 22:29:42 · 155 阅读 · 0 评论 -
leetcode:3Sum [15]
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 zero.Note: The solution set must not contain原创 2016-08-11 22:07:06 · 148 阅读 · 0 评论 -
leetcode:3Sum Closest [16]
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact原创 2016-08-11 22:08:49 · 152 阅读 · 0 评论 -
leetcode:Valid Parentheses [20]
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va原创 2016-08-16 22:08:14 · 211 阅读 · 0 评论 -
leetcode:Remove Nth Node From End of List [19]
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the原创 2016-08-16 22:06:55 · 212 阅读 · 0 评论 -
leetcode[7] Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321class Solution {public: int reverse(int x) { if (x > 0) { int a = 0, b; while (x > 0)原创 2016-08-04 10:54:42 · 140 阅读 · 0 评论 -
leetcode[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 pattern in a fixed font for better legibility)P A H NA P L S I原创 2016-08-04 10:53:26 · 128 阅读 · 0 评论 -
leetcode[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, and there exists one unique longest palindromic substring.clas原创 2016-08-04 10:51:38 · 181 阅读 · 0 评论 -
leetcode之Construct Binary Tree from Preorder and Inorder Traversal
题目:Given preorder and inorder traversal of a tree, construct the binary tree.根据前序序列和中序序列构建二叉树。思路:前序序列的第一数必然是根结点,中序序列中,在该根结点前面的数均为根结点的左子树结点,该结点后面的数均为根结点的右子树结点,根据这个规律不断递归即可构建完整的二叉树。代码/** * De原创 2016-06-27 09:00:38 · 204 阅读 · 0 评论 -
leetcode:Palindrome Number [9]
Determine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { int d = x; int a = 0; if (x >= 0) while (x != 0) { a原创 2016-08-06 21:42:38 · 171 阅读 · 0 评论