분류 전체보기188 BFS package method; import java.util.*; public class bfs { static HashSet myBfs(HashMap map, Integer start){ var visitQ = new LinkedList(); var visited = new HashSet(); // 초기값 셋팅 visitQ.add(start); visited.add(start); while(!visitQ.isEmpty()) { // 현재노드 var nowNode = visitQ.pop(); // 여기서 방문처리해도 되지만 미리 해줌 // 현재노드와 인접한 노드 for(var nextNode : map.get(nowNode)) { // 인접한 노드중 방문한 노드가 아니면 if(!visited.contain.. 2024. 1. 31. java 4 LinkedList 사용법 https://codedragon.tistory.com/6113 LinkedList 클래스의 주요 메소드 LinkedList 클래스의 주요 메소드LinkedList는 Queue인터페이스(JDK 1.5)와 Dequeue인터페이스(JDK 1.6)를 구현하도록 변경되었습니다.LinkedList도 List인터페이스를 구현했기 때문에 ArrayList와 내부 구현방법만 codedragon.tistory.com 추가 및 삽입: add(E e): 리스트의 끝에 요소를 추가합니다. 시간 복잡도는 O(1). add(int index, E element): 지정된 위치에 요소를 삽입합니다. 시간 복잡도는 O(n) (인덱스까지 순회 필요). addFirst(E e): 리스트의 처음에 요소를 추가합.. 2024. 1. 30. Git 다운로드 & 이클립스 연동, 이메일 설정 https://m.blog.naver.com/PostView.naver?blogId=wldks79&logNo=222141957605&categoryNo=38&proxyReferer= GitHub 깃허브 기초적인 사용법, (feat. 잔디심기) #coding #java #git #GitHub #잔디심기 #GitHub사용법 #깃 #깃허브 깃(git) 과 깃허브(GitHub) 기초... blog.naver.com https://velog.io/@yoon_han0/fatal-not-a-git-repository-or-any-of-the-parent-directories-.git [해결방법] fatal: not a git repository (or any of the parent directories): .git.. 2024. 1. 30. Java 3 String 문자열 => 특정 역역의 문자열 가져오기 ex) python str = "abcde" print(str[0:3]) 결과 => abc java 문자열 자르기 => str.substring(a,b); java 에는 String 객체에 substring메서드 존재 String str = "abcde"; System.out.println( str.substring(0:3) ); 결과 => abc java 문자열 => 문자[] String to char[] => str.toCharArray(); java 문자[] => 문자열 char[] to String => Arrays.toString(char[]); java 문자열 비교 => equals() 메소드 1. Object.equals(str1, str.. 2024. 1. 29. 프로그래머스. 둘만의 암호. Java and Python import java.util.*; class Solution { public String solution(String s, String skip, int index) { String answer = ""; char[] skipChArr = skip.toCharArray(); char[] sChArr = s.toCharArray(); var skipChIntSet = new HashSet(); var chList = new ArrayList(); for(char ch : skipChArr) skipChIntSet.add((int)ch); for(char ch : sChArr){ int chInt = (int)ch; //index처리 for(int i=0; i (int)('z')) chInt = (int).. 2024. 1. 26. 프로그래머스. 완주하지 못한 선수. Java and Python 1. java import java.util.*; class Solution { public String solution(String[] participant, String[] completion) { String answer = ""; HashMap hMap = new HashMap(); for(String c :completion){ if(hMap.containsKey(c)){ hMap.put(c, hMap.get(c)+1); }else{ hMap.put(c, 1); } } for(String p : participant){ if(hMap.containsKey(p)){ int tm = hMap.get(p) - 1; if(tm == -1) return p; else hMap.put(p,tm); }els.. 2024. 1. 26. 이전 1 ··· 6 7 8 9 10 11 12 ··· 32 다음