CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1423. Maximum Points You Can Obtain from Cards

There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints. In one step, you can take one card from the beginning
2021-02-06
#leetcode #java #array #prefix sum #sliding window

[LeetCode] 923. 3Sum With Multiplicity

Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target. As the answer can be very large, retu
2021-02-05
#leetcode #java #array #two sum #two pointer

[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 #java #javascript #array #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 #java #hashmap #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 #java #array #hashmap #counting sort #greedy #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] 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 #java #array #two pointer #sort

[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] 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 #java #two pointer #math
1…2324252627…47

Search

Hexo Fluid