본문 바로가기
반응형

Problem Solving4

<Solution> 17.Letter Combinations of a Phone Number 17.Letter Combinations of a Phone Number 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. Example 1: Input: digits = "23" Output: ["ad","ae","af","bd","be","bf","cd.. 2022. 9. 17.
BOJ 12851 - 숨바꼭질 2 https://www.acmicpc.net/problem/12851 12851번: 숨바꼭질 2 수빈이는 동생과 숨바꼭질을 하고 있다. 수빈이는 현재 점 N(0 ≤ N ≤ 100,000)에 있고, 동생은 점 K(0 ≤ K ≤ 100,000)에 있다. 수빈이는 걷거나 순간이동을 할 수 있다. 만약, 수빈이의 위치가 X일 때 www.acmicpc.net 문제 설명 숨바꼭질 2 문제 수빈이는 동생과 숨바꼭질을 하고 있다. 수빈이는 현재 점 N(0 ≤ N ≤ 100,000)에 있고, 동생은 점 K(0 ≤ K ≤ 100,000)에 있다. 수빈이는 걷거나 순간이동을 할 수 있다. 만약, 수빈이의 위치가 X일 때 걷는다면 1초 후에 X-1 또는 X+1로 이동하게 된다. 순간이동을 하는 경우에는 1초 후에 2*X의 위치.. 2021. 10. 31.
[LeetCode.412][easy] Fizz Buzz https://leetcode.com/problems/fizz-buzz/ Fizz Buzz - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 접근 방법 1부터 n까지에 대해 3과5의 공배수인지, 3의 배수인지, 5의 배수인지 체크한다. O(n)의 시간복잡도를 차지하는 알고리즘으로 풀었다. 풀이 코드 class Solution { public: vector fizzBuzz(int n) { vector ans; for(int i=1;i 2021. 10. 30.
[LeetCode.454][middle] 4Sum II https://leetcode.com/problems/4sum-ii/ 4Sum II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 초기 접근 방법 일단 브루트포스 알고리즘으로 접근했다. 모든 경우의 수를 4중 for loop 돌려서 전체를 탐색했다. 테스트케이스는 통과했지만, 시간초과 에러로 실패했다. 초기 코드 class Solution { public: int fourSumCount(vector& nums1, vector& nums2, vector& nu.. 2021. 10. 28.
반응형