Deep_Dev
article thumbnail

๋ฌธ์ œ ์„ค๋ช…

์˜์–ด ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ง„ ๋ฌธ์ž์—ด my_string์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, my_string์„ ๋ชจ๋‘ ์†Œ๋ฌธ์ž๋กœ ๋ฐ”๊พธ๊ณ  ์•ŒํŒŒ๋ฒณ ์ˆœ์„œ๋Œ€๋กœ ์ •๋ ฌํ•œ ๋ฌธ์ž์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”.

 

 

์ œํ•œ์‚ฌํ•ญ
  • 0 < my_string ๊ธธ์ด < 100

 

 

์ž…์ถœ๋ ฅ ์˜ˆ
"Bcad" "abcd"
"heLLo" "ehllo"
"Python" "hnopty"

 

 


๋กœ์ง์€ ๋ถ„๋ช… toLowerCase -> sort ํ•˜๋ฉด ๋˜๊ฒ ๊ตฌ๋‚˜ ์ƒ๊ฐ์€ ํ–ˆ๋Š”๋ฐ 

๋ฌธ์ž์—ด๋ฌธ์ œ๊ฐ€ ์•„์ง ์•ฝํ•ด์„œ .. char ๋ฐฐ์—ด์„ ์ƒ์„ฑ๋งŒ ํ•˜๋ฉด ๋๋Š”๋ฐ ์ด๊ฑธ ์ƒ๊ฐ๋ชปํ•ด์„œ ๊ทธ๋ƒฅ ๋Œ์•„๊ฐ”๋‹ค ; 

 

char[] ch=my_string.toLowerCase.toCharArray();......... 

๊ธฐ์–ตํ•ด;;;


import java.util.Arrays;
import java.util.Scanner;
class Solution {
    public String solution(String my_string) {
        String answer="";
        char[] ch=my_string.toCharArray();
        char[] chars=new char[ch.length];
        for(int i=0; i<ch.length; i++){
            chars[i]=Character.toLowerCase(ch[i]);
        }
        Arrays.sort(chars);
        for(int i=0; i<chars.length; i++){
            answer+=chars[i];
        }
        return answer;
    }
}

 

 

 


๋‚ด๊ฐ€ ์›ํ–ˆ๋˜ ํ’€์ด...( ๋‹ค๋ฅธ ์‚ฌ๋žŒ ํ’€์ด )

 

return new String(c)๊ฐ€ ๋˜๋Š”๊ฑฐ๊ตฌ๋‚˜ .  .