[ 다먹살 ]/- Coding

[구름] 레벨3 부모단어

엉망으로살기 2021. 8. 4. 11:43
반응형

https://level.goorm.io/exam/43244/%EB%B6%80%EB%AA%A8-%EB%8B%A8%EC%96%B4/quiz/1

 

구름LEVEL

코딩테스트에서 가장 높은 비중을 차지하는 알고리즘 문제를 제작하고 풀이할 수 있는 온라인 저지 서비스입니다. 기업에서 선호하는 C, C++, 파이썬(Python), 자바(Java), 자바스크립트(Javascript) 이

level.goorm.io

 

확실히 동일레벨로 봤을 때 구름이 프로그래머스보다 좀 더 쉬운 것 같다. 체크할 문자열과 대상 문자열을 받은 뒤, HashMap에 넣고 각각의 Map이 같은 크기인지 비교만 하면 되는 문제다. HashTable에 대한 개념만 알고 있으면 해결할 수 있는 문제였다.

 

 

import java.util.Scanner;
import java.util.HashMap;

class Main
{
     public static void main(String[] args) throws Exception
     {
         Scanner sc = new Scanner(System.in);
         String input = sc.nextLine();
         String[] temp = input.split(" ");
         String in = temp[0];
         String chk = temp[1];
         HashMap<Character, Integer> inMap = new HashMap<Character, Integer>();
         HashMap<Character, Integer> chkMap = new HashMap<Character, Integer>();

         for(int i=0; i<in.length(); i++)
         {
             inMap.put(in.charAt(i), 1);
         }
         for(int i=0; i<chk.length(); i++)
         {
             chkMap.put(chk.charAt(i), 1);
         }
         
         if(inMap.size()==chkMap.size())
         {
             System.out.println("YES");
         }
         else
         {
              System.out.println("NO");
         }
     }
}

반응형