CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1207. Unique Number of Occurrences

Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise. Example 1:Input: arr = [1,2,2,1,1,3]Output: trueExplanation: The
2022-11-30
#leetcode #java #array #hashmap

[LeetCode] 1758. Minimum Changes To Make Alternating Binary String

You are given a string s consisting only of the characters ‘0’ and ‘1’. In one operation, you can change any ‘0’ to ‘1’ or vice versa. The string is called alternating if no two adjacent characters ar
2022-11-29
#leetcode #java #greedy #string

[LeetCode] 2225. Find Players With Zero or One Losses

You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Return a list answer of size 2 where:answer[0] is
2022-11-29
#leetcode #java #array #hashmap #sort

[LeetCode] 1768. Merge Strings Alternately

You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the e
2022-10-23
#leetcode #java #two pointer #string

[LeetCode] 1700. Number of Students Unable to Eat Lunch

The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sa
2022-10-19
#leetcode #java #array #greedy #simulation

[LeetCode] 1328. Break a Palindrome

Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the
2022-10-11
#leetcode #java #greedy #string

[LeetCode] 2007. Find Original Array From Doubled Array

An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array. Given an array changed
2022-09-18
#leetcode #java #array #hashmap #greedy #sort

[LeetCode] 1608. Special Array With X Elements Greater Than or Equal X

You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x. Notice th
2022-09-12
#leetcode #java #array #counting sort #sort #binary search #binary search on answer

[LeetCode] 1184. Distance Between Bus Stops

A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n.
2022-07-24
#leetcode #java #array

[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 #java #hashmap #string
1…1718192021…44

Search

Hexo Fluid