Maximum Times Word Removed
Learn this problemProblem statement
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
maximumTimesWordRemoved(s: String, t: String) → int
Complete the function maximumTimesWordRemoved in the editor.
maximumTimesWordRemoved has the following parameters:
String s: a log entryString t: a target wordReturns
int: the maximum number of times the target word can be removed࣪𓏲ּ ᥫ᭡ ₊ ⊹ Credit to kchoˑ ִֶ 𓂃🌼
Examples
Example 1
s = "abacbc"t = "bca"return = 2
Example 2
s = "abdadccacd"t = "edac"return = 0t from the characters in s.Constraints
Both string s and t consist only of lowercase English letters. (there might be some other constraints, will add once find out 😘)More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026