随笔分类 -  LeetCode

上一页 1 ··· 4 5 6 7 8 9 下一页
leetcode第31题--Longest Valid Parentheses
摘要:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2014-10-22 23:11 higerzhang 阅读(250) 评论(0) 推荐(0)
leetcode第30题--Next Permutation
摘要:problem:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not... 阅读全文
posted @ 2014-10-22 00:28 higerzhang 阅读(191) 评论(0) 推荐(0)
leetcode第29题--Substring with Concatenation of All Words
摘要:problem:You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a con... 阅读全文
posted @ 2014-10-21 23:19 higerzhang 阅读(313) 评论(0) 推荐(0)
leetcode第28题--Divide Two Integers
摘要:Divide two integers without using multiplication, division and mod operator.分析:题目意思很容易理解,就是不用乘除法和模运算求来做除法,很容易想到的一个方法是一直做减法,然后计数,超时。在网上找到一种解法,利用位运算,意思是... 阅读全文
posted @ 2014-10-21 00:51 higerzhang 阅读(271) 评论(0) 推荐(0)
leetcode第27题--Implement strStr()
摘要:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.就是判断haystack中是否有needle,如果包... 阅读全文
posted @ 2014-10-21 00:09 higerzhang 阅读(249) 评论(0) 推荐(0)
leetcode第26题--Remove Duplicates from Sorted Array
摘要:problem: Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra sp... 阅读全文
posted @ 2014-10-20 21:03 higerzhang 阅读(220) 评论(0) 推荐(0)
leetcode第25题--Remove Element
摘要:problem:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doe... 阅读全文
posted @ 2014-10-20 17:50 higerzhang 阅读(259) 评论(0) 推荐(0)
leetcode第24题--Reverse Nodes in k-Group
摘要:problem:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthe... 阅读全文
posted @ 2014-10-20 17:18 higerzhang 阅读(323) 评论(0) 推荐(0)
leetcode第23题--Swap Nodes in Pairs
摘要:Problem:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Yo... 阅读全文
posted @ 2014-10-20 12:08 higerzhang 阅读(325) 评论(0) 推荐(0)
leetcode第22题--Merge k Sorted Lists
摘要:problem:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.先合并两个list,再根据归并排序的方法递归合并。假设总共有k个list,每个list的最大... 阅读全文
posted @ 2014-10-20 00:56 higerzhang 阅读(163) 评论(0) 推荐(0)
leetcode第21题--Generate Parentheses
摘要:problem:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is... 阅读全文
posted @ 2014-10-19 23:46 higerzhang 阅读(174) 评论(0) 推荐(0)
leetcode第20题--Valid Parentheses
摘要:Problem:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the ... 阅读全文
posted @ 2014-10-19 00:19 higerzhang 阅读(179) 评论(0) 推荐(0)
leetcode第19题--Remove Nth Node From End of List
摘要:Problem: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. ... 阅读全文
posted @ 2014-10-18 23:45 higerzhang 阅读(192) 评论(0) 推荐(0)
leetcode第18题--Letter Combinations of a Phone Number
摘要:Problem:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the ... 阅读全文
posted @ 2014-10-18 23:26 higerzhang 阅读(169) 评论(0) 推荐(0)
leetcode第17题--4Sum
摘要:Problem:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the... 阅读全文
posted @ 2014-10-17 21:03 higerzhang 阅读(241) 评论(0) 推荐(0)
leetcode第16题--3Sum Closest
摘要:Problem:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integer... 阅读全文
posted @ 2014-10-17 12:29 higerzhang 阅读(301) 评论(0) 推荐(0)
leetcode第15题--3Sum
摘要:Problem:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Not... 阅读全文
posted @ 2014-10-16 22:41 higerzhang 阅读(317) 评论(0) 推荐(0)
leetcode第14题--Longest Common Prefix
摘要:Problems:Write a function to find the longest common prefix string amongst an array of strings.就是返回一个字符串数组的所有的公共前缀。不难。我是已第一个字符串为参考,然后依次遍历其他的字符串,一旦遇到不同... 阅读全文
posted @ 2014-10-16 00:07 higerzhang 阅读(195) 评论(0) 推荐(0)
leetcode第13题--Roman to Integer
摘要:Problem:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.遍历一次输入的字符串,如果不满足类似4或者9的就直接加相应的数,否则减去... 阅读全文
posted @ 2014-10-16 00:00 higerzhang 阅读(214) 评论(0) 推荐(0)
leetcode第12题--Integer to Roman
摘要:Problem:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.把阿拉伯数字转换为罗马数字输出。百度一下对应的 I V X L C D ... 阅读全文
posted @ 2014-10-15 00:53 higerzhang 阅读(297) 评论(0) 推荐(0)

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