Skip to content

Commit

Permalink
최대값과 최소값 - level2
Browse files Browse the repository at this point in the history
  • Loading branch information
sey2 authored Aug 28, 2022
1 parent 185269e commit fe15d5e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions programmers/MaxMin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

class Solution {
public String solution(String s) {
String str[] = s.split(" ");

int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;

for(int i=0; i<str.length; i++){
min = Math.min(min, Integer.parseInt(str[i]));
max = Math.max(max, Integer.parseInt(str[i]));
}

return min+ " " + max;
}
}

0 comments on commit fe15d5e

Please sign in to comment.