CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 670. Maximum Swap

You are given an integer num. You can swap two digits at most once to get the maximum valued number. Return the maximum valued number you can get. Example 1:Input: num = 2736Output: 7236Explanati
2021-03-18
#leetcode #array #java #greedy #math

[LeetCode] 1461. Check If a String Contains All Binary Codes of Size K

Given a binary string s and an integer k. Return True if every binary code of length k is a substring of s. Otherwise, return False. Example 1:Input: s = “00110110”, k = 2Output: trueExplana
2021-03-14
#leetcode #hashmap #java #sliding window with fixed size #string

[LeetCode] 1481. Least Number of Unique Integers after K Removals

Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements. Example 1:Input: arr = [5,5,4], k = 1Output: 1Explanation: Remove
2021-03-12
#leetcode #array #hashmap #java #greedy #sort #heap

[LeetCode] 1151. Minimum Swaps to Group All 1s Together

Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any place in the array. Example 1:Input: data = [1,0,1,0,1]Output: 1Explan
2021-03-11
#leetcode #array #java #prefix sum #sliding window #sliding window with fixed size

[LeetCode] 303. Range Sum Query - Immutable

Given an integer array nums, handle multiple queries of the following type:Calculate the sum of the elements of nums between indices left and right inclusive where left <= right. Implement the
2021-03-01
#leetcode #java #prefix sum #design

[LeetCode] 1561. Maximum Number of Coins You Can Get

There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:In each step, you will choose any 3 piles of coins (not necessarily consecutive).Of your choice, A
2021-02-25
#leetcode #array #two pointer #greedy #sort

[LeetCode] 1052. Grumpy Bookstore Owner

Today, the bookstore owner has a store open for customers.length minutes. Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that mi
2021-02-24
#leetcode #array #two pointer #java #sliding window #sliding window with fixed size

[LeetCode] 765. Couples Holding Hands

There are n couples sitting in 2n seats arranged in a row and want to hold hands. The people and seats are represented by an integer array row where row[i] is the ID of the person sitting in the ith s
2021-02-14
#leetcode #java #greedy #graph #union find

[LeetCode] 1208. Get Equal Substrings Within Budget

You are given two strings s and t of the same length and an integer maxCost. You want to change s to t. Changing the ith character of s to ith character of t costs |s[i] - t[i]| (i.e., the absolute di
2021-02-10
#leetcode #array #two pointer #java #sliding window

[LeetCode] 1423. Maximum Points You Can Obtain from Cards

There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you can take one card from the beginning
2021-02-06
#leetcode #array #java #sliding window #sliding window with fixed size
1…2021222324…41

Search

Hexo Fluid