목록분류 전체보기 (958)
넘치게 채우기
Brute Force. 무식한 힘이란 뜻인데, 풀어 말하면 무식하게 풀기라고 할 수 있다. 완전히 모든 경우를 탐색하여 조건에 맞는 결과를 가져오는 것이다. 속도가 어떻게 될지라도, 반드시 결과를 가져온다. 선형 구조에서는 주로 순차 탐색, 비선형 구조에서는 BFS와 DFS등을 주로 사용한다. 장점으로는 반드시 답을 찾는다는 점이고, 단점으로는 느리거나 메모리를 많이 사용할 수 있다는 점이다. 브루트 포스의 문제 해결 과정 1. 주어진 문제를 구조화 한다. 2. 구조화 된 문제의 모든 해를 구하도록 탐색한다. 3. 구성된 해를 정리한다.
https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/description/ Average Salary Excluding the Minimum and Maximum Salary - LeetCodeCan you solve this real interview question? Average Salary Excluding the Minimum and Maximum Salary - You are given an array of unique integers salary where salary[i] is the salary of the ith employee. Return the average salary of em..
https://leetcode.com/problems/n-th-tribonacci-number/description/?envType=study-plan-v2&id=dynamic-programming N-th Tribonacci Number - LeetCode Can you solve this real interview question? N-th Tribonacci Number - The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. Example 1: Input: n = 4 Output: 4 E l..
https://leetcode.com/problems/fibonacci-number/description/?envType=study-plan-v2&id=dynamic-programming Fibonacci Number - LeetCode Can you solve this real interview question? Fibonacci Number - The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0 leetcode..
https://leetcode.com/problems/reverse-integer/description/ Reverse Integer - LeetCode Can you solve this real interview question? Reverse Integer - Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the envir leetcode.com 문제 유형 : 수학 난이도 : Medium 문제 Given a signed ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bBEMRy/btsdhybRY8P/0Fpek4PYfrjH3nxUp9gffK/img.png)
https://leetcode.com/problems/gas-station/description/ Gas Station - LeetCode Can you solve this real interview question? Gas Station - There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith st leetcode.com 문제 유형 : 그리디 / 브루트 포스 난이도 : Medium 문제 There are n g..
"당장 최선의 수를 고려하기" 탐욕 알고리즘은 매 선택마다 당장의 최선의 선택을 하여 답에 도달하는 방법이다. 항상 최선의 결과를 보여주지는 않지만 특정 상황들 속에서는 굉장히 효과적이고, 직관적이다. 대표적인 예시로는, 거스름돈이 있다. #include #include using namespace std; int input; int wons[4] = {500, 100, 50, 10}; vector calc_coin(int money) { vector coins = vector(4); coins[0] = money / 500; coins[1] = (money % 500) / 100; coins[2] = (money % 100) / 50; coins[3] = (money % 50) / 10; return ..
"이미 알고있는 답은 또 구하지 않는다" 사실 전혀 다이나믹하지 않고, 프로그래밍이라고 하기에도 애매하다. 벨만이라는 수학자가 펀딩을 잘 받기 위해서, 눈에 띄는 이름을 지은 것이다. 이광근 교수님의 저서 "컴퓨터과학이 여는 세계"에서는 '기억하며 풀기'라는 이름이 쓰였다. 하나의 큰 문제를 작은 문제로 나누어서, 그 결과를 얻고, 큰 문제의 답을 구하는 방식이다. "분할 정복법"과도 유사하다. 다이나믹 프로그래밍에는 두 가지 방법이 있다: 종류 메모이제이션 타뷸레이션 과정 하향식(Top down) 상향식(Bottom up) 구현 재귀 함수 반복문 장점 직관적이다 시간을 더 아낄 수도 있다 단점 재귀함수의 호출이 잦아 느려질 수 있다. DP테이블을 잘 채워야 한다. 기타 Lazy - Evaluation ..
https://leetcode.com/problems/add-digits/description/ Add Digits - LeetCode Can you solve this real interview question? Add Digits - Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. Example 1: Input: num = 38 Output: 2 Explanation: The process is 38 --> 3 + 8 --> 11 11 --> leetcode.com 난이도 : Easy 문제 Given an integer num, repeatedly add all i..
https://leetcode.com/problems/roman-to-integer/ Roman to Integer - LeetCode Can you solve this real interview question? Roman to Integer - Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw leetcode.com 난이도 : Easy 문제 Roman numerals are represented by seven d..