CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1749. Maximum Absolute Sum of Any Subarray

You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, …, numsr-1, numsr] is abs(numsl + numsl+1 + … + numsr-1 + numsr). Return the maximum absolute sum of any (possibly
2021-03-25
#leetcode #array #java #greedy #prefix sum

[LeetCode] 1801. Number of Orders in the Backlog

You are given a 2D integer array orders, where each orders[i] = [price, amount, orderType] denotes that amount orders have been placed of type orderType at the price price. The orderTyp is:0 if i
2021-03-22
#leetcode #java #greedy #MOD #heap

[LeetCode] 841. Keys and Rooms

There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. When you
2021-03-21
#leetcode #java #bfs #dfs #graph

[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] 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 #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
1…2021222324…43

Search

Hexo Fluid