Category: c / c++
There are n people whose IDs go from 0 to n – 1 and each person belongs exactly to one group. Given the array groupSizes of length n telling …
Design a Leaderboard class, which has 3 functions: addScore(playerId, score): Update the leaderboard by adding score to the given player’s score. If there is no player with such id …
Catalan numbers are popular in Combinatoric Mathematics. Many interesting counting problems tend to be solved using the Catalan numbers. The first few Catalan numbers are: 1, 1, 2, 5, …
nth_element is a partial sorting algorithm which can be invoked by including the header algorithm. It has following two forms: void nth_element(_RanIt _First, _RanIt _Nth, _RanIt _Last); void nth_element(_RanIt …
Given an integer number n, return the difference between the product of its digits and the sum of its digits. Example 1: Input: n = 234 Output: 15 Explanation: …