Tap here to switch tabs
Problem
Submissions

Problem: Rearrange K Substrings to Form Target String

med
30 min
Try to solve the Rearrange K Substrings to Form Target String problem.

Statement

You are given two strings s and t, and an integer k. Both strings have the same length, which is divisible by k.

You need to divide string s into k equal sized substrings. Determine whether it is possible to rearrange these substrings such that concatenating them in some order produces the string t.

Return true if t can be formed by rearranging the k substrings, or false otherwise.

Constraints:

  • 1≤1 \leq s.length == t.length ≤2imes105\leq 2 imes 10^5

  • 1≤1 \leq k ≤\leq s.length

  • s.length is divisible by k.

  • s and t consist only of lowercase English letters.

  • The input is generated such that s and t are anagrams of each other.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Rearrange K Substrings to Form Target String

med
30 min
Try to solve the Rearrange K Substrings to Form Target String problem.

Statement

You are given two strings s and t, and an integer k. Both strings have the same length, which is divisible by k.

You need to divide string s into k equal sized substrings. Determine whether it is possible to rearrange these substrings such that concatenating them in some order produces the string t.

Return true if t can be formed by rearranging the k substrings, or false otherwise.

Constraints:

  • 1≤1 \leq s.length == t.length ≤2imes105\leq 2 imes 10^5

  • 1≤1 \leq k ≤\leq s.length

  • s.length is divisible by k.

  • s and t consist only of lowercase English letters.

  • The input is generated such that s and t are anagrams of each other.