
数组类型
低空飞行的
一枚奋勇争先的小菜鸡
展开
-
Boyer–Moore majority vote algorithm 博耶-穆尔多数投票算法 leetcode第229题
import java.util.ArrayList; import java.util.List; public class MajorElements229 { public List majorityElement1(int[] nums) //算法的精妙之处在于,如果不存在多于三分之一的元素的值,则次多元素是错误的,所有还要在最后做一次遍历和统计。 { List mylist=n原创 2016-06-04 10:54:47 · 1258 阅读 · 0 评论 -
Summary Ranges 228
题目要求: 228. Summary Ranges My Submissions Question Editorial Solution Total Accepted: 47215 Total Submissions: 191166 Difficulty: Medium Given a sorted integer array without duplicates, retu原创 2016-06-04 20:02:54 · 351 阅读 · 0 评论 -
一道简单的题被做的很难
209. Minimum Size Subarray Sum My SubmissionsQuestionEditorial SolutionTotal Accepted: 40966 Total Submissions: 150450 Difficulty: MediumGiven an array of n positive integers and a positive integer s,原创 2016-06-05 11:23:53 · 530 阅读 · 0 评论 -
用二分法找到数组山峰值
public int findPeakElement(int[] nums) { int N = nums.length; if (N == 1) { return 0; } int left = 0, right = N - 1; while (right - left > 1) { int mid = left + (ri原创 2016-06-13 19:53:48 · 2668 阅读 · 0 评论 -
在旋转数组中找最小的值
原题如下所示: 153. Find Minimum in Rotated Sorted Array My Submissions Question Editorial Solution Total Accepted: 96116 Total Submissions: 261936 Difficulty: Medium Suppose a s原创 2016-06-16 14:59:27 · 341 阅读 · 0 评论 -
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,原创 2016-07-16 11:52:09 · 257 阅读 · 0 评论