自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

cravingszy的博客

想要更好的东南小渣渣...

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

原创 88. Merge Sorted Array

Merge Sorted ArrayGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n

2016-01-27 11:16:52 173

原创 21.Merge Two Sorted Lists

Merge Two Sorted Lists合并两个有序序列 此题非常简单 不做解释 public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if(l1 == null) return l2; if(l2 == nu

2016-01-25 15:58:11 159

原创 20. Valid Parentheses

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

2016-01-23 20:40:01 156

原创 14. Longest Common Prefix

Longest Common Prefix最长的公共前缀    想法:以第一个字符串为公共前缀然后依次向后面遍历 这道题挺简单 主要多注意运行时间public class Solution { public String longestCommonPrefix(String[] strs) { if(strs == null || strs.length == 0)

2016-01-22 16:20:44 182

原创 17. Letter Combinations of a Phone Number

Letter Combinations of a Phone NumberInput:Digit string “23” Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”]. 使用回溯法:

2016-01-22 11:36:47 140

原创 18. 4Sum

4SumGiven 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.For example, given ar

2016-01-21 15:56:20 183

原创 16. 3Sum Closest

3Sum ClosestGiven 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 h

2016-01-20 16:00:01 182

原创 11. Container With Most Water

Container With Most WaterGiven 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)

2016-01-19 22:14:11 155

原创 19. Remove Nth Node From End of List

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

2016-01-19 10:22:49 122

原创 12. Integer to Roman

Integer to Romanps:把几种特殊的情况都列出来,然后进行加减即可代码public class solution{ public string intToRoMan(int num){ int[] values = {1000,900,500,400,100,90,50,40,10,9,5,4,1}; String[] strs = {"M"

2016-01-18 15:08:19 188

转载 String、StringBuffer、StringBullider

String、StringBuffer、StringBullider的区别?String 字符串常量 StringBuffer 字符串变量(线程安全) StringBuilder 字符串变量(非线程安全) 1)、 简要的说, String 类型和 StringBuffer 类型的主要性能区别其实在于: String 是不可变的对象, 因此在每次对 String 类型进行改变的时候其实都等

2016-01-18 14:53:23 323

原创 13. Roman to Integer

Roman to IntegerGiven a roman numeral, convert it to an integer; and Input is guaranteed to be within the range from 1 to 3999.关于罗马数字I、V、X、L、C、D、M 分别表示1、5、10、50、100、500、1000; 右加左减:在一个较大的罗马数字的右边记上一个较

2016-01-17 22:48:10 166

原创 10. Regular Expression Matching

Regular Expression Matching题目意思:给两个字符串 按照规则进行匹配 输出结果 是true or false‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. Some examples: isMatch(“aa”,”a”) → false is

2016-01-16 22:09:27 144

原创 9. Palindrome Number

Palindrome Number回文数 从左读和从右读都是一样的代码public class Solution { public boolean isPalindrome(int x) { if(x<0 || (x!=0 && x%10==0)) return false;) int rev = 0; while(x > rev){

2016-01-14 23:22:23 186

原创 8. String to Integer (atoi)

String to Integer (atoi)主要考虑有哪些的输入情况,并进行分析 空白 空格 符号位 溢出 Integer.MAX_VALUE=0x7FFFFFFF Integer.MIN_VALUE=0X8000000public class Solution { public int myAtoi(String str) { int index = 0, si

2016-01-13 16:05:35 268

原创 7. Reverse Integer

Reverse Integer颠倒数; Example1: x = 123, return 321 Example2: x = -123, return -321代码public class soultion{ public int reverse(int x) { int result = 0; while(x != 0){ int y

2016-01-13 15:03:56 169

原创 6. ZigZag Conversion

ZigZag Conversion题目大意:For example: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 legibi

2016-01-12 20:17:31 146

原创 5.Longest Palindromic Substring

Longest Palindromic SubstringGiven 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 substrin

2016-01-11 18:39:27 161

原创 4. Median of Two Sorted Arrays

Median of Two Sorted ArraysThere are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n))注意:即

2016-01-10 23:45:43 115

原创 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 f

2016-01-08 11:44:00 179

原创 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 return it as a link

2016-01-07 20:23:19 156

原创 15、3SUM

For example: given array S = {-1 0 1 2 -1 -4}, A solution set is: (-1, 0, 1) (-1, -1, 2)思路:使用指针(Two Pointers) 先将给出的数组按照进行排序 然后依次遍历后面的数令后面的两个数之和等于前面的数(因为需要找出三个数

2016-01-07 16:02:30 165

原创 1、Two Sum

> 1、Two SumInput: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2> 2、思路:使用hash表然后开始遍历 先减去第一个数查找key 如果false则进行map.get (key value) 如果true则输出result[0]/result[1]> 3、代码: public class So

2016-01-07 14:24:14 168

空空如也

空空如也

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

TA关注的人

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