일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- collections.deque
- Sequential Search
- shapeArea
- til
- centuryFromYear
- 파이썬머신러닝완벽가이드
- recursion
- 수 정렬하기
- Python
- 2750
- data_structure
- 파이썬 포렌식
- cpp
- 2015 봄학기 알고리즘
- 백준
- Counting cells in a blob
- 10953
- 피보나치 수
- Daily Commit
- flask
- adjacentElementsProduct
- codesingal
- markdown
- codesignal
- baekjun
- All Longest Strings
- almostIncreasingSequence
- matrixElementsSum
- Numpy
- C++
- Today
- Total
목록분류 전체보기 183
Introfor
다음과 같이 삼각형 모양으로 수를 배열했습니다. 3 7 4 2 4 6 8 5 9 3 삼각형의 꼭대기부터 아래쪽으로 인접한 수를 찾아 내려가면서 합을 구하면, 위의 그림처럼 3 + 7 + 4 + 9 = 23 이 가장 큰 합을 갖는 경로가 됩니다. 다음 삼각형에서 합이 최대가 되는 경로를 찾아서 그 합을 구하세요. 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 32 37 16 94 29 53 71 44 65 25 43 91 52 97 51 14 70 11 33 28 77 73 17 78 3..
이 문제는 위 표에서 보이는 0과 1로 구분된 이미지인 binary image를 가진다. 파란색은 image pixel(1), 흰 색은 background pixel(0)이라고 할 때, 상하좌우 및 대각선방향으로 서로 연결된 image pixel들의 집합을 blob라고 한다. 이 문제는 특정 위치 (x, y)에서 blob이 존재하면 그 blob의 셀 개수를 계산하는 문제다. Solving problem 주어진 위치가 존재하는지 여부 판별 - x 혹은 y의 값이 범위를 넘어갈 경우 0을 반환 주어진 위치가 image pixel 아닌 판별 - image pixel이 아닌 경우 0을 반환 - blob를 구해야하기 때문에 image pixel이 아닌 경우 필요 없음. 위 조건들이 모두 일치하지 않을 경우, 주어..
#include int size = 8; int maze[8][8] = { {0, 0, 0, 0, 0, 0, 0, 1}, {0, 1, 1, 0, 1, 1, 0, 1}, {0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 1, 0, 0}, {0, 1, 1, 1, 0, 0, 1, 1}, {0, 1, 0, 0, 0, 1, 0, 1}, {0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 0, 0}, }; int pathWay = 0; int wall = 1; int blocked = 2; int path = 3; int find_path(int x, int y){ if (x=size) return 0; else if (maze[x][y] != pathWay) ..
#include #include typedef struct node{ int data; struct node* next; } Node; int main(){ Node* head = NULL; head = (Node*)malloc(sizeof(Node)); head->data = 1; head->next = NULL; Node* q = (Node *)malloc(sizeof(Node)); q->data = 2; q->next = NULL; head->next = q; q = (Node *)malloc(sizeof(Node)); q->data = 0; q->next = head; head = q; Node *p = head; while(p!=NULL){ printf("%d\n", p->data); p = p..
이 글은 인프런에서 "영리한 프로그래밍을 위한 알고리즘 강좌"를 제 생각과 더불어 이해하기 쉬운 방식으로 정리한 글입니다. Recursion(재귀, 순환) def func(n): if nend: return -1 elif target == data_list[start]: return start else: return sequencial_search(data_list, start+1, end, target) data_list = [4, 2, 1, 6, 5, 7, 3] print(sequencial_search(data_list, 0, len(data_list)-1, 5)) 더보기 4 위 코드에서 sequencial_search 함수의 매개변수를 보면 데이터 리스트, 시작점, 끝점, 목표값으로 구성되어 있다..
Queue는 스택과 달리 한 쪽에서 들어가서 다른 한 쪽으로 나오는 구조로 파이프을 연상하면 쉽게 이해할 수 있다. 일직선으로 양쪽이 뚫린 파이프 모형에 어떤 물체를 넣는다면 처음에 넣어던 물체가 제일 처음 나오는 구조인 것을 알 수 있다. 이것을 FIFO(First In First Out)이라고 한다. class Queue: def __init__(self): self.items = [] self.max = 5 def add(self, item): if len(self.items) 0: self.items.pop(0) else:..
보호되어 있는 글입니다.
Stack 영어로 '쌓다'라는 의미를 가지는 것처럼 알고리즘에서 의미도 동일하다. 하나의 스택 공간이 주어지고, 그 공간에 데이터를 쌓는다. 그리고 그 공간에 있는 데이터를 활용하기 위해서 마지막에 넣은 데이터부터 순차적으로 빼는 과정을 가진다. 이것을 마지막에 들어간 데이터가 먼저 나온다라고 해서 LIFO(리포, Last IN First Out)라고 부른다. stack 구조를 사용하는 예로 chrome이나 whale 등과 같은 브라우저에서 사용되는 back button과 DFS(Depth First Search) 깊이 우선 탐색이 있다. DFS의 경우 나중에 블로그에 업로드할 계획이다. C #include #define STACK_SIZE 500 int stack[STACK_SIZE]; int top ..
Given an array of strings, return another array containing all of its longest strings. 주어진 문자열들에서 가장 긴 모든 문자열을 다른 배열에 포함에서 반환해라. def allLongestStrings(array): return [i for i in array if len(i)==len(max(array, key=len))] array 각각의 요소에 대해 array의 최댓값과 비교해서 같다면 리스트 요소에 넣고 리턴한다.
After becoming famous, the CodeBots decided to move into a new building together. Each of the rooms has a different cost, and some of them are free, but there's a rumour that all the free rooms are haunted! Since the CodeBots are quite superstitious, they refuse to stay in any of the free rooms, or any of the rooms below any of the free rooms. Given matrix, a rectangular matrix of integers, wher..