[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] 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 #sort #greedy #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 #sliding window #sliding window with fixed size #prefix sum
[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 #design #prefix sum
[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 #sort #greedy
[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 #prefix sum
[LeetCode] 1657. Determine if Two Strings Are Close Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters.For example, abcde -> aecdbOperation 2: Transform 2021-01-25 #leetcode #hashmap #java #greedy