CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 828. Count Unique Characters of All Substrings of a Given String

Let’s define a function countUniqueChars(s) that returns the number of unique characters in s. For example, calling countUniqueChars(s) if s = “LEETCODE” then “L”, “T”, “C”, “O”, “D” are the uniq
2022-07-12
#leetcode #hashmap #java #string

[LeetCode] 729. My Calendar I

You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking. A double booking happens when two events have some non-empty interse
2022-07-05
#leetcode #java #treemap #design

[LeetCode] 2116. Check if a Parentheses String Can Be Valid

A parentheses string is a non-empty string consisting only of ‘(‘ and ‘)’. It is valid if any of the following conditions is true:It is ().It can be written as AB (A concatenated with B), where A and
2022-07-02
#leetcode #java #greedy #string #stack

[LeetCode] 475. Heaters

Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every house can be warmed, as long as the house is within the heate
2022-06-09
#leetcode #array #two pointer #java #sort #binary search #binary search on answer

[LeetCode] 2016. Maximum Difference Between Increasing Elements

Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j]. Retu
2022-02-26
#leetcode #array #java

[LeetCode] 1491. Average Salary Excluding the Minimum and Maximum Salary

You are given an array of unique integers salary where salary[i] is the salary of the ith employee. Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5
2022-02-07
#leetcode #array #java #math

[LeetCode] 2000. Reverse Prefix of Word

Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist
2022-02-06
#leetcode #two pointer #java #string

[LeetCode] 1072. Flip Columns For Maximum Number of Equal Rows

You are given an m x n binary matrix matrix. You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from 0 to 1 or vice versa). Retur
2021-11-21
#leetcode #array #hashmap #java #matrix

[LeetCode] 1436. Destination City

You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outg
2021-10-06
#leetcode #hashmap #java #string

[LeetCode] 1963. Minimum Number of Swaps to Make the String Balanced

You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets ‘[‘ and n / 2 closing brackets ‘]’. A string is called balanced if and only if:It i
2021-08-18
#leetcode #java #greedy #string #stack
1…1819202122…44

Search

Hexo Fluid