[LeetCode] 115. Distinct Subsequences Given two strings s and t, return the number of distinct subsequences of s which equals t. A string’s subsequence is a new string formed from the original string by deleting some (can be none) of the 2021-03-17 #leetcode #java #dynamic programming #string
[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 #java #hashmap #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 #java #array #hashmap #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 #java #array #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 #java #array #two pointer #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 #java #array #two pointer #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 #java #array #sliding window #sliding window with fixed size