Company: Cvent Full stack developer experience 5 years_12may
Difficulty: medium
A string S and an integer K are given. Find the longest substring length so that each consecutive character's absolute difference is less than or equal to K . Function Description In the provided code snippet, implement the provided longestSubstring( String S, int K ) method to find the longest substring length so that each consecutive character's absolute difference is less than or equal to K . You can write your code in the space below the phrase "WRITE YOUR LOGIC HERE". There will be multiple test cases running, so the Input and Output should match exactly as provided. The base Output variable result is set to a default value of -404 , which can be modified. Additionally, you can add or remove these output variables. Input Format The first line contains a string, S . The second line contains an integer, K . Sample Input bcaadef -- denotes S 2 -- denotes K Constraints 1 <= |S| <= 10^5 0 <= K <= 25 The string contains only lowercase English letters. Output Format The outpu