Leetcode 0451. Sort Characters By Frequency

Posted on Sat 03 December 2022 in Leetcode • Tagged with counting

Question Link : https://leetcode.com/problems/sort-characters-by-frequency/

Difficulty: Medium

Premium: False

Question

Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are …


Continue reading

Leetcode 1657. Determine if Two Strings Are Close

Posted on Thu 01 December 2022 in Leetcode • Tagged with counting

Question Link : https://leetcode.com/problems/determine-if-two-strings-are-close/

Difficulty: Medium

Premium: False

Question

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 -> aecdb

Operation 2: Transform every occurrence of one existing character into …


Continue reading

Leetcode 1207. Unique Number of Occurrences

Posted on Tue 29 November 2022 in Leetcode • Tagged with counting

Question Link : https://leetcode.com/problems/unique-number-of-occurrences/

Difficulty: Easy

Premium: False

Question

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: true Explanation: The …


Continue reading

Leetcode 2451. Odd String Difference

Posted on Sat 05 November 2022 in Leetcode • Tagged with array, counting

Question Link : https://leetcode.com/problems/odd-string-difference/

Difficulty: Easy

Question

You are given an array of equal-length strings words. Assume that the length of each string is n. Each string words[i] can be converted into a difference integer array difference[i] of length n - 1 where difference[i][j …


Continue reading

Leetcode 0169. Majority Element

Posted on Thu 27 October 2022 in Leetcode • Tagged with counting, boyer-moore-voting-algorithm

Question Link : https://leetcode.com/problems/majority-element/

Difficulty: Easy

Question

Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.   Example 1: Input: nums …


Continue reading