Coding Practice Articles

Page 3 of 3

Program to find a Score of a String

Revathi Satya Kondra
Revathi Satya Kondra
Updated on 23-Jul-2024 657 Views

The Score of a String is a concept which is used to calculate the score based on the sum of the absolute differences between the ASCII values of adjacent characters in the string. Problem Statement Given a string s, calculate the score of the string. The score is defined as the sum of the absolute differences between the ASCII values of adjacent characters. Example Scenario 1 Input: s="abc" Output: 2 The ASCII values of the characters in s are 'a' = 97, 'b' = 98, 'c' = 99. So, the score of s = |97-98|+|98-99|= 1+1 ...

Read More
Showing 21–21 of 21 articles
« Prev 1 2 3 Next »
Advertisements