## Insert Delete GetRandom O(1)

Implement the RandomizedSet class: RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise. int getRandom() Returns a random ......

You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i]. Return any permutation of nums1 that maximizes its advantage with respect to nums2. https://leetcode.com/problems/advantage-shuffle/ Solution Use The Worst to Defeat The Best. The only thing I ......

## Split Array Largest Sum | Binary Search

Given an array nums which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. https://leetcode.com/problems/split-array-largest-sum/ Solution Binary Search Code submit code class Solution: def splitArray(self, nums: List[in......

## Capacity To Ship Packages Within D Days | Binary Search

A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship. Return the least w......

## Koko Eating Bananas | Binary Search

Koko loves to eat bananas. There are n piles of bananas, the ith 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 k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any ......

## Find First and Last Position of Element in Sorted Array | Binary Search

Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return[-1, -1]. You must write an algorithm with O(log n) runtime complexity. https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array......

## Binary Search

Description Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity. https://leetcode.com/problems/binary-search/ Code submit code class Solution: def search(self, nums: L......

## Longest Substring Without Repeating Characters | Sliding Windows

Descreption Given a string s, find the length of the longest substring without repeating characters. https://leetcode.com/problems/longest-substring-without-repeating-characters/ Solution sliding windows, The most import things is how to get The max. Code submit code class Solution: def lengthOfLongestSubstring(self, ......

## Find All Anagrams in a String | Sliding Windows

Desciption Given two strings s and p, return an array of all the start indices of p\'s anagrams in s. You may return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Input: s = "cbaebabacd", p = "abc" Output: [0,6] Explanation: The ......

## 优惠码

 阿里云国际版 20美元 Vultr 10美元 搬瓦工 | Bandwagon 应该有折扣吧？ Just My Socks JMS9272283 【注意手动复制去跳转】 域名 | namesilo emperinter(1美元)