FastPrepFastPrep
Problem Brief

Maximum Times Word Removed

INTERNOA

Amazon Engineering maintains a large number of logs of operations across all products. A software engineer is debugging an issue in a product. An efficient way to analyze logs is to write automated scripts to check for patterns. The engineer wants to find the maximum number of times a target word can be obtained by rearranging a subset of characters in a log entry.

Given a log entry s and target word t, the target word can be obtained by selecting some subset of characters from s that can be rearranged to form string t and removing them from s. Determine the maximum number of times the target word can be removed from the given log entry.

Note: Both strings s and t consist only of lowercase English letters.

Function Description

Complete the function maximumTimesWordRemoved in the editor.

maximumTimesWordRemoved has the following parameters:

  • String s: a log entry
  • String t: a target word
  • Returns

  • int: the maximum number of times the target word can be removed
  • ࣪𓏲ּ ᥫ᭡ ₊ ⊹ Credit to kchoˑ ִֶ 𓂃🌼

    1Example 1

    Input
    s = "abacbc", t = "bca"
    Output
    2
    Explanation
    Example 1 illustration
    All characters were removed from s. ✎, Credit to ketchup 🍅♡˳ >ᴗ<

    2Example 2

    Input
    s = "abdadccacd", t = "edac"
    Output
    0
    Explanation
    It is not possible to form the target word t from the characters in s.

    Constraints

    Limits and guarantees your solution can rely on.

    Both string s and t consist only of lowercase English letters. (there might be some other constraints, will add once find out 😘)
    public int maximumTimesWordRemoved(String s, String t) {
        // write your code here
    }
    
    Input

    s

    "abacbc"

    t

    "bca"

    Output

    2

    Sign in to submit your solution.