leetcode.com/problems/valid-anagram/ Valid Anagram - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 파라미터로 2개의 문자열 주면 anagram이면 true 아니면 false 걍 sort시켜버리면 됨. impl Solution { pub fn is_anagram(s: String, t: String) -> bool { let mut s_sort : Vec= s.chars().collect(); let mut t_sort ..
leetcode.com/problems/merge-intervals/ Merge Intervals - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 2차원 배열을 intervals를 주고 원소별 범위가 겹치는 것에 대해 범위를 merge시키는 문제임 원소가 2개인 배열 st를 만들어서 intervals의 원소를 검사해 나가며 겹치는 범위를 st[0] ~ st[1]에 각각 저장 범위를 벗어나는 원소를 만나면 answer배열에 push하고 st를 비운 후 st에 새..
leetcode.com/problems/task-scheduler/ Task Scheduler - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 작업 스케줄을 tasks 배열로 인자에 넘겨준다. 배열에는 작업해야 될 task가 주어지며 task는 알파벳 대문자 char로 표현된다. 각 작업에는 cool time이 존재한다. 1time에 1개의 작업만 수행 한다. 한 작업이 수행 된 경우 cool time n시간 동안 해당 작업을 다시 할 수 없다. 쿨타임의 존재..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/bZ2x9F/btq4ntr9tdE/cqvJ4zAmqelgamj1kbgU1k/img.png)
leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 정상적인 괄호 양식이 맞는 경우 true, 정상적인 양식이 아닐 경우 false를 return하는 문제 간단하게 stack을 이용하여 해결 가능하다. time complexity : O(n) space complexity : O(n) #include #include using namespace std; cla..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/brVyz2/btq4jX6FPLU/aJ3jlYCPs6GfJQSy27N750/img.png)
leetcode.com/problems/word-search-ii/ Word Search II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 2차원 배열 board와 1차원 배열 words가 주어짐 board에서 words의 문자를 만들 수 있으면 해당 문자를 반환함 words는 board에서 상하좌우로 이어질 수 있고 이어져 있지 않다면 만들 수 없는 문자임 rust코드로 작성 use std::collections::HashMap; #[derive(Defa..
leetcode.com/problems/implement-trie-prefix-tree/ Implement Trie (Prefix Tree) - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Trie는 문자열 탐색 알고리즘 중 하나. root 노드에서부터 자식 노드를 따라 내려가며 문자 하나하나 완성시켜나가는 알고리즘. insert함수를 실행하면 Trie에 문자열을 Trie알고리즘에 따라 입력 search함수를 실행하면 parameter로 받아온 문자열이 있을 ..
leetcode.com/problems/course-schedule-ii/ Course Schedule II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com //위상정렬 //1. incoming 없는 node부터 시작 //2 .outgoing node로 이동 //3. outgoing 이동후 해당 node에서 incoming 삭제 //4. 해당 node에서 그 다음 outgoing node로 이동 //5. 2~4반복 //6. outgoing으로 이동한 해당 no..
![](http://i1.daumcdn.net/thumb/C148x148.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/chcjcP/btq3TMEO22m/UpkKzguGzqNW58YkTd1ZL0/img.png)
leetcode.com/problems/number-of-provinces/ Number of Provinces - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 그래프가 주어진다. 각 노드는 하나씩 도시이다. 각 노드는 연결되어있을수도 있고 연결되지 않을수도 있다. 모두 연결되어있을 경우 하나의 도 라고 친다. 2차원 배열로 그래프가 주어질 때 총 도의 수를 반환하는 문제이다. #include #include using namespace std; class S..