Tap here to switch tabs
Problem
Submissions

Problem: Find Beautiful Indices in the Given Array I

med
30 min
Try to solve the Find Beautiful Indices in the Given Array I problem.

Statement

You are given a 00 indexed string s, string a, string b, and an integer k.

An index i is called beautiful if:

  • 0≤i≤0 \leq i \leq s.length −- a.length

  • The substring of s starting at index i with length a.length is equal to a

  • There exists at least one index j such that:

    • 0≤j≤0 \leq j \leq s.length −- b.length

    • The substring of s starting at index j with length b.length is equal to b

    • ∣j−i∣≤k|j - i| \leq k

Return an array containing all beautiful indices sorted in ascending order.

Constraints:

  • 1≤k≤1 \leq k \leq s.length ≤105\leq 10^5

  • 1≤1 \leq a.length, b.length ≤10\leq 10

  • s, a, and b contain only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Beautiful Indices in the Given Array I

med
30 min
Try to solve the Find Beautiful Indices in the Given Array I problem.

Statement

You are given a 00 indexed string s, string a, string b, and an integer k.

An index i is called beautiful if:

  • 0≤i≤0 \leq i \leq s.length −- a.length

  • The substring of s starting at index i with length a.length is equal to a

  • There exists at least one index j such that:

    • 0≤j≤0 \leq j \leq s.length −- b.length

    • The substring of s starting at index j with length b.length is equal to b

    • ∣j−i∣≤k|j - i| \leq k

Return an array containing all beautiful indices sorted in ascending order.

Constraints:

  • 1≤k≤1 \leq k \leq s.length ≤105\leq 10^5

  • 1≤1 \leq a.length, b.length ≤10\leq 10

  • s, a, and b contain only lowercase English letters.