전체 글47 [프로그래머스] - 거리두기 확인하기 w/ Python 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr BFS 탐색과 값을 저장한 countArr을 통해 문제를 해결했다: 1. 모든 곳을 확인한다고 가정했을때 그 타일이 "P"값이라면? 2. 들어가서 주위에 있는 모든 칸 (위, 아래, 옆들)을 확인해서: - 같은 "P"라면 리턴 - "O"라면 countArr에 그 위치에서 + 1 3. 만약 "O"를 찾았는데 그 칸의 위치가 2 이상이라면 거리두기 실패로 False 리턴 4. 만약 다 탐색해서 올바른 자리에 있다면 "True'리턴 dx = [0, 0, -1, 1] dy = [1, -1, 0, 0] def sear.. 2024. 4. 17. [프로그래머스] - 방금그곡 w/ Python 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 재생된 시간, 노래 제목, 기억나는 음, 곡의 진짜음 4개로 푸는 문제 m에서 곡의 진짜 음, musicinfos에서 나머지 정보를 확인할 수 있다 이를 통해 확인해야될건 다음과 같다: 1. 기억나는 음들이랑 실제 음들이 같은지 -> 틀어진 시간 만큼 음을 늘려서 확인한다 2. 맞는 노래가 여러개면 가장 긴 시간을 보유한 노래가 무엇인지 해결한 부분: 1. #을 모두 소문자로 바꿔서 풀이를 했다 2. 들은 음과 실제 음악의 음들이 같다면 시간을 계산해 현재 가장 긴 시간을 비교 3. 맞는 음악이 1개도 없으면.. 2024. 4. 17. [Leetcode 215] - Kth Largest Element in an Array w/ Python Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Can you solve it without sorting? 숫자가 들어가 있는 배열과 정수 k가 주어졌을때 정렬 없이 배열에서 k번째로 큰 숫자를 리턴하는 문제 https://leetcode.com/problems/kth-largest-element-in-an-array/description/ Example 1: Input: nums = [3,2,1,5,6,4], k = 2 Outp.. 2024. 4. 16. [Leetcode 973] - K Closest Points to Origin w/ Python Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0). The distance between two points on the X-Y plane is the Euclidean distance (i.e., √(x1 - x2)2 + (y1 - y2)2). You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in). [x, y]의 좌표가 들어있는 .. 2024. 4. 16. [Leetcode 1046] - Last Stone Weight w/ Python You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x 2024. 4. 16. [Leetcode 703] - Kth Largest Element in a Stream w/ Python Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: 1. KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums. 2. int add(int val) Appends the integer val to the stream and returns the element representing the kth largest .. 2024. 4. 16. [Leetcode 51] - N-Queens w/ Python The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order. Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space, respectively. n x n크기.. 2024. 4. 16. [React 공부] 1-5. 컴포넌트에 Props 전달하기 Passing Props to a Component – React The library for web and native user interfaces react.dev React에서 컴포넌트끼리 정보를 주려면 Props (Properties)를 사용해야 된다 한 단계 위에 상위 컴포넌트 (부모 컴포넌트)는 하위 컴포넌트 (자식 컴포넌트에게) Props를 보낼수 있다 컴포넌트에게 Props 보내는 예시 아래 Avatar한테 Props를 보내기 위해선 두가지가 필요하다 export default function Profile() { return ( ); } 1. 내부에 정보를 작성하기 이런 방법으로 부모 컴포넌트에서 자식 컴포넌트에게 필요한 정보를 보내는 형식이 만들어진다 export default func.. 2024. 4. 15. [Leetcode 17] - Letter Combinations of a Phone Number w/ Python Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. 전화기에 있는 숫자 조합이 주어졌을 경우 2~9의 각 숫자에 알맞은 글자로 만들수 있는 조합을 찾는 문제 https://leetcode.com/problems/letter-combinations-of-a-p.. 2024. 4. 15. 이전 1 2 3 4 ··· 6 다음 반응형