自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

大气人生

点滴星沙,能塑之,能扬之,方成沙海

  • 博客(64)
  • 收藏
  • 关注

原创 Leetcode25 Reverse Nodes in k-Group

Reverse Nodes in k-Group My Submissions Question Solution 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 mu

2015-07-27 20:58:05 351

原创 Leetcode26 Remove Duplicates from Sorted Array

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 anothe

2015-07-27 13:38:03 406

原创 Leetcode 27 Remove Element

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 th

2015-07-27 12:48:12 315

原创 Leetcode 24 Swap Nodes in Pairs

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

2015-07-27 12:23:17 346

原创 Leetcode 23 Merge k Sorted Lists

Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution1将链表利用二分法两两进行合并。代码如下:public class Solution { public ListNode merg

2015-07-27 11:33:23 386

原创 Leetcode 22 Generate Parentheses

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: “((()))”, “(()())

2015-07-27 01:37:11 453

原创 Leetcode 21 Merge Two Sorted Lists

Merge Two 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.Solution1这道题思路特别清晰,就是分别从两条链表的头部开始

2015-07-26 23:34:03 352

原创 Leetcode 20 Valid Parentheses

Valid Parentheses Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “(

2015-07-26 13:02:06 301

原创 Leetcode 19 Remove Nth Node From End of List

Remove Nth Node From End of List 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 s

2015-07-26 11:54:21 313

原创 Leetcode 18 4Sum

4Sum 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: Ele

2015-07-26 10:51:14 287

原创 Leetcode 17 Letter Combinations of a Phone Number

Letter Combinations of a Phone Number 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 but

2015-07-26 01:32:43 337

原创 Leetcode 16 3Sum Closest

3Sum Closest 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 woul

2015-07-26 00:09:50 332

原创 Leetcode 15 3Sum

3Sum 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: Elements in a triplet (a

2015-07-25 16:14:41 336

原创 Leetcode 14 Longest Common Prefix

Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.Solution1最简单的方法就是遍历去比较每一个字符串。第一个字符串与第二个字符串进行比较得到一个前缀,然后拿这个前缀去跟第三个字符串去进行比较,以此类推。代码如下:publ

2015-07-25 13:01:49 583

原创 Leetcode 13 Roman to Integer

Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.Solution基本思路是将字符串中的每一个字母代表的数都加起来,但是有一种情况例外,就是当较小的单位出现在较大单位的左边时,表示要减去这个

2015-07-25 12:09:57 534

原创 Leetcode 12 Integer to Roman

Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.Solution这道题如果针对每一位用if或者switch来判断,则要枚举的情况太多,所以最简洁的方法便是将每一位的所有情况先枚举出来,然后

2015-07-25 11:11:30 579

原创 Leetcode 11 Container With Most Water

Container With Most Water 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,

2015-07-25 10:23:45 560

原创 Leetcode 9 Palindrome Number

Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer t

2015-07-25 01:25:20 527

原创 Leetcode 7 Reverse Integer

Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321Solution1像这种有可能会超出数据类型范围的情况,一般有两种比较好的解决办法:一种是用一个可以表示更大的数据类型,比如这里用long类型;另一种是用字符串去模拟大

2015-07-25 00:41:37 620

原创 Leetcode 6 ZigZag Conversion

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

2015-07-24 23:41:54 550

原创 Leetcode 5 Longest Palindromic Substring

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 subst

2015-07-24 22:20:10 454

原创 Leetcode 3 Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for

2015-07-24 09:49:52 602

原创 Leetcode 2

Add Two Numbers 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 digit. Add the two numbers and re

2015-07-23 23:53:28 948

原创 Leetcode 1

Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the

2015-07-23 22:40:05 406

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除