
LeetCode
文章平均质量分 74
meteor^_^
这个作者很懒,什么都没留下…
展开
-
剑指offer-03.找出数组中重复的数字
给定一个长度为n的整数数组nums,数组中所有的数字都在0∼n−1的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。注意:如果某些数字不在0∼n−1的范围内,或数组中不包含重复数字,则返回 -1;样例给定 nums = [2, 3, 5, 4, 3, 2, 6, 7]。 返回 2 或 3。...原创 2021-02-23 22:12:34 · 381 阅读 · 1 评论 -
sort-colors
packagecom.ytx.array;/** 题目: sort-colors * * 描述: Given an array with n objects colored red, white or blue, sort them so that objects of the same color * are adjacen原创 2017-09-11 22:32:35 · 213 阅读 · 0 评论 -
remove-duplicates-from-sorted-array-ii
packagecom.ytx.array;/** 题目:remove-duplicates-from-sorted-array-ii * * 描述: Follow up for "Remove Duplicates": * What if duplicates are allowed at most twice?原创 2017-09-11 22:38:20 · 269 阅读 · 0 评论 -
remove-element
packagecom.ytx.array;/** 题目:remove-element * * 描述: Given an array and a value, remove all instances of that value in place and return the new length. The order of elem原创 2017-09-11 22:40:24 · 221 阅读 · 0 评论 -
container-with-most-water
packagecom.ytx.array;/** 题目: container-with-most-water * * 描述: Given n non-negative integers a1 , a2 , ..., an , where each represents a point at * coordinate (i,ai原创 2017-09-11 22:42:27 · 237 阅读 · 0 评论 -
two-sum
packagecom.ytx.hash;importjava.util.Arrays;importjava.util.HashMap;/** * 题目:two-sum * * 描述: Given an array of integers, find two numbers such that they add up to a specific tar原创 2017-09-11 22:44:06 · 197 阅读 · 0 评论 -
4sum
packagecom.ytx.hash;importjava.util.ArrayList;importjava.util.Arrays;/** 题目: 4sum * * 描述: Given an array S of n integers, are there elements a, b, c, * and d in原创 2017-09-11 22:45:52 · 185 阅读 · 0 评论 -
3sum
package com.ytx.hash;import java.util.ArrayList;import java.util.Arrays;/** 题目:3sum * * 描述: Given an array S of n integers, are there elements a, b, c in S such that a + b + c原创 2017-09-11 22:47:43 · 187 阅读 · 0 评论 -
Maximum_Subarray
packagecom.ytx.dp;/** 题目描述:给定一个整数数组,如{-1,3,6,0,-9,2,-5,-1,9,3,-3},求该数组中的和最大的连续子序列 * *@authoryuantian xin * * 以下是根据之前dp算法的进一步优化,优化空间,并不需要一个数组来打表,可以用两个变量即可。 */publicclass原创 2017-09-11 22:48:56 · 212 阅读 · 0 评论 -
first-missing-positive
packagecom.ytx.array;importjava.util.Arrays;/** 题目:first-missing-positive * * 描述: Given an unsorted integer array, find the first missing positive integer. Fo原创 2017-09-11 22:51:00 · 401 阅读 · 0 评论 -
next-permutation
packagecom.ytx.array;/** * 题目 : next-permutation * * 描述: Implement next permutation, which rearranges numbers into the lexicographically * next greater permutation of num原创 2017-09-11 22:52:15 · 236 阅读 · 0 评论 -
3sum-closest
packagecom.ytx.array;importjava.util.Arrays;/** 题目: 3sum-closest * * 描述: Given an array S of n integers, find three integers in S such that the sum is * closest原创 2017-09-11 22:56:40 · 379 阅读 · 0 评论 -
search-a-2d-matrix
packagecom.ytx.array;/** 题目: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:原创 2017-09-02 23:15:14 · 249 阅读 · 0 评论 -
palindrome-number
packagecom.ytx.array;/** 题目:palindrome-number * * 描述: * Determine whether an integer is apalindrome. Do this without extra space. click to show spoilers.原创 2017-09-02 23:11:14 · 167 阅读 · 0 评论 -
remove-duplicates-from-sorted-array
packagecom.ytx.array;/** 题目:remove-duplicates-from-sorted-array * * 描述:Given a sorted array, remove the duplicates in place such that each * element appear only once and return原创 2017-09-03 23:38:22 · 345 阅读 · 0 评论 -
merge-intervals
packagecom.ytx.array;importjava.util.ArrayList;importjava.util.Collections;importjava.util.Comparator;/** 题目:merge-intervals * * 描述: Given a collection of intervals, merge all原创 2017-09-04 17:56:43 · 422 阅读 · 0 评论 -
spiral-matrix
packagecom.ytx.array;importjava.util.ArrayList;importjava.util.List;/** 题目: spiral-matrix * 描述: Given a matrix of m x n elements (m rows, n columns), * return all ele原创 2017-09-04 18:00:43 · 506 阅读 · 0 评论 -
spiral-matrix-ii
packagecom.ytx.array;importjava.util.ArrayList;/** 题目:spiral-matrix-ii * * 描述: Given an integer n, generate a square matrix filled with elements from 1 to n 2 in spiral order.原创 2017-09-04 18:02:07 · 304 阅读 · 0 评论 -
Surrounded-Regions
packagecom.ytx.array;/**130题 * Given a 2D board containing'X'and'O', capture all regions surrounded by'X'. A region is captured byflipping all'O's into'X's in that surrounded region .原创 2017-09-02 17:18:10 · 291 阅读 · 0 评论 -
best-time-to-buy-and-sell-stock
packagecom.ytx.array;/** * best-time-to-buy-and-sell-stock * * Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte原创 2017-09-02 17:22:40 · 668 阅读 · 0 评论 -
best-time-to-buy-and-sell-stock-ii
packagecom.ytx.array;/**best-time-to-buy-and-sell-stock-ii * * Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the max原创 2017-09-02 17:23:54 · 189 阅读 · 0 评论 -
best-time-to-buy-and-sell-stock-iii
packagecom.ytx.array;/**best-time-to-buy-and-sell-stock-iii * * Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to fin原创 2017-09-02 17:25:19 · 179 阅读 · 0 评论 -
plus-one
packagecom.ytx.array;/** * plus-one * * Given a number represented as an * array of digits, plus one to the number. * *@authoryuantian xin * 给你一个用数组表示的数,求加一之后的结果,结果还是用数组表示。 *原创 2017-09-02 17:26:29 · 266 阅读 · 0 评论 -
Longest_consecutive_sequence
package com.ytx.array;/** * convert-sorted-array-to-binary-search-tree * * Given an array where elements are sorted in ascending order, convert it to a height balanced BST. * * @author y原创 2017-09-02 17:21:10 · 245 阅读 · 0 评论 -
convert-sorted-array-to-binary-search-tree
packagecom.ytx.array;/** * convert-sorted-array-to-binary-search-tree * * Given an array where elements are sorted in ascending order, convert it to a height balanced BST. * *@author原创 2017-09-02 17:27:23 · 167 阅读 · 0 评论 -
rotate-image
packagecom.ytx.array;/** 题目:rotate-image * * 描述: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise).原创 2017-09-03 23:36:30 · 257 阅读 · 0 评论