Skip to content

Commit f4d2051

Browse files
authored
Add files via upload
1 parent 4a38bb2 commit f4d2051

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

C++/1701. Average Waiting Time.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
double averageWaitingTime(vector<vector<int>>& customers) {
4+
int time = customers[0][0];
5+
double ans = 0;
6+
for (int x = 0; x < customers.size(); ++x) {
7+
if (time < customers[x][0]) {
8+
time = customers[x][0] + customers[x][1];
9+
}
10+
else {
11+
time += customers[x][1];
12+
}
13+
ans += time - customers[x][0];
14+
// cout << ans << "," << time << endl;
15+
}
16+
ans /= (double)customers.size();
17+
return ans;
18+
}
19+
};

0 commit comments

Comments
 (0)