CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 643. Maximum Average Subarray I

You are given an integer array nums consisting of n elements, and an integer k. Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. Any answ
2021-02-05
#leetcode #array #java #javascript #sliding window #sliding window with fixed size

[LeetCode] 1657. Determine if Two Strings Are Close

Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two existing characters.For example, abcde -> aecdbOperation 2: Transform
2021-01-25
#leetcode #hashmap #java #greedy

[LeetCode] 1338. Reduce Array Size to The Half

You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the inte
2021-01-23
#leetcode #array #hashmap #java #greedy #counting sort #heap

[LeetCode] 984. String Without AAA or BBB

Given two integers a and b, return any string s such that: s has length a + b and contains exactly a ‘a’ letters, and exactly b ‘b’ letters, The substring ‘aaa’ does not occur in s, and The substring
2021-01-19

[LeetCode] 1405. Longest Happy String

A string s is called happy if it satisfies the following conditions: s only contains the letters ‘a’, ‘b’, and ‘c’. s does not contain any of “aaa”, “bbb”, or “ccc” as a substring. s contains at most
2021-01-19
#leetcode #java #dynamic programming #greedy

[LeetCode] 744. Find Smallest Letter Greater Than Target

You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters. Return the smallest character in le
2021-01-14
#leetcode #java #binary search

[LeetCode] 1471. The k Strongest Values in an Array

Given an array of integers arr and an integer k. A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the median of the array.If |arr[i] - m| =&#
2021-01-14
#leetcode #array #two pointer #java #sort

[LeetCode] 633. Sum of Square Numbers

Given a non-negative integer c, decide whether there’re two integers a and b such that a2 + b2 = c. Example 1:Input: c = 5Output: trueExplanation: 1 * 1 + 2 * 2 = 5 Example 2:Input: c &
2021-01-12
#leetcode #two pointer #java #math

[LeetCode] 1695. Maximum Erasure Value

You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements. Return the maxi
2021-01-08
#leetcode #array #two pointer #hashmap #java #sliding window #string

[LeetCode] 1679. Max Number of K-Sum Pairs

You are given an integer array nums and an integer k. In one operation, you can pick two numbers from the array whose sum equals k and remove them from the array. Return the maximum number of operatio
2021-01-03
#leetcode #array #two pointer #hashmap #java #sort
1…2122232425…41

Search

Hexo Fluid