Company: AMAZON ML SUMMER SCHOOL_28june

Difficulty: medium

Problem Statement

Captain Morgan and his crew are on a quest to find a hidden treasure under the ocean. This treasure is a sequence of letters from 'A' to 'Z', scattered and guarded by ancient spirits. Their goal is to - Retrieve the lexicographically largest sequence of K letters from the fragments they collect, while preserving the original order of the letters. Help them find this treasure by determining the largest subsequence of K letters. Note:- S consists of lowercase letters ('a' to 'z') Input Format The first line contains a variable N, the size of given string. The second line contains the string, S. The third line contains the integer K, which will be the length of the required subsequence. Output Format Print a string of length K which is the lexicographically largest subsequence of the given string S. It is guaranteed that a valid answer will always exist. Constraints 1 ≤ N ≤ 10 5 1 ≤ K ≤ N Sample Testcase 1 Testcase Input 8 cognitio 4 Testcase Output otio Explanation In this te

More AMAZON ML SUMMER SCHOOL_28june OA questionsInterview experiences