대학교 3학년이 되면서, 한동안 어플리케이션 쪽을 공부한다고 미루어 놨던, 코테의 감을 살릴 때가 온거 같다.(취업시장에서 코테를 기본적으로 하더라) 이미 녹슬어버린 코테실력을 되살리기 위해서 한 노력들을 적어보려고 한다.(취업해야지)사실, 취업만이 목적이라면 기업의
알고리즘을 풀기 전에 Vscode로 C++를 컴파일 하기위한 환경 셋팅을 해주자! 단, Window유저라면 Dev c++이나, visual studio와 같이 C/C++와 아주 잘 연동되는 IDE도 있으니까, 귀찮다면 위 2가지 중 하나를 쓰도록하자.Mac이라면 gcc
C++과 같은 Managed Language(메모리를 직접 다루는 언어)를 안한지 너무 오래되서, C++에 대한 특성과 C++의 포인터, 구조체, 클래스 , I/O ,함수 5가지 정도는 가볍게 정리할 예정이다. ( JS, Python 같은 동적언어를 하다보니 , 어느새 머리속에서 C++과 같은 언어는 멀어져버렸다.) 알고리즘은 기본적인 입출력 문제를 풀 ...
Intro 멘탈을 정상화 시키고 다시 하나씩 해보려고 합니다! 제 나름의 정해진 순서대로 공부를 하고있지만, 결국 하고싶은 순서대로 할 예정입니다. 그리고, 문제에 필요한 지식들을 그때 그때 찾아가면서 좀 야생적으로 공부할 생각입니다. 그래도, 필수적인 개념정리는 매일 1개씩 업로드할 예정입니다! > 어떤 문제를 보고, "아 이걸로 풀어야겠다!" 라고 생...
알고리즘 개념 정리글입니다. 이해가 힘드신 부분이거나, 명확하지 않은 부분에 대한 피드백은 언제나 환영합니다! 순열 순열은 개념자체는 간단하다. $$nPr$$ , n개 중 r개를 뽑아서 순서대로 나열하는 모든 경우의 수를 "순열"이라고 한다. 예를들어, A,B,C 3명의 사람이 있을 때, 2명을 뽑아서 줄 세우는 경우의 수를 구한다고 하면, (A,...
알고리즘 개념 정리글입니다. 이해가 힘드신 부분이거나, 명확하지 않은 부분에 대한 피드백은 언제나 환영합니다! 조합 조합은 의미적으로 보자면, 순열안에 있는 개념이다. $$nPr$$은* "n개 중 r개를 뽑아서, 줄세우는 경우의 수"라고 한다면, $$nCr$$은 "n개 중 r개를 뽑는 경우"*이다. 하지만, 수학적으로 구하는 방법으로는 nPr이 훨씬 쉽...
순열과 조합 문제를 풀다보면, "중복하여" 뽑는 문제에 대해서 처리를 해줘야 하는 경우가 있다. 사실, 순열과 조합의 코드를 잘 이해한다면, 어렵지 않게 응용할 수 있는 부분이지만, 은근히 헷갈릴 수도 있기 때문에, 한번 정리해보려고 한다. 중복순열 (Permutation with repetition) 중복순열은 n개 중에 중복 상관없이 r개를 뽑아서,...
알고리즘에 대한 개념을 다루기 전, 필요한 기반 지식들 정리글 입니다. 시간복잡도 측정하기 알고리즘 개념을 공부하기 전, 알고리즘 문제를 풀기위해서 가장 먼저 해야하는 일이 있다. 바로 , 입력값의 갯수를 보고, 시간 복잡도를 측정하는 과정이다. 왜냐하면, 알고리즘은 제한시간 안에 결과값을 도출해내는 로직을 짜야한다. 내가 문제를 풀었다고 해도, 시간초...
다양한 자료구조에 대한 지식은 알고리즘에 대한 지식만큼이나 중요하다. 자료구조는 컴퓨터에 데이터를 효율적으로 저장하고, 조회하고, 수정하는 등에 밀접한 연관이 있기 때문이다. 즉, 효율적인 로직은 "적절한 자료구조와 적절한 알고리즘을 사용하는 것"이므로, 두 가지 모두 알고있어야한다. 배열 배열은 아주 간단하고, 직관적인 자료구조형이다. 자료형을 일렬로...
제목은 항상 거창하게 짓지만 , 중간에 틀린부분이 분명히 있을 수 있습니다! 날카로운 피드백은 언제나 환영합니다. C++에서 Iterator 함수형 프로그램을 하거나 , 객체지향적(OOP)를 했다면 이터레이터라는 말은 사실 낯선용어가 아니다.하지만, 한번도 제대로 공부해보거나 정의를 생각하지 않은체 사용하기만 했다. C++를 사용하면서 Iterator가...
STL 사용법이 아직 익숙하지 못해서 , 컨닝페이퍼 처럼 블로그에 기록을 해보려고 한다. 알고리즘 문제들은 C언어의 Array[]와 같이 전통적인 배열을 사용해도 대부분은 문제가 없었지만, 코드의 간결함과 빠르게 풀 수 있다는 장점 때문에, 앞으로는 STL을 적극적으로 채용하기로 했다. 내가 직접 짜는것 보다, STL은 이미 많은 사람들이 쓰고 있으며, ...
Stack의 활용에서 자주 나오는 구조이다. Stack을 활용하는 대표적인 예시 중에 하나라서, Code Interview때 물어볼 수도 있다. Stack은 함수 Call에도 사용하고, ISR(Interupt Service Routine)에서도 사용되는데, 코딩 테스트에는 Monotone Stack이 자주 나오는거 같다. 개념 개념은 Monotone S...
BFS,DFS 유명한 알고리즘 주제 중 하나이다. 하지만, 처음 공부를 해보면 상당히 뜬금없는 내용으로 느껴질 수도 있다. 왜냐하면, 두가지 이론 모두 '그래프 탐색' 방법 중 하나로써 소개가 된다. 분명히 그래프를 탐색해야하는데, 알고리즘은 문제가 대부분 2차원 배열로 나오는 차이가 존재하기 때문이다. BFS,DFS에서 헷갈릴 수 있는 포인트가 많기 ...
문제를 풀다보니 BFS에도 다양한 활용방법이 있다는걸 깨닫게 됐습니다. 그래서, 그 활용방법에 대해서 간단하게 정리해보려고 합니다. 활용의 범위가 애매하긴 하지만, 제가 느끼기에 이건 쫌 직관적으로 떠올리기 어려운 활용법이라고 생각한 것을 정리해볼 생각입니다. BFS에 대한 이해도가 있다고 가정하고 쭉 정리할 생각이니, 혹시 이 글을 보는 분들 중 BFS...
재귀함수에 대해서 재귀함수와 반복문이라는 글을 짧게 적어놓은게 있습니다. 지금은 재귀에 대한 이해가 저 글을 적을 때보단 깊어진 상태이고, 재귀함수에 대해서 새롭게 안 사실들이 많아서 새롭게 적어보려고 합니다. 재귀 하나의 함수에서 자기 자신을 다시 호출해, 작업을 수행하는 방법입니다. 예를들어, N까지의 합을 구하는 재귀함수를 만들어봅시다. 재귀...
요즘 신나게 구현 문제를 풀다보니, 구현에 대한 테크닉들이 몇개씩 나오고 있어서, 하나씩 기록해보려고 한다. 감시 문제에서는 dx,dy의 좌표를 방향으로 생각하고 n진법으로 나타내는 테크닉이 있었는데, 이번에는 생각보다 꽤 자주나오는 NxN 배열 90도 돌리기이다. 배열 회전하기 사실 , NxM 배열을 90도 회전하는 방법은 아주 많다. 하지만, 원리...
정렬에 대한 정말정말 다양한 방법들이 있지만, 오늘은 3가지 정도만 구현해보려고 합니다. O(N^2)의 대표격인 버블정렬과 O(NlogN)의 대표격인 Merge Sort와 Quick Sort 2개에 대해서 정리해보려고 합니당! 정렬 어렵게 생각하지 않아도 됩니다! 정렬하면 딱 떠오르는 그 행위 그대로입니다. 예를들어, A=[2,5,3,1] 을 A = [...
점차 개념들이 하나하나 등장하기 시작하네요! 오늘은 탐색의 대표격인 이분탐색(Binary Searching)입니다. 저는 Python을 이용할 때도 이분탐색은 직접구현해서 썻기 때문에 이분탐색은 직접구현해서 써야지! 라는 척화비가 있었습니다. 하지만, C++ STL이 훨씬훨씬 쓰기 편하게 되어있고, 이분탐색을 직접 구현하는데 실수가 발생할 수 있기 때문에...
예전 글을 보면, MinGW를 이용해서 윈도우에 C컴파일러를 직접깔아서 vscode와 연결시켜주는 방식으로 이때까지 코딩을 해왔고, 별 문제가 없었다. 하지만 실제로 기업에서 내준 코딩테스트나 교육기관에 가기위해서 시험을 쳤을 때, 처음 본 런타임 에러가 많았어서 환경을 바꿔보려고한다. 알고리즘글에 있는대로 이용한다면, 만약 런타임에러가 발생하면 * 그...
key-value 구조로 자료를 저장하고 싶을 때 혹은 알고리즘에서는 탐색을 잘하기 위해서 자료를 이쁘게 저장하고 싶을 때 많이쓴다. HashMap Key도 객체, Value도 객체. Entry객체를 저장하는 구조를 가지고 있는 자료구조 값은 중복 저장 가능, 키는 중복저장 x 만약, 기존 저장된 키와 동일한 키로 값을 저장하면, 기존의 값은 없...