Problem Statement

Given two strings find if S1 is apermutation of s2, in other words if any subset of S2 is equal to S1.

Attempt 1

  • If a specific order is not required to be maintained then hashmap can be used. No the order has to be maintained, it is mentioned in problem.
  • So I need to calculate all permutations of s1 and then start matching it with the string using sliding window or something.
  • Permutation
  • How to calculate all subsets? Unique Subsets

Attempt 2