코딩 테스트를 준비하면서 알고리즘을 체계적으로 풀기위해 도서 알고리즘 문제해결전략로 공부하면서 작성합니다.문제를 읽고 이해한다문제를 익숙한 용어로 재정의 한다.어떻게 해결할지 계획을 세운다.계획을 검증한다.프로그램으로 구현한다.어떻게 풀었는지 돌아보고, 개선할 방법이
스파이들은 매일 다른 옷을 조합하여 입어 자신을 위장합니다.예를 들어 스파이가 가진 옷이 아래와 같고 오늘 스파이가 동그란 안경, 긴 코트, 파란색 티셔츠를 입었다면 다음날은 청바지를 추가로 입거나 동그란 안경 대신 검정 선글라스를 착용하거나 해야 합니다.스파이가 가진
Write a function that reverses a string. The input string is given as an array of characters char\[].Do not allocate extra space for another array, yo
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number
어떤 문장의 각 알파벳을 일정한 거리만큼 밀어서 다른 알파벳으로 바꾸는 암호화 방식을 시저 암호라고 합니다. 예를 들어 AB는 1만큼 밀면 BC가 되고, 3만큼 밀면 DE가 됩니다. z는 1만큼 밀면 a가 됩니다. 문자열 s와 거리 n을 입력받아 s를 n만큼 민 암호문
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is d
n개의 음이 아닌 정수가 있습니다. 이 수를 적절히 더하거나 빼서 타겟 넘버를 만들려고 합니다. 예를 들어 1, 1, 1, 1, 1로 숫자 3을 만들려면 다음 다섯 방법을 쓸 수 있습니다.사용할 수 있는 숫자가 담긴 배열 numbers, 타겟 넘버 target이 매개변
Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the posi
You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).You have to rotate the image in-place, which means
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.Note:1\. You must
두 수를 입력받아 두 수의 최대공약수와 최소공배수를 반환하는 함수, solution을 완성해 보세요. 배열의 맨 앞에 최대공약수, 그다음 최소공배수를 넣어 반환하면 됩니다. 예를 들어 두 수 3, 12의 최대공약수는 3, 최소공배수는 12이므로 solution(3, 1
Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.Ex
Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Retu
양의 정수 x가 하샤드 수이려면 x의 자릿수의 합으로 x가 나누어져야 합니다. 예를 들어 18의 자릿수 합은 1+8=9이고, 18은 9로 나누어 떨어지므로 18은 하샤드 수입니다. 자연수 x를 입력받아 x가 하샤드 수인지 아닌지 검사하는 함수, solution을 완성해
천천히... leetcode most interview 어쩌구 뽀개기 시작
Given an array, rotate the array to the right by k steps, where k is non-negative.입출력 예Input: nums = 1,2,3,4,5,6,7, k = 3Output: 5,6,7,1,2,3,4Explanat
Given an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the arra
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.Follow up: Could you implement a solution w
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each inpu
Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.The digits are stored such that the most s
Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1.입출력 예s = "leetcode"return 0.s = "lov
Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whites
Given a 32-bit signed integer, reverse digits of an integer.Note:Assume we are dealing with an environment that could only store integers within the 3
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Clarification:What should w
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we
문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 sun, bed, car이고 n이 1이면 각 단어의 인덱스 1의 문자 u, e, a로 strings를 정렬
점심시간에 도둑이 들어, 일부 학생이 체육복을 도난당했습니다. 다행히 여벌 체육복이 있는 학생이 이들에게 체육복을 빌려주려 합니다. 학생들의 번호는 체격 순으로 매겨져 있어, 바로 앞번호의 학생이나 바로 뒷번호의 학생에게만 체육복을 빌려줄 수 있습니다. 예를 들어, 4
정수 배열 numbers가 주어집니다. numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아 return 하도록 solution 함수를 완성해주세요.입출력 예numbers: 2,1,3,4,1result:
1,2,3은 반복되는 패턴이 있음. answer의 length만큼 배열을 만들어준다.answer와 1,2,3번을 비교하는 방법 -> 각 인덱스끼리 같으면 count++;1,2,3순서대로 조사2,2,1이 됐다면 Math.max후 이 수와 같은 값을 가진 인덱스+1을 an
Programmers | 크레인 인형뽑기 게임게임개발자인 죠르디는 크레인 인형뽑기 기계를 모바일 게임으로 만들려고 합니다.죠르디는 게임의 재미를 높이기 위해 화면 구성과 규칙을 다음과 같이 게임 로직에 반영하려고 합니다.게임 화면은 1 x 1 크기의 칸들로 이루어진 N
Given the root of a binary tree, return its maximum depth.A binary tree's maximum depth is the number of nodes along the longest path from the root no
일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린터를 개발했습니다. 이 새롭게 개발한 프린터는 아래와 같은 방식으로 인쇄 작업을 수행합
프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다.또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 기능보다 먼저 개발될 수 있고, 이때 뒤에 있는 기능은 앞에 있는 기능이 배포
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo
수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다.마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의
\[Programmers] 같은 숫자는 싫어배열 arr가 주어집니다. 배열 arr의 각 원소는 숫자 0부터 9까지로 이루어져 있습니다. 이때, 배열 arr에서 연속적으로 나타나는 숫자는 하나만 남기고 전부 제거하려고 합니다. 단, 제거된 후 남은 수들을 반환할 때는 배
두 정수 a, b가 주어졌을 때 a와 b 사이에 속한 모든 정수의 합을 리턴하는 함수, solution을 완성하세요.예를 들어 a = 3, b = 5인 경우, 3 + 4 + 5 = 12이므로 12를 리턴합니다.제한 조건a와 b가 같은 경우는 둘 중 아무 수나 리턴하세요
\[프로그래머스 스킬트리](https://programmers.co.kr/learn/courses/30/lessons/49993>선행 스킬이란 어떤 스킬을 배우기 전에 먼저 배워야 하는 스킬을 뜻합니다.예를 들어 선행 스킬 순서가 스파크 → 라이트닝 볼트 →
0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요.예를 들어, 주어진 정수가 6, 10, 2라면 6102, 6210, 1062, 1026, 2610, 2106를 만들 수 있고, 이중 가장 큰 수는 6210입니다.0 또는 양
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".입출력 예Inp
프로그래머스 | 제일 작은 수 제거하기정수를 저장한 배열, arr 에서 가장 작은 수를 제거한 배열을 리턴하는 함수, solution을 완성해주세요. 단, 리턴하려는 배열이 빈 배열인 경우엔 배열에 -1을 채워 리턴하세요. 예를들어 arr이 4,3,2,1인 경우는 4,
Given the head of a singly linked list, reverse the list, and return the reversed list.입출력 예Input: head = 1,2,3,4,5Output: 5,4,3,2,1입력으로 들어오는 head의 ne
Given an integer x, return true if x is palindrome integer.An integer is a palindrome when it reads the same backward as forward. For example, 121 is
프로그래머스 | 카펫Leo는 카펫을 사러 갔다가 아래 그림과 같이 중앙에는 노란색으로 칠해져 있고 테두리 1줄은 갈색으로 칠해져 있는 격자 모양 카펫을 봤습니다.Leo는 집으로 돌아와서 아까 본 카펫의 노란색과 갈색으로 색칠된 격자의 개수는 기억했지만, 전체 카펫의 크
스트리밍 사이트에서 장르 별로 가장 많이 재생된 노래를 두 개씩 모아 베스트 앨범을 출시하려 합니다. 노래는 고유 번호로 구분하며, 노래를 수록하는 기준은 다음과 같습니다.속한 노래가 많이 재생된 장르를 먼저 수록합니다.장르 내에서 많이 재생된 노래를 먼저 수록합니다.
트럭 여러 대가 강을 가로지르는 일 차선 다리를 정해진 순으로 건너려 합니다. 모든 트럭이 다리를 건너려면 최소 몇 초가 걸리는지 알아내야 합니다. 트럭은 1초에 1만큼 움직이며, 다리 길이는 bridge_length이고 다리는 무게 weight까지 견딥니다.※ 트럭이
어떤 숫자에서 k개의 수를 제거했을 때 얻을 수 있는 가장 큰 숫자를 구하려 합니다.예를 들어, 숫자 1924에서 수 두 개를 제거하면 19, 12, 14, 92, 94, 24 를 만들 수 있습니다. 이 중 가장 큰 숫자는 94 입니다.문자열 형식으로 숫자 number
LeetCode | Valid ParenthesesGiven a string s containing just the characters '(', ')', '{', '}', '' and '', determine if the input string is valid.An i