Skip to main content

19 docs tagged with "Counting"

View all tags

Majority Element

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.

Majority Element II

This document provides a solution to the Majority Element II problem, where we need to find all elements that appear more than ⌊ n/3 βŒ‹ times.

Sort Characters By Frequency (LeetCode)

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.

Sort Characters By Frequency (LeetCode)

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.