Company: Amex
Difficulty: medium
ASCII Sum Problem Description A number N and a string S consisting of lowercase English characters are given. Implement the provided sumASCII(...) method. This method should calculate the sum of the ASCII values of the string by the following method: Calculate the sum of the ASCII values of the top N largest characters in the string. Calculate the sum of the ASCII values of the top N smallest characters in the string. The method should then print the sum of both these calculated values. Note: N is always less than or equal to the length of the string. Input Format: The first line contains a single integer N denoting the given number. The second line contains a string S consisting of lowercase English characters. Output Format: The output contains a single integer denoting the sum of both values of the steps. Examples Example 1: Input: 2 abcdef Output: 398 Explanation: S = abcdef N = 2 The sum of the ASCII values of the top 2 largest characters is f + e = 102 + 101 = 203. The sum of the