- 博客(9)
- 收藏
- 关注
原创 [LeetCode] Divide Two Integers
题目Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路这道题需要用到移位操作,这就涉及到一些二进制相关的概念,先普及一下:1)二进制表示中,首位是符号位,1表示复数,0表示正数2)二进制表示
2016-01-05 10:08:05 325
原创 [LeetCode] Implement strStr()
题目Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.思路按照下标递增的顺序比较haystack中的所有子字符串和needle。代码public class Solu
2016-01-05 10:04:09 259
原创 [LeetCode] Remove Element
题目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 doesn't matter what you leave beyond the new length
2016-01-05 09:57:52 252
原创 [LeetCode] Remove Duplicates from Sorted Array
题目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 for another array, you must do this in pl
2016-01-04 20:18:52 227
原创 [LeetCode] Reverse Nodes in k-Group
题目Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain
2016-01-04 20:12:49 248
原创 [LeetCode] Swap Nodes in Pairs
题目Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant
2016-01-04 20:05:00 234
原创 [LeetCode] Regular Expression Matching
题目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
2016-01-04 19:57:05 249
原创 [LeetCode] Merge k Sorted Lists
题目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.思路考察的是Two Pointers思想。开始这两个指针分别指向两个链表的头节点,每次取出这两
2016-01-04 19:47:28 220
原创 [LeetCode] Generate Parentheses
题目Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())
2016-01-04 19:37:50 256
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人