
array
文章平均质量分 59
伊萨卡钢琴家
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode 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原创 2016-01-23 13:54:18 · 250 阅读 · 0 评论 -
Leetcode Greedy 题型总结
我自己对Greedy不是很熟悉 https://en.wikipedia.org/wiki/Greedy_algorithm 觉得greedy题也没有规律可以遵循,所以比较难 比如 134. Gas Station https://leetcode.com/problems/gas-station/如何判断从哪里开始开,就是很难,如何判断在给定的Gas和Cost的情况下能够跑完所原创 2016-01-27 09:49:26 · 1038 阅读 · 0 评论 -
Leetcode 120. Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [原创 2016-01-28 04:25:57 · 248 阅读 · 0 评论 -
Leetcode 31. Next Permutation
Implement next 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原创 2016-01-28 04:58:52 · 275 阅读 · 0 评论 -
Leetcode Wiggle Sort
Given an unsorted array nums, reorder it in-place such that nums[0] = nums[2] For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4]. /先将Array排序,然后进行两两互换。最后的结原创 2016-01-28 11:56:31 · 287 阅读 · 0 评论 -
Leetcode Two Sum II – Input array is sorted (Java)
When the array is sorted, when we want to do the sum to the target. we can scan from both sides. public int[] twoSum(int[] numbers, int target) { if (numbers == null || numbers.length == 0) return原创 2016-01-28 12:00:43 · 368 阅读 · 0 评论 -
Leetcoed 277 Find the Celebrity
Find the Celebrity Total Accepted: 1126 Total Submissions: 3603 Difficulty: Medium Suppose you are at a party with n people (labeled from 0 ton - 1) and among them, there may exi转载 2016-01-28 13:43:20 · 422 阅读 · 0 评论 -
Leetcode 287. Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,原创 2016-01-28 22:43:29 · 590 阅读 · 0 评论 -
Leetcode 283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling you原创 2016-01-28 12:50:38 · 259 阅读 · 0 评论 -
Leetcode 252 Meeting Rooms
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings. For example, Given [[0, 30],[5, 10],[原创 2016-01-29 05:11:45 · 681 阅读 · 0 评论 -
Leetcode 296 Best Meeting Point
Best Meeting Point Total Accepted: 701 Total Submissions: 1714 Difficulty: Medium A group of two or more people wants to meet and minimize the total travel distance. You are given a原创 2016-01-29 05:26:36 · 661 阅读 · 0 评论 -
Leetcode 286. Walls and Gates
You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to repres原创 2016-01-29 05:45:07 · 360 阅读 · 0 评论 -
Leetcode 215. Kth Largest Element in an Array
public class Solution { public int findKthLargest(int[] nums, int k) { int length = nums.length; } public int helper(int[] nums, int k, int start, int end){ int pivot = nums[e原创 2016-01-29 23:55:58 · 340 阅读 · 0 评论 -
Leetcode 84. Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width o转载 2016-01-24 11:31:19 · 509 阅读 · 0 评论 -
Leetcode 162. Find Peak Element
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in转载 2016-01-24 11:18:52 · 361 阅读 · 0 评论 -
Leetcode Array题型总结
Dynamic Programming 62. Unique Paths https://leetcode.com/problems/unique-paths/ 63. Unique Paths II https://leetcode.com/problems/unique-paths-ii/ 120. Triangle h原创 2016-01-24 09:51:12 · 487 阅读 · 0 评论 -
Leetcode 63. Unique Paths II
question: 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 respect原创 2016-01-23 14:03:28 · 277 阅读 · 0 评论 -
Leetcode 1. Two Sum
question Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to t原创 2016-01-23 14:07:00 · 276 阅读 · 0 评论 -
Leetcode 54. 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 ] ]原创 2016-01-23 14:41:49 · 422 阅读 · 0 评论 -
Leetcode 73. Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.public class Solution { public void setZeroes(int[][] matrix) { int m = matrix.length; if原创 2016-01-23 14:48:01 · 276 阅读 · 0 评论 -
Leetcode 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-01-23 15:01:55 · 261 阅读 · 0 评论 -
Leetcode 33. Search in Rotated Sorted Array
Leetcode 33. Search in Rotated Sorted Array question: Suppose a sorted array 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原创 2016-01-24 05:08:13 · 298 阅读 · 0 评论 -
Leetcode 81. Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the原创 2016-01-24 05:22:49 · 298 阅读 · 0 评论 -
Leetcode 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原创 2016-01-24 05:29:47 · 265 阅读 · 0 评论 -
Leetcode 189. Rotate Array
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. The idea is from http://www.programcreek.com/原创 2016-01-24 05:41:38 · 304 阅读 · 0 评论 -
Leetcode 238. Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O原创 2016-01-24 05:48:27 · 293 阅读 · 0 评论 -
Leetcode 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原创 2016-01-24 09:24:59 · 534 阅读 · 0 评论 -
Leetcode 27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length. T原创 2016-01-24 09:52:23 · 278 阅读 · 0 评论 -
Leetcode 78. Subsets
Given a set of distinct integers, nums, return all possible subsets. Analysis, just to use the former result and then add some elements to the result set. public class Solution { public List>原创 2016-01-23 14:37:30 · 242 阅读 · 0 评论