Company: Amex
Difficulty: medium
ASCII Sum Problem Description You are given a number N and a string S made up of lowercase English letters. Implement the given sumASCII(...) method, which computes the sum of the string's ASCII values in the following way: Add up the ASCII values of the N largest characters in the string. Add up the ASCII values of the N smallest characters in the string. The method should then print the total of these two sums. 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 Adding up the ASCII values of the 2 largest characters gives f + e = 102 + 101 = 203. Adding up the ASCII values of the 2 smallest characters gives a + b = 97 + 98 = 195. So the