Category: python
The permutation is a frequently-used algorithm that we can apply to strings, list, or arrays (vector). In Python, we can import the itertools and use the permutations method which …
Given an array (or list), and a target element, find all the indices that the element appears in it. For example, Array: , and find the element 5, which …
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 …
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: …
Reversing a List/Array is very commonly needed and there are three ways to reverse a list or array in Python. Using the .reverse() method to reverse a list or …