본문 바로가기

전체 글369

[LeetCode] 282. Expression Add Operators 문제 URL : https://leetcode.com/problems/expression-add-operators/ Expression Add Operators - LeetCode Can you solve this real interview question? Expression Add Operators - Given a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' between the digits of num so that the re leetcode.com 문제 접근법: 숫자와 숫자 사이에 연산자를 집어 .. 2023. 10. 14.
[LeetCode] 329. Longest Increasing Path in a Matrix 문제 URL :https://leetcode.com/problems/longest-increasing-path-in-a-matrix/ Longest Increasing Path in a Matrix - LeetCode Can you solve this real interview question? Longest Increasing Path in a Matrix - Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or down. leetcode.com 접근법: 2차.. 2023. 10. 14.
순열(permutation) & 조합(combination) 알고리즘 되도록 심플하게 글을 작성하려합니다. 순열 : 서로 다른 n개의 원소에서 r개를 중복없이 순서에 상관있게 선택하는 혹은 나열하는 것을 순열(permutation)이라고 한다 permutation 알고리즘은 c++ 에선 여러가지 방법중 2가지를 알려드리려합니다. 하나는 재귀함수(backtracking)을이용한 직접 구현과, 라이브러리를 이용한 next_permutation을 이용 재귀함수를 이용한 소스코드 : #include using namespace std; vector p, check; int n; void backtrack(int h = 0) { if (h >= n) { for (int i : p) cout 2023. 9. 12.
프로그래머스 리코쳇 로봇 문제 URL : https://school.programmers.co.kr/learn/courses/30/lessons/169199 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 접근법: bfs문제입니다. 난이도는 쉬우니 딱히 크게 얘기는 하지 않겠고 이동할때 벽을부딪힐때까지만 이동해서 G를 이동만하면되는 문제입니다. 소스코드 : #include using namespace std; int n,m; int dy[4]={-1,0,1,0}; int dx[4]={0,1,0,-1}; bool isrange(int y,int x){ return 0 2023. 9. 12.