FastPrepLargest Subsequences
Problems/Largest Subsequences

Largest Subsequences

Cashfree Payments logoCashfree Payments● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Cashfree Payments online assessment. Our version is about 99% the same as the reported question.

Given a lowercase string s of length n, return an array answer of length n.

For every i from 1 through n, answer[i - 1] must be the lexicographically largest subsequence of s whose length is exactly i.

A subsequence is formed by deleting zero or more characters without changing the order of the remaining characters.

Function

getLargestSubsequences(s: String) → String[]

Examples

Example 1

s = "hrw"return = ["w","rw","hrw"]

For lengths 1, 2, and 3, the lexicographically largest subsequences are w, rw, and hrw.

Example 2

s = "dbca"return = ["d","dc","dca","dbca"]

The best subsequence of each length is d, dc, dca, and the complete string dbca.

Constraints

  • 1 <= s.length <= 3000.
  • s contains only lowercase English letters.

More Cashfree Payments interview questions

  • Minimum Server VulnerabilityOA · Seen Aug 2022
  • Pairs of Songs With Total Durations Divisible by 120PHONE SCREEN · Seen Dec 2026

Similar questions at other companies

  • Substring RemovalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Modify the StringYahoo · OAYahoo interview questions
  • Lexicographically Minimum Stack EncryptionRippling · OARippling interview questions
  • Shortest String After Erasing Equal PairsMarshall Wace · OAMarshall Wace interview questions
  • Minimum Insertions to Balance a Parentheses StringIBM · OAIBM interview questions
  • Remove K Digits for the Smallest NumberNutanix · OANutanix interview questions
  • Good Binary StringsBNP Paribas · OA
  • Remove K DigitsProcol · PHONE SCREEN
  • Remove K DigitsThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Remove K DigitsAmazon · ONSITE INTERVIEW
See Cashfree Payments hiring insights
Saved
class Solution {
    public String[] getLargestSubsequences(String s) {
        // Write your code here.
    }
}
Checking account…