전체 글34 구름 구름스퀘어 java 답 import java.io.*; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int ninput = Integer.parseInt(br.readLine()); int[][] time = new int[ninput][2]; StringTokenizer st; for (int i = 0; i < ninput; i++) { String[] st.. 2024. 3. 15. 인텔리제이 import 자동 접힘 해제 Imports 체크 해제 2023. 5. 8. leetcode 1221. Split a String in Balanced Strings 자바 코드 균형잡힌 문자열이 하나 주어짐 R과L로 균형잡힌 문자열을 몇개 낼 수 있는지 구하는 문제 그리디 알고리즘 썼음 작성한 코드 class Solution { public static int calculater(String s) { int count = 0; int balance = 0; int cal = 0; for (char c :s.toCharArray()) { if(c == 'R') { cal = 1; } else { cal = -1; } balance += cal; if(balance == 0) { count ++; } } return count; } } 테스트코드 import org.junit.jupiter.api.*; import static org.assertj.core.api.Assertion.. 2023. 5. 8. 1859. Sorting the Sentence 자바 코드 Input: s = "is2 sentence4 This1 a3" 이거를 Output: "This is a sentence" 이렇게 정렬 import java.util.Arrays; import java.util.stream.Collectors; class Solution { public static void main(String[] args) { System.out.print(sortSentence("is2 sentence4 This1 a3")); } public static String sortSentence(String s) { String[] strings = s.split(" "); String collectString = Arrays.stream(strings).sorted( (string1, .. 2023. 5. 2. 이전 1 2 3 4 ··· 9 다음