CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1704. Determine if String Halves Are Alike

You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half. Two strings are alike if they have the same number of
2021-04-08
#leetcode #two pointer #java #string

[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 #MOD #greedy #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] 1717. Maximum Score From Removing Substrings

You are given a string s and two integers x and y. You can perform two types of operations any number of times. Remove substring “ab” and gain x points.For example, when removing “ab” from “cabxbae” i
2021-03-04
#leetcode #java #greedy #string #stack
1…2223242526…48

Search

Hexo Fluid