随笔分类 - Array
摘要:[抄题]: Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots
阅读全文
摘要:[抄题]: Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array wi
阅读全文
摘要:[抄题]: In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as m
阅读全文
摘要:[抄题]: Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to outp
阅读全文
摘要:[抄题]: Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time co
阅读全文
摘要:[抄题]: Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Example 2: [暴力解法]: 时间分析
阅读全文
摘要:[抄题]: Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is no
阅读全文
摘要:[抄题]: Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes t
阅读全文
摘要:[抄题]: Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example,Assume that w
阅读全文
摘要:[抄题]: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: [暴力解法]: 用temp,result,结果发现写起来很麻烦 时间分析: 空间分析: [优化后]: 时间分
阅读全文
摘要:[抄题]: A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if
阅读全文
摘要:[抄题]: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original
阅读全文
摘要:[抄题]: Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.
阅读全文
摘要:[抄题]: We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or
阅读全文
摘要:[抄题]: 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
阅读全文
摘要:[抄题]: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [
阅读全文
摘要:[抄题]: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1 Example 2 [暴力解法]
阅读全文
摘要:[抄题]: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩
阅读全文
摘要:[抄题]: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in t
阅读全文
摘要:[抄题]: Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as a
阅读全文

浙公网安备 33010602011771号