본문 바로가기
반응형

#알고리즘 [Algorithm]47

[Algorithm - Concept] 트라이 알고리즘 (Trie Algorithm) [Algorithm - Concept] 트라이 알고리즘 (Trie Algorithm) In computer science, a trie, also called digital tree, radix tree or prefix tree, is a kind of search tree—an ordered tree data structure used to store a dynamic set or associative array where the keys are usually strings. Unlike a binary search tree, no node in the tree stores the key associated with that node; instead, its position in the tree de.. 2019. 8. 27.
[프로그래머스 - 구현] 자동완성 (for kakao) 카테고리 게시글 작성 날짜 게시글 최근 수정 날짜 작성자 Algorithm 2019-08-27 20:38 2022.02.26. 19:51 Dev.Yang 포털 다음에서 검색어 자동완성 기능을 넣고 싶은 라이언은 한 번 입력된 문자열을 학습해서 다음 입력 때 활용하고 싶어 졌다. 예를 들어, go 가 한 번 입력되었다면, 다음 사용자는 g 만 입력해도 go를 추천해주므로 o를 입력할 필요가 없어진다! 단, 학습에 사용된 단어들 중 앞부분이 같은 경우에는 어쩔 수 없이 다른 문자가 나올 때까지 입력을 해야 한다. 효과가 얼마나 좋을지 알고 싶은 라이언은 학습된 단어들을 찾을 때 몇 글자를 입력해야 하는지 궁금해졌다. 예를 들어, 학습된 단어들이 아래와 같을 때 go gone guild go를 찾을 때 go를.. 2019. 8. 27.
[프로그래머스 - 정렬] 파일명 정렬 (for kakao) 📄 [정렬] 파일명 정렬 C++ Source Code #include #include #include #include using namespace std; #define STR_FILE_PAIR pair const string removeZero(string number) { auto end = number.begin(); while (number.end() != end && *end == 48) { end++; } // 문자열 앞에 숫자 0을 제거한다. if (number.begin() != end) { number.erase(number.begin(), end); } return number.empty() ? "0" : number; } const bool isDigit(const char lette.. 2019. 8. 14.
[프로그래머스 - 구현] 압축 (for kakao) 📄 [구현] 압축 C++ Source Code #include #include #include using namespace std; /*LZW 압축은 다음 과정을 거친다. ⓐ 길이가 1인 모든 단어를 포함하도록 사전을 초기화한다. ⓑ 사전에서 현재 입력과 일치하는 가장 긴 문자열 w를 찾는다. ⓒ w에 해당하는 사전의 색인 번호를 출력하고, 입력에서 w를 제거한다. ⓓ 입력에서 처리되지 않은 다음 글자가 남아있다면(c), w+c에 해당하는 단어를 사전에 등록한다. ⓔ 단계 2로 돌아간다. */ #define INT_PAIR pair // ※ CAPTION - 압축 알고리즘이 영문 대문자만 처리한다고 한다. vector solution(string msg) { vector answer; unordered_.. 2019. 8. 13.
반응형