답안 :
class Solution {
public String solution(String s) {
String[] words = new String[s.length()];
words = s.split(" ");
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for (String num : words) {
max = Integer.parseInt(num) > max ? Integer.parseInt(num) : max;
min = Integer.parseInt(num) < min ? Integer.parseInt(num) : min;
}
String answer = min + " " + max;
return answer;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Solution s = new Solution();
String s1 = "1 2 3 4";
System.out.println(s.solution(s1));
}
}
답안 :
class Solution {
public String solution(String s) {
StringBuffer sb = new StringBuffer();
char[] words = new char[s.length()];
for (int i = 0; i < s.length(); i++) {
words[i] = s.charAt(i);
}
if (Character.isDigit(words[0])) {
sb.append(words[0]);
} else {
sb.append(Character.toUpperCase(words[0]));
}
for (int i = 1; i < words.length; i++) {
if (words[i - 1] == ' ') {
sb.append(Character.toUpperCase(words[i]));
} else {
sb.append(Character.toLowerCase(words[i]));
}
}
String answer = sb.toString();
return answer;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Solution s = new Solution();
String s1 = "3people unFollowed me";
System.out.println(s.solution(s1));
}
}
답안 :
SELECT
machine_id,
ROUND(SUM(CASE WHEN activity_type='start' THEN timestamp*-1 ELSE timestamp END)*1.0
/ (SELECT COUNT(DISTINCT process_id)),3) AS processing_time
FROM
Activity
GROUP BY machine_id