自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode--No.49--Group Anagrams

我今天太累了,累到刷不动。这道题抄的。有几个常用的function, 但是我不是很记得清楚的1. char[] ca = s.toCharArray()2. String aaa = String.valueOf(ch)3. return new ArrayList(ans.values());这样就不用再循环一遍重新加一次,一行代码就能搞定,一定要记住啊class Sol...

2019-05-14 09:20:58 119

原创 LeetCode--No.46--Permutations

Given a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]绝对是经典题啊还记得当初在cts的办公...

2019-05-13 20:48:21 127

原创 LeetCode--No.560--Subarray Sum Equals K

Given an array of integers and an integerk, you need to find the total number of continuous subarrays whose sum equals tok.Example 1:Input:nums = [1,1,1], k = 2Output: 2Note:The length...

2019-05-13 08:11:15 115

原创 LeetCode--No.771-Jewels and Stones

虽然是很简单的题,但是发现一个问题。就是如何遍历一个String更好一点class Solution { public int numJewelsInStones(String J, String S) { if (J == null || S == null) return 0; Set<Character> set = n...

2019-05-13 07:02:28 104

原创 LeetCode--No.31--Next Permutation

Implementnext permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o...

2019-05-13 06:48:00 107

原创 LeetCode--No.22--Generate Parentheses

Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())"...

2019-05-12 23:41:37 129

原创 LeetCode--No.1041--Robert Bounded in Circle

On an infinite plane, arobot initially stands at(0, 0)and faces north.The robot can receive one of three instructions:"G": go straight 1 unit; "L": turn 90 degrees to the left; "R": turn 90 d...

2019-05-12 12:23:25 92

原创 LeetCode--No.322--Coin Change

322.Coin ChangeMedium166272FavoriteShareYou are given coins of different denominations and a total amount of moneyamount. Write a function to compute the fewest number of coins that you need t...

2019-05-12 10:18:00 149

原创 LeetCode--No.33--Search in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,1,2,4,5,6,7]might become[4,5,6,7,0,1,2]).You are given a target value to search. If found ...

2019-05-10 10:08:57 91

原创 LeetCode--No.11--Container With Most Water

Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find two...

2019-05-09 11:23:19 256

原创 LeetCode--No.138--Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return adeep copyof the list.Example 1:Input:{"$id":"1...

2019-05-09 10:52:25 106

原创 LeetCode--No.253--Meeting Rooms II

Given an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...](si< ei), find the minimum number of conference rooms required.Example 1:Input: [[0, 30],[5, 1...

2019-05-08 20:32:05 159

原创 LeetCode--No.15--3Sum

早上睡醒了不能玩手机啊,晚上睡觉的时候手机还是要放得远一点。抄了一道3sum. 有机会复习一下吧。感觉以后即使用最笨的方法,也要写出来跑一下才可以。要复习一下不同数据结构之间的转换,晚上总结一下。class Solution { public List<List<Integer>> threeSum(int[] nums) { List...

2019-05-07 20:42:16 69

原创 LeetCode--No.973--K Closest Points to Origin

We have a list ofpointson the plane. Find theKclosest points to the origin(0, 0).(Here, the distance between two points on a plane is the Euclidean distance.)You may return the answer in any...

2019-05-06 20:39:57 138

原创 LeetCode--No.3--Longest Substring Without Repeating Characters

Given a string, find the length of thelongest substringwithout repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:...

2019-05-06 20:03:32 137

原创 LeetCode--No.5--Longest Palindromic Substring

Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.Exa...

2019-04-10 11:56:30 86

原创 LeetCode -- 904 -- Fruit into Baskets

又刷起来啦。不打算贴具体的实现了。但还是写一下心得吧。LeetCode 904 Fruit into Baskets题号大的题,果然比较新,变化多端。还是消化了一下,才能够把题目抽象出来。总之是说,给一个数组,找出最多连续多少个element, 只包含两个不同的数字。先是暴力的话,O(n*n)肯定能算出来,但是要优化。这个问题又不会涉及到二分法,再加上是数组问题,所以复杂度上只能优化...

2019-04-03 11:15:23 118

原创 碎碎念

我觉得一个问题搞不定的时候一定要记得仔细读代码,不要放过每一个细节。细节里面就能说明问题。有些想不明白的问题,不太可能是电脑出错了。尤其是,关于电脑是否出错的情况已经进行过验证的前提下。那么从现有的代码里,就可以获得一些信息去解决。...

2019-01-11 03:45:44 80

原创 很久没来了

很久没来了,有一年那么久。2017年后来情绪抑郁,就放纵自己不再刷题了。2018年因为CSDN需要手机号绑定,而我的号又刚刚好被注销,所以刷过的题就没有再记录上来。再后来就专心准备找工作,虽然过程很虐心,但也还算幸运。然而好运不会总是光顾,倒霉了好几个月,总是和身体里大大小小的毛病做斗争。突然意识到,年龄稍微大一些之后,也许身体再也不会像小时候一样清清爽爽了,所以要学会和不那么舒服的自己妥协。...

2019-01-10 12:59:10 124

原创 忏悔

说好的4月之前刷完Array呢。我又放纵了半个月没刷题。。。我受不了自己了T.T我要谴责一下自己。这星期我要刷完Array然后吃小肥羊的火锅!

2017-04-11 05:17:11 307

原创 LeetCode--No.80--Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi

2017-03-28 00:31:53 277

原创 LeetCode--No.78--Subsets

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

2017-03-27 23:41:26 291

原创 LeetCode--No.75--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

2017-03-27 22:50:58 326

原创 LeetCode--No.74--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

2017-03-26 10:01:56 262

原创 LeetCode--No.63--Unique Paths II

Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the

2017-03-25 04:42:42 368

原创 LeetCode--No.62--Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the

2017-03-25 04:33:58 345

原创 LeetCode--No.56--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].代码在此:/** * Definition for an interval. * p

2017-03-24 10:53:27 331

原创 分界线?

好久没登了。今天偶然发现了一个小粉丝,还有访问量居然四位数了,觉得很是神奇。都是去年暑假时候刷的easy题了,记得当时刷的吭哧瘪肚的。后来开学了,忙到哭,又急着找实习。后来就神奇地以及万分幸运地找到了实习。后来就开始忙实习。忙这个。忙那个的。刷题就这么耽搁了整半年。哎。要是勤快的人,早就刷完了,可能还不止一遍。~~~~~~~~~~~~前一阵子amazon面跪了,虽然面的晚,没位

2017-03-24 03:45:38 452

原创 LeetNode--No.7--Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321一开始呢,我的思路是很好的。于是我写下了这些代码public class Solution { public int reverse(int x) { int symbol

2016-09-09 11:42:22 383

原创 LeetCode--No.204--Count Primes

Description:Count the number of prime numbers less than a non-negative number, n.Credits:Special thanks to @mithmatt for adding this problem and creating all test cases.不敢说是自己的思路。我发现我刷

2016-09-06 03:53:47 220

原创 LeetCode--No.303--Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange

2016-09-05 05:18:24 201

原创 LeetCode--No.28--Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Subscribe to see which companies asked this question真的需要更多的考虑一

2016-09-05 05:04:49 198

原创 LeetCode--No.67--Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Subscribe to see which companies asked this question注意StringBuilder的用法。app

2016-09-05 04:35:14 281

原创 LeetCode--No.1--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.Example:Given nums =

2016-09-05 03:12:20 254

原创 LeetCode--No.14--Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.Subscribe to see which companies asked this question哎。。不认识prefix。。。脑残啊public class Solution { publ

2016-08-25 22:40:46 242

原创 LeetCode--No.190--Reverse Bits

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010

2016-08-25 22:24:03 336

原创 LeetCode--No.203--Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special thanks

2016-08-19 03:47:39 180

原创 LeetCode--No.234--Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?Subscribe to see which companies asked this question空间复杂度O(n)的思路很容

2016-08-18 09:10:13 207

原创 LeetCode--No.219--Contains Duplicate II--有个地方不太懂

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.

2016-08-18 03:43:05 225

原创 LeetCode--No.88--Merge Sorted Array

Given 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) to hold addit

2016-08-18 02:31:26 183

空空如也

空空如也

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

TA关注的人

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