摘要: 题意:给定一个数组,数组的度是其中出现最多次数的元素。求,最小连续子数组的度和原数组一致。 思路:(参考最佳答案) 遍历数组,找到数组最大值,然后根据最大值设置三个长度为max+1的数组left[],right[],counts[],分别用于存储一个数第一次出现的索引、最后一次出现的索引、出现次数。 阅读全文
posted @ 2018-05-15 21:44 何以解忧,唯有撸代码 阅读(197) 评论(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-05-15 20:44 何以解忧,唯有撸代码 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 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 non-decr 阅读全文
posted @ 2018-05-14 22:10 何以解忧,唯有撸代码 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, find three numbers whose product is maximum and output the maximum product. 题目:给定一个数组,数组长度3-10000,求其中三个数乘积最大的值;(最大乘积不会超过int范围) 阅读全文
posted @ 2018-05-14 14:19 何以解忧,唯有撸代码 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 引言:由于实习工作的原因,需要使用Nodejs开发,作为一个前端白痴和后端塑料,我开始了欲仙欲死的前端学习。 本文主要记录在学习前端技术的过程以及使用到的资源,以便后续复习。 首先:查找nodejs的入门方法,参考 怎样有效地学习Node.js 中高赞答案,用一个工作日学习 Node入门 。 然后: 阅读全文
posted @ 2018-05-10 16:30 何以解忧,唯有撸代码 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. 题目:给一个无序数组,长度为n,元素为从0到n,缺少一个,求缺了 阅读全文
posted @ 2018-05-09 21:06 何以解忧,唯有撸代码 阅读(103) 评论(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-05-05 14:31 何以解忧,唯有撸代码 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Given an array, rotate the array to the right by k steps, where k is non-negative. 题目:给定一个数组和一个数值k,要求将数组向右旋转k步。 以前准备面试时看到过这个题目,结果今天还是记不得空间复杂度O(1)的解法,好 阅读全文
posted @ 2018-05-05 14:09 何以解忧,唯有撸代码 阅读(113) 评论(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-05-05 13:34 何以解忧,唯有撸代码 阅读(77) 评论(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-05-05 12:03 何以解忧,唯有撸代码 阅读(110) 评论(0) 推荐(0) 编辑