03 2018 档案

摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex 阅读全文
posted @ 2018-03-29 21:08 还是说得清点吧 阅读(191) 评论(0) 推荐(0)
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul 阅读全文
posted @ 2018-03-29 19:48 还是说得清点吧 阅读(837) 评论(0) 推荐(0)
摘要: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]. Not 阅读全文
posted @ 2018-03-28 22:11 还是说得清点吧 阅读(135) 评论(0) 推荐(0)
摘要: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 complexi 阅读全文
posted @ 2018-03-28 21:09 还是说得清点吧 阅读(121) 评论(0) 推荐(0)
摘要: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 an inte 阅读全文
posted @ 2018-03-28 20:11 还是说得清点吧 阅读(135) 评论(0) 推荐(0)
摘要: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 will be 阅读全文
posted @ 2018-03-26 22:30 还是说得清点吧 阅读(123) 评论(0) 推荐(0)
摘要: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 - they 阅读全文
posted @ 2018-03-26 21:56 还是说得清点吧 阅读(163) 评论(0) 推荐(0)
摘要: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  阅读全文
posted @ 2018-03-25 21:53 还是说得清点吧 阅读(110) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2018-03-25 21:16 还是说得清点吧 阅读(129) 评论(0) 推荐(0)
摘要: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 output the 阅读全文
posted @ 2018-03-25 20:38 还是说得清点吧 阅读(120) 评论(0) 推荐(0)
摘要:Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorithm to us 阅读全文
posted @ 2018-03-22 21:58 还是说得清点吧 阅读(97) 评论(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 sum of 阅读全文
posted @ 2018-03-22 20:48 还是说得清点吧 阅读(197) 评论(0) 推荐(0)
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return 贴上一个更加简洁的方法: 阅读全文
posted @ 2018-03-21 21:41 还是说得清点吧 阅读(127) 评论(0) 推荐(0)
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2018-03-21 20:59 还是说得清点吧 阅读(150) 评论(1) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文
posted @ 2018-03-21 20:25 还是说得清点吧 阅读(152) 评论(0) 推荐(0)
摘要:Given an array and a value, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2018-03-20 22:10 还是说得清点吧 阅读(167) 评论(0) 推荐(0)
摘要: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 much as 阅读全文
posted @ 2018-03-20 21:54 还是说得清点吧 阅读(154) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Example 2: Note: Length of th 阅读全文
posted @ 2018-03-20 21:33 还是说得清点吧 阅读(149) 评论(0) 推荐(0)
摘要:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. Y 阅读全文
posted @ 2018-03-20 20:56 还是说得清点吧 阅读(111) 评论(0) 推荐(0)
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Example 2: Note: 这道题还是比较简单的,直接贴代码吧:) 阅读全文
posted @ 2018-03-20 20:21 还是说得清点吧 阅读(142) 评论(0) 推荐(0)
摘要: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 Note:Your al 阅读全文
posted @ 2018-03-20 20:05 还是说得清点吧 阅读(786) 评论(0) 推荐(0)
摘要: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 the arr 阅读全文
posted @ 2018-03-19 21:11 还是说得清点吧 阅读(114) 评论(0) 推荐(0)
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文
posted @ 2018-03-19 20:50 还是说得清点吧 阅读(110) 评论(0) 推荐(0)
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2018-03-19 20:23 还是说得清点吧 阅读(143) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2018-03-18 21:35 还是说得清点吧 阅读(128) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2018-03-18 20:47 还是说得清点吧 阅读(187) 评论(0) 推荐(0)
摘要: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 11). N 阅读全文
posted @ 2018-03-18 19:46 还是说得清点吧 阅读(358) 评论(0) 推荐(0)
摘要: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 [1, n] 阅读全文
posted @ 2018-03-18 19:01 还是说得清点吧 阅读(148) 评论(0) 推荐(0)
摘要: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, giv 阅读全文
posted @ 2018-03-18 16:06 还是说得清点吧 阅读(104) 评论(0) 推荐(0)
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文
posted @ 2018-03-18 12:47 还是说得清点吧 阅读(146) 评论(0) 推荐(0)
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length 阅读全文
posted @ 2018-03-17 20:58 还是说得清点吧 阅读(249) 评论(1) 推荐(0)
摘要: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 the m 阅读全文
posted @ 2018-03-17 20:54 还是说得清点吧 阅读(386) 评论(1) 推荐(0)
摘要:之前有刷过一些题,但都坚持不下去,现在搞个小博客,希望自己能坚持下去吧~~ In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with diff 阅读全文
posted @ 2018-03-17 20:49 还是说得清点吧 阅读(160) 评论(2) 推荐(0)