随笔分类 - Array
摘要:You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are in the inclusive range. A number x is c
阅读全文
摘要:Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume that multiplication is always po
阅读全文
摘要:This question is about implementing a basic elimination algorithm for Candy Crush. Given an m x n integer array board representing the grid of candy w
阅读全文
摘要:According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Hort
阅读全文
摘要:Suppose you are at a party with n people (labeled from 0 to n - 1), and among them, there may exist one celebrity. The definition of a celebrity is th
阅读全文
摘要:Given an m x n matrix mat where every row is sorted in strictly increasing order, return the smallest common element in all rows. If there is no commo
阅读全文
摘要:参考:https://www.geeksforgeeks.org/maximum-element-in-a-sorted-and-rotated-array/ 给定在某个未知点旋转的不同元素的排序数组arr[],任务是找到其中的最大元素。例子: 输入: arr[] = {3, 4, 5, 1, 2}
阅读全文
摘要:Given an unsorted integer array nums, find the smallest missing positive integer. Example 1: Input: nums = [1,2,0] Output: 3 Example 2: Input: nums =
阅读全文
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num
阅读全文
摘要: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
阅读全文
摘要:Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except n
阅读全文
摘要:思路:用map.put(cur_sum, i); 动不动就break 一开始设置end = -1是因为没找到 https://www.geeksforgeeks.org/find-subarray-with-given-sum-in-array-of-integers/ // Java progra
阅读全文
摘要:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that
阅读全文
摘要:Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. Example 1: Input: nums = [1,1
阅读全文
摘要:小部件制造商面临对其新产品的意外高需求。他们想满足尽可能多的客户。给定可用的小部件数量和客户订单列表,制造商最多可以完全满足的订单数量是多少? 功能说明 在下面的编辑器中完成功能fillOrders。该函数必须返回一个整数,该整数表示已完成订单的最大数量。 fillOrders具有以下参数: ord
阅读全文
摘要:Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one duplicate number in n
阅读全文
摘要:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. Example:Assume that words = ["p
阅读全文
摘要: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
阅读全文
摘要:[抄题]: Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for anot
阅读全文
摘要:[抄题]: An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A
阅读全文

浙公网安备 33010602011771号