Movatterモバイル変換


[0]ホーム

URL:


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

Commit3564a92

Browse files
yue2388253haoel
authored andcommitted
New C++ Solution "Largest Perimeter Triangle"
1 parentbb0ede1 commit3564a92

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
classSolution {
2+
public:
3+
intlargestPerimeter(vector<int>& A) {
4+
if (A.size() <3)return0;
5+
sort(A.begin(), A.end(), greater<int>());
6+
for (auto it = A.begin(); it != A.end() -2; ++it) {
7+
if (*it < *(it +1) + *(it +2))
8+
return *it + *(it +1) + *(it +2);
9+
}
10+
return0;
11+
}
12+
};
13+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp