🙈

⃝ 동글동글 ⃝

🪐ᐩ˖ 🍎
728x90
반응형
SMALL

hashmap 5

[프로그래머스 고득점 Kit] 베스트앨범 - Hash(해시) - Lv3

⭐️ 코드 (HashSet 이용) 정답 코드지만 직접 풀어보면서 출력해 봤던 테스트 코드!! 이번 문제는 완전 리스트와 해시맵의 중첩이었다... import java.util.*; public class 베스트앨범 { static class Solution { private static class Node { int idx; String genre; int play; public Node(int idx, String genre, int play) { this.idx = idx; this.genre = genre; this.play = play; } @Override public String toString() { return "Node{" + "idx=" + idx + ", genre='" + genre..

[프로그래머스 고득점 Kit] 의상 - Hash(해시) - Lv2

⭐️ 코드 (HashSet 이용) 1. HashMap에 옷의 종류별로 개수를 카운트한다. 2. 해당 옷을 안 입는 경우도 있기 때문에 경우의 수 + 1을 해준다. 3. 모든 옷을 안 입는 경우는 없기 때문에 결과 -1을 해서 개수 세기! import java.util.*; class Solution { public int solution(String[][] clothes) { int answer = 0; HashMap hashMap = new HashMap(); for (int i = 0; i < clothes.length; i++) { hashMap.put(clothes[i][1], hashMap.getOrDefault(clothes[i][1], 0) + 1); } int count = 1; for (..

[프로그래머스 고득점 Kit] 전화번호 목록 - Hash(해시) - Lv2

⭐️ 코드 (HashSet 이용) import java.util.*; class Solution { public boolean solution(String[] phone_book) { boolean answer = true; HashSet hashSet = new HashSet(); for (int i = 0; i < phone_book.length; i++) { hashSet.add(phone_book[i]); } for (int i = 0; i < phone_book.length; i++) { for (int j = 0; j < phone_book[i].length(); j++) { if (hashSet.contains(phone_book[i].substring(0, j))) { return fals..

[프로그래머스/Programmers] 영어 끝말잇기 (Java - HashSet - Lv2)

영어 끝말잇기 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr ⭐️ 코드 import java.util.HashMap; class Solution { public int[] solution(int n, String[] words) { int[] answer = new int[2]; HashMap hashMap = new HashMap(); for (int i = 0; i 0 && !(words[i].charAt(..

[프로그래머스/Programmers] 신고 결과 받기 (Java - HashMap)

https://school.programmers.co.kr/learn/courses/30/lessons/92334 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 💬 문제 접근 중복을 제거하기 위해 HashSet과 HashMap을 사용한다. 2명 이상 User를 신고하면 계정이 정지가 되고, 신고한 User에게 메일을 보낸다. 따라서 HashMap에 신고당한 User와 신고한 User의 정보가 담겨야 한다. 신고한 User는 여러명이 될 수 있기 때문에 신고한 User가 중복이 되지 않도록 HashMap 안에 HashSet을 포함해 준다. 💡 문제 풀이 /..

728x90
반응형
LIST