In a premier championship series of sports car racing, initially, the 1st car is ahead of the 2nd car by X metres. After that, in every second, the 1st car moves ahead by n1 metres and the 2nd can moves ahead by n2 metres (in the same direction). The task is to print the number of seconds after which the 2nd car crosses the 1st car. If it is impossible to do so, then print -1
Example 1:
Input:
3 -- Value of n1
4 -- Value of n2
1 -- Value of x
Output:
2
Explanation:
Initially, the 1st car is ahead by 1 metre.
After the 1st second, the 1st and 2nd cars are at the same place.
After the 2nd second, the 2 car moves ahead of the 1st car by 1 metre.
Example 2
Input
5 ---- Value of n1
4 ---- Value of n2
1 ---- Value of x
Output:
-1
Example 3
Input
2 ---- Value of n1
12 ---- Value of n2
15 ---- Value of x
Output:
2
Constraints
1 <= n1
1 <= n2
0 <= k < 1000
Given a sentence Str. The task is to find whether the given sentence contains all letters of the English alphabet (a to z or A to Z). If it does not, then print all missing letters of the alphabet, otherwise print 0.
Note:
Example 1:
Input
The four boxing wizard starts over the quickly --- Value of Str
Output
jmp --- Missing letters
Explanation:
"The four boxing wizard starts over the quickly does not contains all the letters from a to z or A to Z as 'j', 'm' and 'p' are missing.
Example 2: Input
The four boxing wizard jumps over the quickly --- Value of Str
Output
0 -- None of the letters are missing
Explanation:
"The four boxing wizard jumps over the quickly" contains all the letters of the English alphabet. Hence, the output is 0.
Constraints:
The input sentence should not contain any special characters or numbers.
Size of Str <= 500
Question 2
Overview/BreakDown
Approach/Explanation'
Question 1
Overview
PreRequists
Concept of Relative speed and basic maths
Approach/Detailed Solution
while(car1>=car2){ time++; car1+=n1; car2+=n2; }
Hi @Bhargav-8569
TJO is an open community where people can discuss & learn what they like. You can check out "all submissions" tab in problem page though and learn from others accepted solutions.