自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(96)
  • 收藏
  • 关注

原创 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 another ar

2018-01-09 16:03:11 203

原创 leetcode—Word Search

Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically n

2018-01-08 22:00:54 349

原创 leetcode—Subsets

Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is: [

2018-01-07 09:05:49 225

原创 leetcode—Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],

2018-01-06 16:15:03 194

原创 leetcode—Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of each row

2018-01-06 16:13:06 195

原创 leetcode—Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0,

2018-01-05 22:58:52 257

原创 leetcode—Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): “123” “132” “213” “231”

2018-01-04 21:39:58 206

原创 leetcode—Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Exampl

2018-01-04 15:17:03 189

原创 leetcode—Merge Intervals

Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].class Solution { public List<Interval> merge(List<Int

2018-01-04 11:44:17 181

原创 leetcode—Spiral Matrix系列

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Yo

2018-01-04 10:04:32 217

原创 leetcode—N-Queens系列

题目链接class Solution { List<List<String>> res = new ArrayList<>(); public List<List<String>> solveNQueens(int n) { if(n<=0) return res; int[] colForRow = new int[n]; NQuee

2018-01-03 15:35:34 226

原创 leetcode—Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to

2018-01-03 10:29:56 190

原创 leetcode—Jump Game

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you

2018-01-03 09:24:17 269

原创 leetcode—Permutations

Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,

2018-01-02 17:07:03 245

原创 leetcode—First Missing Positive

Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant spac

2018-01-02 15:32:02 197

原创 leetcode—Combination Sum II

Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination.

2018-01-02 11:19:12 196

原创 leetcode—Combination Sum

Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from

2018-01-02 10:40:36 202

原创 leetcode—Plus One

Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leading zero, except the number 0 itself. The digits ar

2018-01-02 09:28:19 208

原创 leetcode— Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last word does not exist, return 0. Note: A word is define

2018-01-02 08:33:18 216

原创 leetcode-Count and Say

The count-and-say sequence is the sequence of integers with the first five terms as following:111211211111221 1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off as

2017-12-30 11:10:13 200

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

2017-12-28 11:09:14 117

原创 leetcode—Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { ListNode preHead = new ListNode(0

2017-12-22 17:31:33 128

原创 leetcode—Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent. Input:Digit string “23” Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”]class Solution {

2017-12-22 16:22:07 124

原创 leetcode_4Sum、4Sum II

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: The solution set mu

2017-12-22 15:18:24 139

原创 leetcode— 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: The solution set must not contain duplic

2017-12-22 10:42:10 113

原创 leetcode_Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.class Solution { public String longestCommonPrefix(String[] strs) { if(strs==null) return null;

2017-12-22 09:11:38 117

原创 leetcode-Roman to Integer

Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.class Solution { public int romanToInt(String s) { int sum = 0; if(s.inde

2017-12-19 21:16:16 151

原创 leetcode— Integer to Roman

Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.class Solution { public String intToRoman(int num) { String[] s1 = {"","I","II","II

2017-12-19 20:36:13 106

原创 leetcode—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, ai) and (i, 0). Find two lin

2017-12-19 19:37:28 107

原创 leetcode—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.Example: Input: “babad” Output: “bab” Note: “aba” is also a valid answer. Example:

2017-12-19 17:32:43 128

原创 leetcode—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 H N A P L S I I G

2017-12-19 16:26:31 104

原创 leetcode—Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note th

2017-12-19 11:27:46 126

原创 leetcode—Median of Two Sorted Arrays

There 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)).Example 1: nums1 = [1, 3] num

2017-12-19 11:03:09 106

原创 leetcode—Reverse Integer

Given a 32-bit signed integer, reverse digits of an integer. Example 1:Input: 123 Output: 321 Example 2:Input: -123 Output: -321 Example 3:Input: 120 Output: 21 Note: Assume we are dealing wit

2017-12-18 22:36:17 198

原创 leetcode-Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3.Given “bbbbb”, the answer is “b”, with the le

2017-12-18 16:14:25 132

原创 leetcode—Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it

2017-12-17 17:40:51 125

原创 leetcode—Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same e

2017-12-17 17:33:51 129

原创 剑指offer—整数中1的个数

题目描述 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现6次,但是对于后面问题他就没辙了。ACMer希望你们帮帮他,并把问题更加普遍化,可以很快的求出任意非负整数区间中1出现的次数。public class Solution { public int NumberOf1Betwee

2017-12-15 22:11:16 453

原创 剑指offer—数组中的逆序对

题目描述 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%1000000007public class Solution { public int InversePairs(int [] array) { if(array==null ||

2017-12-15 21:18:00 152

原创 剑指offer—数字在排序数组中出现的次数

题目描述 统计一个数字在排序数组中出现的次数。public class Solution { public int GetNumberOfK(int [] array , int k) { if(array==null || array.length<=0) return 0; int first = getFirst(array,k); in

2017-12-15 19:13:44 150

空空如也

空空如也

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

TA关注的人

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