CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1962. Remove Stones to Minimize the Total

You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times:Choose any pil
2021-08-16
#leetcode #java #array #greedy #heap

[LeetCode] 1137. N-th Tribonacci Number

The Tribonacci sequence Tn is defined as follows:T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.Given n, return the value of Tn. Example 1:Input: n = 4
2021-08-08
#leetcode #java #dynamic programming #math #memoization

[LeetCode] 791. Custom Sort String

order and str are strings composed of lowercase letters. In order, no letter occurs more than once. order was sorted in some custom order previously. We want to permute the characters of str so that t
2021-07-15
#leetcode #java #hashmap #counting sort #sort #string

[LeetCode] 1930. Unique Length-3 Palindromic Subsequences

Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counte
2021-07-13
#leetcode #java #hashmap #string #palindrome

[LeetCode] 1905. Count Sub Islands

You are given two m x n binary matrices grid1 and grid2 containing only 0’s (representing water) and 1’s (representing land). An island is a group of 1’s connected 4-directionally (horizontal or verti
2021-07-05
#leetcode #bfs #dfs #java #flood fill

[LeetCode] 1886. Determine Whether Matrix Can Be Obtained By Rotation

Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise. Example 1: Input: mat = [[0,
2021-06-17
#leetcode #java #array #matrix

[LeetCode] 1400. Construct K Palindrome Strings

Given a string s and an integer k, return true if you can use all the characters in s to construct k palindrome strings or false otherwise. Example 1:Input: s = “annabelle”, k = 2Output: tru
2021-06-12
#leetcode #java #greedy #palindrome

[LeetCode] 1331. Rank Transform of an Array

Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Rank is an integer starting from 1. The larger the
2021-06-08
#leetcode #java #array #hashmap

[LeetCode] 1642. Furthest Building You Can Reach

You are given an integer array heights representing the heights of buildings, some bricks, and some ladders. You start your journey from building 0 and move to the next building by possibly using bric
2021-05-13
#leetcode #java #greedy #heap

[LeetCode] 1720. Decode XORed Array

There is a hidden integer array arr that consists of n non-negative integers. It was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For
2021-05-06
#leetcode #java #bit manipulation
1…1920212223…44

Search

Hexo Fluid