Encryption

Company: Tech Mahindra-SDE_24may

Difficulty: medium

Problem Statement

Encryption Given a string S, find the number of non-empty encryptable subsequences in S. Since the result can be large, return it modulo 998244353. A subsequence is obtained by deleting zero or more characters of S without changing the order of the rest. Two subsequences are different when they use different sets of positions, even if they spell the same text. A non-empty subsequence is encryptable when the difference between the largest and the smallest character code (ASCII value) among its characters is at most 17. For example, c (99) and o (111) differ by 12, so "co" is encryptable, while d (100) and v (118) differ by 18, so any subsequence containing both is not. Notes The letters can be present in the string one or more times, not necessarily just once. A single character is always encryptable. Input The first line contains a string S. The provided harness reads S from standard input and prints the value returned by solve(S) . Output Return an integer representing the number of n