随笔分类 -  Array

摘要:[抄题]: We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the 阅读全文
posted @ 2018-08-21 10:37 苗妙苗 阅读(255) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increas 阅读全文
posted @ 2018-08-12 14:40 苗妙苗 阅读(172) 评论(0) 推荐(0)
摘要:[抄题]: Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: 阅读全文
posted @ 2018-08-12 09:37 苗妙苗 阅读(182) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: [暴力解法]: 阅读全文
posted @ 2018-08-11 10:14 苗妙苗 阅读(344) 评论(0) 推荐(0)
摘要:gas = [1,2,3,4,5], cost = [3,4,5,1,2]index =[0,1,2,3,4]//cost = index - 1 [抄题]: There are N gas stations along a circular route, where the amount of g 阅读全文
posted @ 2018-08-09 16:23 苗妙苗 阅读(292) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appe 阅读全文
posted @ 2018-08-03 08:37 苗妙苗 阅读(311) 评论(0) 推荐(0)
摘要:[抄题]: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may 阅读全文
posted @ 2018-08-02 22:04 苗妙苗 阅读(135) 评论(0) 推荐(0)
摘要:[抄题]: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Example 2: [暴力解法]: 时间分析: 空间分 阅读全文
posted @ 2018-07-31 17:25 苗妙苗 阅读(141) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[ 阅读全文
posted @ 2018-07-31 10:06 苗妙苗 阅读(188) 评论(0) 推荐(0)
摘要:[抄题]: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: 阅读全文
posted @ 2018-07-30 11:12 苗妙苗 阅读(224) 评论(0) 推荐(0)
摘要:[抄题]: Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Exampl 阅读全文
posted @ 2018-07-26 14:28 苗妙苗 阅读(134) 评论(0) 推荐(0)
摘要:[抄题]: Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Example 2: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空 阅读全文
posted @ 2018-05-15 22:22 苗妙苗 阅读(124) 评论(0) 推荐(0)
摘要:[抄题]: Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you coul 阅读全文
posted @ 2018-05-14 22:44 苗妙苗 阅读(274) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. Acc 阅读全文
posted @ 2018-05-11 10:41 苗妙苗 阅读(151) 评论(0) 推荐(0)
摘要:[抄题]: 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 e 阅读全文
posted @ 2018-05-05 17:12 苗妙苗 阅读(141) 评论(0) 推荐(0)
摘要:[抄题]: Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. Now, you are g 阅读全文
posted @ 2018-04-28 11:19 苗妙苗 阅读(115) 评论(0) 推荐(0)
摘要:[抄题]: We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1. Now, given an intege 阅读全文
posted @ 2018-04-26 10:58 苗妙苗 阅读(142) 评论(0) 推荐(0)
摘要:[抄题]: he set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to anot 阅读全文
posted @ 2018-04-25 21:59 苗妙苗 阅读(159) 评论(0) 推荐(0)
摘要:[抄题]: Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) a 阅读全文
posted @ 2018-04-22 22:30 苗妙苗 阅读(135) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the s 阅读全文
posted @ 2018-04-22 16:54 苗妙苗 阅读(97) 评论(0) 推荐(0)