less than 1 minute read

Given two lowercase alphabet strings a and b, return the length of the longest anagram subsequence.

Constraints

  • n ≤ 100,000 where n is the length of a
  • m ≤ 100,000 where m is the length of b

https://binarysearch.com/problems/Longest-Anagram-Subsequence

Examples

Example 1

Input

  • a = afbc
  • b = cxba

Output

  • answer = 3

Explanation

  • “abc” is a subsequence in “afbc”
  • “cba” is a subsequence in “cxba”

And abc and cba are anagrams of each other.

Solution

Leave a comment