Skip to content

Commit

Permalink
이슈 #393에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 26, 2024
1 parent eff0018 commit 7954243
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Programmers/겹치는_선분의_길이.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <string>
#include <vector>

using namespace std;

int solution(vector<vector<int>> lines) {
vector<int> overlap(201, 0);

for (const auto& line : lines) {
int start = line[0] + 100;
int end = line[1] + 100;
for (int i = start; i < end; ++i) {
overlap[i]++;
}
}

int result = 0;
for (int i = 0; i < 201; ++i) {
if (overlap[i] > 1) {
result++;
}
}

return result;
}

0 comments on commit 7954243

Please sign in to comment.