본문 바로가기

Algorithm

(2139)
(C++) - LeetCode (easy) 1002. Find Common Characters https://leetcode.com/problems/find-common-characters/ LeetCode - The World's Leading Online Programming Learning Platform 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. alphabat별 전체 words의 최소 빈도를 저장할 vector minFreq를 선언 후 각 값을 INT_MAX로 초기화해줍니다. 2. 정답 변수 ..
(C++) - LeetCode (easy) 999. Available Captures for Rook https://leetcode.com/problems/available-captures-for-rook/description/ LeetCode - The World's Leading Online Programming Learning Platform 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. {행, 열}을 저장할 struct Coord를 선언합니다. 2. 정답변수 ans를 선언해줍니다. 📔 풀이과정 1. rook의 행,..
(C++) - LeetCode (easy) 1005. Maximize Sum Of Array After K Negations https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/ LeetCode - The World's Leading Online Programming Learning Platform 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 greedy문제 였습니다. 📕 풀이방법 📔 풀이과정 원소 전체 합이 최대가 되려면 가장 작은 음수부터 최대한 flip해줘야합니다. 따라서 1. nums를 먼저 오름차순으로 정렬해줍니다.2..
(C++) - LeetCode (easy) 997. Find the Town Judge https://leetcode.com/problems/find-the-town-judge/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 전수조사 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 i번째 사람을 믿는 사람 수를 세기 위한 vector trusted와 i번째가 믿는 사람이 존재하는지 여부를 저장할 vector isTrust를 ..
(C++) - LeetCode (easy) 993. Cousins in Binary Tree https://leetcode.com/problems/cousins-in-binary-tree/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 자료구조 순회 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 구조체 Info를 선언합니다. node의 깊이 depth와 부모정보 parent를 member 변수로 선언했습니다.x와 y의 정보를 저..
(Python3) - LeetCode (easy) 989. Add to Array-Form of Integer https://leetcode.com/problems/add-to-array-form-of-integer/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 큰 수 다루는 문제였습니다. 📕 풀이방법 📔 풀이과정 큰 수 사칙연산을 지원하는 python3을 사용해 풀었습니다.1. int로의 문자열 변환에 사용할 수 있는 문자열의 최대 길이가 1..
(C++, Rust) - LeetCode (easy) 977. Squares of a Sorted Array https://leetcode.com/problems/squares-of-a-sorted-array/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 정렬 해보는 문제였습니다. 📕 풀이방법 📔 풀이과정 각 원소를 제곱한 후 오름차순으로 정렬하면 됩니다.sort()함수를 적절히 사용해줍니다. 📕 Code 📔 C++ class Solution..
(C++) - LeetCode (easy) 965. Univalued Binary Tree https://leetcode.com/problems/univalued-binary-tree/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 tree 순회 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 tree node의 종류를 저장할 set s를 선언해줍니다. 📔 풀이과정 preOrder로 s에 각 tree node를 순회한 결과를 저..