Problem Statement
Problem Statement
Given a bill amount as input, you are required to calculate a discount. The discount is determined by
summing all odd digits present in the bill amount. Return the calculated discount as output.
Example:
- Input: `54728`
- Output: `12`
Explanation:
In the input `54728`, the odd digits are `5`, `7`, and `1`. The sum of these digits is `5 + 7 = 12`. Hence,
the discount is `12`.
Constraints:
- The bill amount can be large, so consider optimizing your solution for efficiency.
Test Cases:
1. Input: `12345`
- Output: `9`
- Explanation: Odd digits are `1`, `3`, and `5`. The sum is `9`.
2. Input: `86420`
- Output: `0`
3. Input: `97531`
- Output: `25`
- Explanation: Odd digits are `9`, `7`, `5`, `3`, and `1`. The sum is `25`.
4. Input: `10001`
- Output: `2`
- Explanation: Odd digits are `1` and `1`. The sum is `2`.
Problem Statement:
Given a bill amount as input, you are required to calculate a discount. The discount is determined by
summing all prime digits present in the bill amount. Return the calculated discount as output.
Example:
- Input: `54728`
- Output: `17`
Explanation:
In the input `54728`, the prime digits are `5`, `7`, `2`. The sum of these digits is `5 + 7 + 2 = 14`.
Hence, the discount is `14`.
Constraints:
- The bill amount can be large, so consider optimizing your solution for efficiency.
Test Cases:
1. Input: `12345`
- Output: `10`
- Explanation: Prime digits are `2`, `3`, `5`. The sum is `10`.
2. Input: `86420`
- Output: `2`
3. Input: `97531`
- Output: `17`
- Explanation: Prime digits are `7`, `5`, `3`. The sum is `15`.
4. Input: `10001`
- Output: `0`
Problem Statement:
Given two strings, `original` and `received`, where `received` is the `original` string with exactly one
character missing, identify and return the missing character.
Example:
- Input:
`original = "abcdefg"`
`received = "abcefg"`
- Output:
`'d'`
Explanation:
In the `original` string `"abcdefg"`, all characters are present except for `'d'` in the `received` string
`"abcefg"`. Hence, `'d'` is the missing character.
Constraints:
- The length of `received` is exactly one less than the length of `original`.
Test Cases:
1. Input:
`original = "hello"`
`received = "hllo"`
- Output: `'e'`
2. Input:
`original = "transmission"`
`received = "trnsmisson"`
- Output: `'a'`
3. Input:
`original = "python"`
`received = "pyton"`
- Output: `'h'`
`original = "abcdef"`
`received = "abcdf"`
- Output: `'e'`
Problem Statement:
Given a list of integers, rearrange the list such that all even numbers appear before all odd numbers.
The relative order of the even and odd numbers does not need to be preserved.
Example:
Explanation:
In the input list `[3, 1, 2, 4, 7, 6]`, the even numbers are `2, 4, 6` and the odd numbers are `3, 1, 7`.
After rearrangement, the even numbers are placed first, followed by the odd numbers.
Constraints:
Test Cases:
- Explanation: Even numbers are `8, 6, 2`, odd numbers are `5, 3, 1`.
- Explanation: Even numbers are `2, 0`, odd numbers are `9, 7, 5`.