随笔分类 -  leetcode

摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read off 阅读全文
posted @ 2017-03-09 22:32 DevinGu 阅读(230) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-03-09 22:09 DevinGu 阅读(180) 评论(0) 推荐(0) 编辑
摘要:Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. solution: 阅读全文
posted @ 2017-03-08 16:22 DevinGu 阅读(249) 评论(0) 推荐(0) 编辑
摘要:Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. solution: 阅读全文
posted @ 2017-03-08 15:06 DevinGu 阅读(191) 评论(0) 推荐(0) 编辑
摘要:Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-03-06 21:24 DevinGu 阅读(161) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-03-06 21:13 DevinGu 阅读(160) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, remove the nth node from the end of list and return its head. For example, 阅读全文
posted @ 2017-03-06 19:49 DevinGu 阅读(138) 评论(0) 推荐(0) 编辑
摘要: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. 阅读全文
posted @ 2017-03-06 19:33 DevinGu 阅读(275) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2017-03-05 22:10 DevinGu 阅读(415) 评论(0) 推荐(0) 编辑
摘要: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 @ 2017-03-05 21:31 DevinGu 阅读(256) 评论(0) 推荐(0) 编辑
摘要:Solution : 1 class Solution { 2 public: 3 vector letterCombinations(string digits) { 4 if(digits.empty()) return vector(); 5 vector list={"","","abc","def","ghi","jkl","mno","... 阅读全文
posted @ 2017-03-05 20:49 DevinGu 阅读(280) 评论(0) 推荐(0) 编辑
摘要: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. 阅读全文
posted @ 2017-03-05 19:21 DevinGu 阅读(169) 评论(0) 推荐(0) 编辑
摘要: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 @ 2017-03-03 21:48 DevinGu 阅读(353) 评论(0) 推荐(0) 编辑
摘要:最长公共前缀:Write a function to find the longest common prefix string amongst an array of strings. Solution : class Solution {public: string longestCommonP 阅读全文
posted @ 2017-03-03 18:26 DevinGu 阅读(226) 评论(0) 推荐(0) 编辑
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Solution: class Solution {public: int roma 阅读全文
posted @ 2017-03-03 16:25 DevinGu 阅读(237) 评论(0) 推荐(0) 编辑
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. Solution: 以3999,为例: class Solution {public 阅读全文
posted @ 2017-03-03 11:26 DevinGu 阅读(268) 评论(0) 推荐(0) 编辑
摘要: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 @ 2017-03-02 22:17 DevinGu 阅读(103) 评论(0) 推荐(0) 编辑
摘要:Determine whether an integer is a palindrome. Do this without extra space. Solution: class Solution {public: bool isPalindrome(int x) { if(x<0|| (x!=0 阅读全文
posted @ 2017-03-01 21:09 DevinGu 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Note:The input is assumed to be a 32-bit signed integer. Yo 阅读全文
posted @ 2017-03-01 20:53 DevinGu 阅读(186) 评论(0) 推荐(0) 编辑
摘要: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 @ 2017-02-28 18:35 DevinGu 阅读(244) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示