0% found this document useful (0 votes)
26 views6 pages

Problem Statement

AVADA KEDAVRA

Uploaded by

sooram k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

Problem Statement

AVADA KEDAVRA

Uploaded by

sooram k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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 will always be a non-negative integer.

- 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`

- Explanation: No odd digits, so the discount is `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.

Note: The prime digits are 2, 3, 5, and 7.

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 will always be a non-negative integer.

- 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`

- Explanation: Prime digit is `2`. The sum is `2`.

3. Input: `97531`

- Output: `17`

- Explanation: Prime digits are `7`, `5`, `3`. The sum is `15`.

4. Input: `10001`

- Output: `0`

- Explanation: No prime digits, so the discount is `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:

- Both strings consist of only lowercase English letters.

- The length of `received` is exactly one less than the length of `original`.

- There is exactly one missing character in `received`.

Test Cases:

1. Input:

`original = "hello"`

`received = "hllo"`

- Output: `'e'`

- Explanation: `'e'` is missing from `"hello"`.

2. Input:

`original = "transmission"`

`received = "trnsmisson"`

- Output: `'a'`

- Explanation: `'a'` is missing from `"transmission"`.

3. Input:

`original = "python"`

`received = "pyton"`

- Output: `'h'`

- Explanation: `'h'` is missing from `"python"`.


4. Input:

`original = "abcdef"`

`received = "abcdf"`

- Output: `'e'`

- Explanation: `'e'` is missing from `"abcdef"`.

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:

- Input: `[3, 1, 2, 4, 7, 6]`

- Output: `[2, 4, 6, 3, 1, 7]`

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:

- The list may contain positive, negative, or zero values.

- The list will have at least one element.

Test Cases:

1. Input: `[5, 3, 8, 6, 2, 1]`


- Output: `[8, 6, 2, 5, 3, 1]`

- Explanation: Even numbers are `8, 6, 2`, odd numbers are `5, 3, 1`.

2. Input: `[7, 1, 5, 3]`

- Output: `[7, 1, 5, 3]`

- Explanation: All numbers are odd, so the list remains unchanged.

3. Input: `[4, 2, 6, 8]`

- Output: `[4, 2, 6, 8]`

- Explanation: All numbers are even, so the list remains unchanged.

4. Input: `[9, 7, 2, 0, 5]`

- Output: `[2, 0, 9, 7, 5]`

- Explanation: Even numbers are `2, 0`, odd numbers are `9, 7, 5`.

You might also like