로딩
요청 처리 중입니다...

JAVA_LeetCode 1859_Sorting the Sentence

 JAVA_LeetCode 1859_Sorting the Sentence

JAVA_LeetCode 1859_Sorting the Sentence 풀이 class Solution { public String sortSentence(String s) { // 각 문자의 끝에 숫자가 있으며, 1~9까지의 수만 있으므로 문자열을 공백으로 나눠 각 문자별 숫자를 체크한다. String[] str = s.split(" "), words = new String[str.length]; int num = 0; for (String str2 : str) { num = str2.charAt(str2.length() - 1) - '0'; words[num - 1] = str2.substring(0, str2.length() - 1); } return String.join(" ", words); } } * 출처 https://leetcode.com/problems/sorting-the-sentence...

# JAVA # JAVA_LeetCode1859 # JAVA_LeetCode1859_SortingtheSentence # JAVA_SortingtheSentence # LeetCode1859_SortingtheSentence