Free Lines Arrow
본문 바로가기
728x90

Algorithm77

[프로그래머스] 영어끝말잇기 문제 분석 2단계라 그렇게 어렵진 않았다. 입출력 예제를 보면 인덱스를 주어 쉽게 풀수 있다. 현재 몇회차 끝말잇기가 진행되었는지 탈락자는 몇번 인지. 구현 import java.util.*; class Solution { public int[] solution(int n, String[] words) { int[] answer = new int[2]; ArrayList checkWordList = new ArrayList(); int rotateCount = 1; int wordCount = 1; int currentCount = 1 ; boolean isWrongWord = false; for(int i = 0; i < words.length-1; i++) { wordCount++; currentCo.. 2021. 10. 15.
[Algorithm] Huffman Coding 3: Decoding 예제 설명 과 구현 Huffman 개념 https://vprog1215.tistory.com/232 [Algorithm] Huffman Coding 1: 개념 Huffman Coding 무손실 압축 알고리즘이다. Huffman Coding 예시 파일 안에는 a,b,c,d,e,f 의 단어만 있다고 가정한다. 파일의 크기는 100,000 개 이고 각 문자의 등장 횟수는 다음과 같다. Fixed-length code:.. vprog1215.tistory.com Decoding 앞서 encoding 한 파일을 decoding 하면 된다. 방법은 간단하다 이미 file 에는 run 의정보 가 담겨 있다. run 을 읽고 codeword 를 따라서 트리를 조회 하면 된다. run 을 읽어들이는 코드 private void inputF.. 2021. 10. 15.
[Algorithm] Huffman Coding 2: Encoding 예제 설명 과 구현 Huffman 개념 https://vprog1215.tistory.com/232 [Algorithm] Huffman Coding 1: 개념 Huffman Coding 무손실 압축 알고리즘이다. Huffman Coding 예시 파일 안에는 a,b,c,d,e,f 의 단어만 있다고 가정한다. 파일의 크기는 100,000 개 이고 각 문자의 등장 횟수는 다음과 같다. Fixed-length code:.. vprog1215.tistory.com Huffman Method With Run-Length Encoding 실제 예제를 가지고 어떻게 허프만 알고리즘이 동작 하는지 알아본다. 인코딩 대상 각각의 런을 구하고 해당 런에 코드워드를 부여한다. 즉 런에대해서 이진코드를 부여한다. 예제 AAABAACCAABA 해당.. 2021. 10. 15.
[Algorithm] 벌집 만들기 문제 벌집 모양으로 순서대로 숫자를 채워 나간다. size 에 따라서 크기가 결정된다. 분석 한바퀴 돌았으면 돌았다는 것을 확인하기 위해 rotate 플래그 사용 한바퀴 돌면 한 면에 둘수 있는 size 를 줄여야 한다. 구현 package algorithm.prim; public class HoneyComb { private int [][]map; private int mapMaxX; private int mapMaxY; private int length; private boolean rotate = false; private int []dirX = {1, 2, 1, -1, -2, -1}; private int []dirY = {1, 0, -1, -1, 0, 1}; public void setLengt.. 2021. 10. 5.
728x90
반응형