ICPC PACNW 2016 A - Alphabet

View as PDF

Submit solution

Points: 7
Time limit: 0.6s
Memory limit: 256M

Problem type
Allowed languages
C, C++, Java, Python

A string of lowercase letters is called alphabetical if deleting zero or more of its letters can result in the alphabet string abcdefghijklmnopqrstuvwxyz.

Given a string s, determine the minimum number of letters to insert anywhere in the string to make it alphabetical.


The input consists of a single line containing the string s\ (1 \leq |s| \leq 50).

It is guaranteed that s consists of lowercase ASCII letters a to z only.


Print, on a single line, a single integer indicating the minimum number of letters that must be inserted in order to make the string s alphabetical.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported


There are no comments at the moment.