forked from snahal04/TCS-Coding-Questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber_of_Sundays.cpp
More file actions
53 lines (42 loc) · 938 Bytes
/
Number_of_Sundays.cpp
File metadata and controls
53 lines (42 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Number of Sundays
/*
Given the start day of the month A and number of days in the month B, find number of sundays in the month.
Problem Constraints
A = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
1 <= B <= 109
Input Format
First argument is an string A.
Second argument is an integer B.
Output Format
Return an integer.
Example Input
Input 1:
A = "Sunday"
B = 1
Input 2:
A = "Monday"
B = 14
Example Output
Output 1:
1
Output 2:
2
Example Explanation
Explanation 1:
The only day in the month is sunday.
Explanation 2:
The 7th and 14th day of the month will be sunday
*/
//Solution in CPP
int Solution::solve(string A, int B) {
int j =0;
vector<string> v = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
for(int i=0;i<v.size();i++){
if(A==v[i]){
j = i;
}
}
int D = B+j;
int days = D/7;
return days;
}