Posts

Showing posts from September 19, 2025

54.Sum of similar frequency element

Image
Problem of the Day: You are given an integer array nums. First, count the frequency of each distinct number in the array. Then, for each frequency f, compute the sum of all numbers in the array that appear exactly f times.Return a mapping (or any suitable output format) where: Key = frequency Value = sum of elements that occur with that frequency Input 1: nums = [1,7,1,1,2,2,2,3,3,5,5] Output: 1 -> 7 2 -> 16 3 -> 9 Input 2: nums = [nums = [1,1,2,2,2,3] Output: 1 -> 3 2 -> 2 3 -> 6

53.Reverse the String According to its Index

Image
Problem of the Day: You are given a string s and an integer k. Your task is to transform the string in the following way: Split the string into groups of size k, starting from index 0. For each group: Rotate the group to the left by 1 character (the first character moves to the end). If the last group has fewer than k characters, still apply the same operation. Finally, return the new transformed string. Input 1: String str1=ZohoCorporations k=3 Output1: hoZoCooprtarnois Input 2: String str1=Hellokid k=2 Output2:eHllkodi