Company: Uber SDE-1_7june

Difficulty: medium

Problem Statement

A string must be transferred using a custom network protocol. The protocol processes the string as follows: Each pair of characters in the string is processed together. If any pair contains matching characters (e.g., "aa"), it requires an additional sameTime seconds. The string can be split into substrings before transmission, with each partition adding partitionTime seconds. Calculate the minimum possible total extra time required, which is the sum of: Time for processing pairs with matching characters. Time for creating partitions. Example s = "abcabcc" sameTime = 1 partitionTime = 4 Two optimal approaches are: Split into ["abc", "abcc"]: "abc" has no matching pairs: 0 seconds One partition: 4 seconds "abcc" has one "cc" pair: 1 second Total: 0 + 4 + 1 = 5 seconds Keep as ["abcabcc"]: 5 matching pairs ("aa", "bb", "cc", "cc", "cc"): 5 seconds Total: 5 seco

More Uber SDE-1_7june OA questionsInterview experiences