[LeetCode] Find the Prefix Common Array of Two Arrays

2657. Find the Prefix Common Array of Two Arrays

You are given two 0-indexed integer permutations A and B of length n.

A prefix common array of A and B is an array C such that C[i] is equal to the count of numbers that are present at or before the index i in both A and B.

Return the prefix common array of A and B.

A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.

Read more
[LeetCode] Maximum Sum With Exactly K Elements

2656. Maximum Sum With Exactly K Elements

You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your score:

  1. Select an element m from nums.
  2. Remove the selected element m from the array.
  3. Add a new element with a value of m + 1 to the array.
  4. Increase your score by m.

Return the maximum score you can achieve after performing the operation exactly k times.

Read more
[Codewars] Weight for weightRead more
[Codewars] ROT13Read more
[Codewars] Best travelRead more
[Codewars] Counting Change CombinationsRead more
[Codewars] Binary multiple of 3Read more
[Hacker Rank] The Full Counting SortRead more
[Hacker Rank] Cut the TreeRead more
[Hacker Rank] Count LuckRead more