Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 16d5f58

Browse files
Create 3376. Minimum Time to Break Locks I.cpp
1 parent 1caf2c1 commit 16d5f58

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//TC : O(N^2);
2+
//SC : O(N);
3+
4+
class Solution {
5+
public:
6+
int fun(vector<int>strength, int k){
7+
int minites = 0;
8+
int x =1;
9+
for(int i=0;i<strength.size();i++){
10+
minites += ceil(((float)strength[i])/x);
11+
x+=k;
12+
}
13+
return minites;
14+
}
15+
int findMinimumTime(vector<int>& strength, int K) {
16+
vector<int>temp = strength;
17+
int ans;
18+
ans = fun(strength,K);
19+
next_permutation(strength.begin(),strength.end());
20+
while(strength!=temp){
21+
int mini = fun(strength,K);
22+
ans = min(mini,ans);
23+
next_permutation(strength.begin(),strength.end());
24+
}
25+
26+
return ans;
27+
}
28+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /