problem on String
problem on String
Test Case 2
Input: feedback = ["dog", "racecar", "car","apple"]
Output: ""
Explanation:
• There is no common prefix among the feedback entries.
• "dog" does not share any prefix with "racecar" or "car".
Test Case 3
Input: feedback = ["interspecies", "interstellar", "interstate"]
Output: "inters"
Explanation:
• All feedback entries share the prefix "inters".
• "interspecies" starts with "inters".
• "interstellar" starts with "inters".
• "interstate" starts with "inters".
Test Case 4
Input: feedback = ["throne", "throne", "throne"]
Output: "throne"
Explanation:
• All feedback entries are identical.
• The common prefix is the entire string "throne".
Test Case 5
Input: feedback = ["reflower", "flow", "flight"]
Output: ""
Explanation:
• The entries do not share a common prefix.
• "reflower" does not share any prefix with "flow" or "flight".
Constraints
• 1 <= feedback.length <= 200
• 0 <= feedback[i].length <= 200
• feedback[i] consists of only lowercase English letters.
Scenario: Finding the Largest Odd Substring in Financial Transactions
Imagine you are developing a financial application where you need to process a
string representing a large transaction ID. Your task is to extract the largest-
valued odd integer from this string. This is useful for identifying certain types of
transactions that end with odd digits, which may be flagged for special
processing or auditing.
You need to write a function that takes a string of digits (representing the
transaction ID) and returns the largest-valued odd integer that is a non-empty
substring of this string. If no odd integer exists, the function should return an
empty string.
Sample Test Cases with Detailed Explanations Test Case 1
Input: transaction_id = "52"
Output: "5"
Explanation:
• The substrings are "5", "2", and "52".
• "5" is the only odd number.
Test Case 2
Input: transaction_id = "4206"
Output: ""
Explanation:
• The substrings are "4", "2", "0", "6", "42", "420", "4206", etc.
• None of these substrings are odd numbers.
Test Case 3
Input: transaction_id = "35427"
Output: "35427"
Explanation:
• "35427" is already an odd number, as it ends with the digit "7".
Test Case 4
Input: transaction_id = "1234567890"
Output: "123456789"
Explanation:
• The largest-valued odd integer is "123456789".
Test Case 5
Input: transaction_id = "88888"
Output: ""
Explanation:
• All digits are even, so no odd numbers exist.
Constraints
• 1 <= transaction_id.length <= 10^5
• transaction_id only consists of digits and does not contain any leading
zeros.