#INFO 난이도 : Easy 출처 : https://leetcode.com/problems/majority-element/ Majority Element - 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 #SOLVE 다양한 방식으로 접근할 수 있는 문제입니다. 비효율적인 코드로도 풀이할 수 있지만 Follow-up 조건인 Time Complexity - Linear Time & Space Complexity - O(1) 을 지켜서 문제를 풀이하고자 할 경우엔 ..
#INFO 난이도 : SILVER2 문제 유형 : Linked List 출처 : https://www.acmicpc.net/problem/1406 #SOLVE 연결 리스트 자료구조를 연습할 수 있는 좋은 문제였습니다. 우선 string으로 abc를 문자열 형태로 입력받은 뒤 char형 연결 리스트를 하나 생성해 모두 넣어줍니다. string str = ""; cin >> str; list editor; for(const auto& i : str){ editor.push_back(i); } 커서는 마지막을 가리켜야 하기에, iterator는 editor(연결 리스트)의 마지막 원소 즉, editor.end()를 가리키도록 합니다. list::iterator cursor = editor.end(); 다음으로..
#INFO 난이도 : Easy 알고리즘 : Stack 출처 : https://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 #SOLVE 스택 자료구조를 활용하면 간단하게 풀이할 수 있는 문제이다. 문자열 s 가 매개변수로 주어지며, s는 '(' , ')' , '{' , '}' , '[', ']' 문자 만을 포함한다. 여는 괄호는 반드시 그에 맞는 닫는 괄..
#INFO 난이도 : Easy 문제 유형 : 구현 출처 : https://leetcode.com/problems/concatenation-of-array/ #SOLVE 주어진 배열을 그대로 복사하여 뒤에 추가한 새로운 배열을 만들면 되는 간단한 문제이다. C++ STL Vector 컨테이너에서 제공하는 insert 멤버함수를 사용해 문제를 풀이했다. → insert member function vector::iterator it = nums.insert(nums.end(), nums.begin(), nums.end()); #CODE class Solution { public: vector getConcatenation(vector& nums) { vector::iterator it = nums.inser..
#INFO Rate : 900 출처 : Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) https://codeforces.com/problemset/problem/1075/A #SOLVE 처음에는 각 퀸과 코인 사이의 거리를 좌표로 나타내어 점과 직선 사이의 거리 공식을 이용해 문제를 풀이 하고자 하였다. #include using namespace std; int main(){ long long n, r, c; cin >> n >> r >> c; long long whiteLen = (r - 1) * (r - 1) + (c - 1) * (c - 1); long long blackLen = (n - r) * (n - r) + (n - c) * (n - ..