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 4e1ffc4

Browse files
2960. Count Tested Devices After Test Operations
1 parent b285da2 commit 4e1ffc4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
3+
// Solution by Sergey Leschev
4+
// 2960. Count Tested Devices After Test Operations
5+
6+
// Time Complexity: O(n)
7+
// Space Complexity: O(1)
8+
9+
func countTestedDevices(_ batteryPercentages: [Int]) -> Int {
10+
var testedDevices = 0
11+
for percentage in batteryPercentages {
12+
testedDevices += (percentage > testedDevices) ? 1 : 0
13+
}
14+
return testedDevices
15+
}
16+
}

0 commit comments

Comments
(0)

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