Skip to content

Commit

Permalink
이슈 #377에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 21, 2024
1 parent b6b4570 commit 0ed205c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Programmers/직사각형_넓이_구하기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <string>
#include <vector>

using namespace std;

int solution(vector<vector<int>> dots) {
int width = 0;
int height = 0;

int min_x = dots[0][0];
int max_x = dots[0][0];
int min_y = dots[0][1];
int max_y = dots[0][1];

for(int i = 1; i < dots.size(); i++) {
min_x = min(min_x, dots[i][0]);
max_x = max(max_x, dots[i][0]);
min_y = min(min_y, dots[i][1]);
max_y = max(max_y, dots[i][1]);
}

width = max_x - min_x;
height = max_y - min_y;

return width * height;
}

0 comments on commit 0ed205c

Please sign in to comment.