binary search
文章平均质量分 77
ForABiggerWorld
这个作者很懒,什么都没留下…
展开
-
1739. Building Boxes
You have a cubic storeroom where the width, length, and height of the room are all equal tonunits. You are asked to placenboxes in this room where each box is a cube of unit side length. There are however some rules to placing the boxes:You can place...原创 2021-02-09 21:02:08 · 253 阅读 · 0 评论 -
1283. Find the Smallest Divisor Given a Threshold
Given an array of integersnumsand an integerthreshold, we will choose a positive integer divisor anddivideall the array by it and sum the result of the division. Find thesmallestdivisor such th...原创 2020-01-31 18:35:20 · 382 阅读 · 0 评论 -
1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold
Given am x nmatrixmatand an integerthreshold. Return the maximum side-length of a square with a sum less than or equal tothresholdor return0if there is no such square.Example 1:Inpu...原创 2020-01-31 11:53:36 · 264 阅读 · 0 评论 -
1300. Sum of Mutated Array Closest to Target
Given an integer arrayarrand a target valuetarget, returnthe integervaluesuch that when we change all the integerslarger thanvaluein the given array to be equal tovalue,the sum of the array...原创 2020-01-30 22:02:26 · 389 阅读 · 0 评论 -
1235. Maximum Profit in Job Scheduling
We havenjobs, where every jobis scheduled to be done fromstartTime[i]toendTime[i], obtaining a profitofprofit[i].You're given thestartTime,endTimeandprofitarrays,you need to output th...原创 2019-10-20 14:33:05 · 261 阅读 · 0 评论 -
1201. Ugly Number III
Write a program to find then-th ugly number.Ugly numbers arepositive integerswhich are divisible byaorborc.Example 1:Input: n = 3, a = 2, b = 3, c = 5Output: 4Explanation: The ugly...原创 2019-09-22 14:01:17 · 433 阅读 · 0 评论 -
1157. Online Majority Element In Subarray
Implementing the classMajorityChecker, which has the following API:MajorityChecker(int[] arr)constructs an instance of MajorityChecker with the given arrayarr; int query(int left, int right, int...原创 2019-08-11 13:40:30 · 263 阅读 · 0 评论 -
1095. Find in Mountain Array
(This problem is aninteractive problem.)You may recall that an arrayAis amountain arrayif and only if:A.length >= 3 There exists someiwith0 < i< A.length - 1such that: A[0] &l...原创 2019-06-23 15:35:44 · 252 阅读 · 0 评论 -
1044. Longest Duplicate Substring
Given a stringS, consider allduplicated substrings: (contiguous) substrings of S that occur 2 or more times. (The occurrencesmay overlap.)Returnanyduplicatedsubstring that has the longest pos...原创 2019-05-12 14:38:59 · 700 阅读 · 0 评论 -
1014. Capacity To Ship Packages Within D Days
A conveyor belt has packages that must be shipped from one port to another withinDdays.Thei-th package on the conveyor belt has a weight ofweights[i]. Each day, we load the ship with packages o...原创 2019-03-17 12:08:51 · 285 阅读 · 0 评论 -
981. Time Based Key-Value Store
Create a timebased key-value store class TimeMap, that supports two operations.1. set(string key, string value, int timestamp)Stores the key and value, along with the given timestamp.2. get(strin...原创 2019-01-27 18:14:00 · 283 阅读 · 0 评论 -
962. Maximum Width Ramp
Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j]. The width of such a ramp is j - i.Find the maximum width of a ramp in A. If one doesn't exist, return...原创 2018-12-23 12:00:17 · 305 阅读 · 0 评论 -
Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume nums1 an...原创 2018-08-27 14:29:43 · 180 阅读 · 0 评论 -
875. Koko Eating Bananas
Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The guards have gone and will come back in H hours.Koko can decide her bananas-per-hour eating speed of...原创 2018-07-22 12:20:05 · 470 阅读 · 0 评论 -
878. Nth Magical Number
A positive integer is magical if it is divisible by either A or B.Return the N-th magical number. Since the answer may be very large, return it modulo 10^9 + 7. Example 1:Input: N = 1, A = 2...原创 2018-07-29 11:33:23 · 444 阅读 · 0 评论 -
287. Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fi...原创 2018-05-24 16:19:19 · 118 阅读 · 0 评论 -
825. Friends Of Appropriate Ages
Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person. Person A will NOT friend request person B (B != A) if any of the following conditions a...原创 2018-04-29 11:52:03 · 205 阅读 · 0 评论 -
540. Single Element in a Sorted Array
Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once.Example 1:Input: [1,1,2,3,...原创 2017-08-21 22:01:09 · 203 阅读 · 0 评论 -
719. Find K-th Smallest Pair Distance
Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B.Example 1:Input:nums = [1,3,1]k = 1...原创 2017-10-29 11:32:59 · 1276 阅读 · 0 评论