自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 48. Rotate Image

The idea was firstly transpose the matrix and then flip it symmetrically. For instance,1 2 3 4 5 67 8 9after transpose, it will be swap(matrix[i][j], matrix[j]...

2019-03-12 23:47:03 93

原创 34. Find First and Last Position of Element in Sorted Array

Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the...

2019-03-05 22:52:02 92

原创 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-03-05 21:50:19 112

原创 561. Array Partition I(Java)

给定一个2n整数数组,您的任务是将这些整数分组为n对整数,例如(a1,b1),(a2,b2),…,(an,bn),它使所有i的min(ai,bi)之和尽可能大,从1到n。 例1: 输入:[1,4,3,2] 产量:4 说明:n为2,对的最大和为4=min(1,2)+min(3,4)。 ...

2019-03-02 10:35:08 156

原创 565.Array Nesting Java

题目:A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below.S...

2019-03-02 10:17:21 128

原创 Leetcode 989:数组形式的整数加法

对于非负整数 X 而言,X 的数组形式是每位数字按从左到右的顺序形成的数组。例如,如果 X = 1231,那么其数组形式为 [1,2,3,1]。给定非负整数 X 的数组形式 A,返回整数 X+K 的数组形式。示例 1:输入:A = [1,2,0,0], K = 34输出:[1,2,3,4]解释:1200 + 34 = 1234123解释 2:输入:A = [2,7,4], K = ...

2019-02-28 11:02:29 356

原创 Leetcode算法Java全解答--18. 四数之和

题目给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。注意:答案中不可以包含重复的四元组。示例:给定数组 nums = [1, 0, -1, 0, -2, 2],和 target = 0。满足要求的四元组集合为:...

2019-02-25 10:27:46 277

转载 算法设计——解决 3Sum 以及 3Sum Closest 问题

常写算法,多动脑,不会老!3Sum问题: 若不考虑效率问题,则解决该问题的思路就很简单直接,三个 for 循环遍历穷举即可。一个优秀的程序员肯定不能忍受这么无脑的时间复杂度,于是先想到先对全部数据进行排序操作,然后设置三个指针,数组的首尾各一,第三个指针从首位+1开始。设置合理的条件限制,移动指针。该过程中需要解决去重问题。废话不多说,贴代码: vector<vecto...

2019-02-25 00:01:07 154

原创 LeetCode string刷题49 Group Anagrams

原题:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[  ["ate", "eat","tea"],  [&quot

2019-01-16 12:01:50 84

原创 LeetCode string系列刷题 Java 58. 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 defi...

2019-01-13 11:16:12 129

原创 LeetCode 15 3sum

15. 3SumMedium  Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The so...

2019-01-12 13:04:15 92

原创 LeetCode 4 JAVA 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)).You may assume nums...

2019-01-11 21:31:45 368 2

原创 LeetCode11 Container With Most Water Java解法

题意分析给定 n 个非负整数 a1,a2,…,an,每个数代表坐标中的一个点 (i, ai) 。画 n 条垂直线,使得垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的矩形可以容纳最多的水。注意:你不能倾斜容器,n 至少是2 比较容易想到的解法,0(n2) 遍历全部 class Solution { pub...

2019-01-10 22:08:37 202

原创 LeetCode206

. Reverse Linked List Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLclass Solution { public ListNode reverse...

2019-01-08 21:43:55 108

转载 leetcode twosum Java解法

题目: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 ...

2019-01-06 18:36:46 99

空空如也

空空如也

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

TA关注的人

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