Python 108

[LeetCode/Python/Java]Array and String - Plus One

문제 Given a non-empty array of digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit. You may assume the integer does not contain any leading zero, except the number 0 itself. 이 문제는 입력된 배열을 한 개의 숫자로 인식하여 1로 더한 후의 값을 배열로 출력해야 합니다. 예를 들어서 입..

[LeetCode/Python/Java]Array and String - Largest Number At Least Twice of Others

문제 In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, otherwise return -1. 배열 안의 최댓값이 다른 모든 값보다 2배 이상일 경우 최댓값의 인덱스를 찾아서 리턴하고 아닐 경우는 -1을 리턴합니다. 예를 들어 배열 A가 [3, 6, 1, 0]일 경우 최댓값 6이 다른 값들보다 2배 이상이기 때문에 1을 리턴합니다. 배열 B가..

[LeetCode/Python/Java]Array and String - Find Pivot Index

문제 Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of all the numbers to the left of the index is equal to the sum of all the numbers to the right of the index. If no such index exists, we should return -1. If there are multiple pivot indexes, you should return the left-most pivot index. 해석해보면 배열 안..

[프로그래머스/python]크레인 인형뽑기 게임

https://programmers.co.kr/learn/courses/30/lessons/64061?language=python3 코딩테스트 연습 - 크레인 인형뽑기 게임 [[0,0,0,0,0],[0,0,1,0,3],[0,2,5,0,1],[4,2,4,4,2],[3,5,1,3,1]] [1,5,3,5,1,2,1,4] 4 programmers.co.kr 이 문제는 크레인(board)에서 moves에 입력된 순서대로 인형을 뽑아서 바구니에 넣습니다. 바구니에 넣을 때 같은 모양의 인형이 2개가 붙어있으면 터트러져 사라집니다. 터트려진 인형의 개수를 출력하는 문제입니다. 입력 : board, moves - board : 2차원 배열로 가로줄씩 크레인 상태를 담은 변수입니다. 배열 안에 0은 빈 공간을 의미하고 ..

[python/11054]가장 긴 바이토닉 부분 수열

https://www.acmicpc.net/problem/11054 11054번: 가장 긴 바이토닉 부분 수열 첫째 줄에 수열 A의 크기 N이 주어지고, 둘째 줄에는 수열 A를 이루고 있는 Ai가 주어진다. (1 ≤ N ≤ 1,000, 1 ≤ Ai ≤ 1,000) www.acmicpc.net 이 문제는 '가장 긴 증가하는 부분 수열' 문제를 응용한 것입니다. https://onlab94.tistory.com/54 [python/11053]가장 긴 증가하는 부분 수열 https://www.acmicpc.net/problem/11053 11053번: 가장 긴 증가하는 부분 수열 수열 A가 주어졌을 때, 가장 긴 증가하는 부분 수열을 구하는 프로그램을 작성하시오. 예를 들어, 수열 A = {10, 20, 10..

알고리즘/백준 2020.05.25

[python]Roman Numerals Encoder

https://www.codewars.com/kata/51b62bf6a9c58071c600001b/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력받은 10진수를 로마 숫자로 출력하는 것입니다. 풀이를 보시려면 더보기를 누르시면 됩니다. 더보기 Roman Numerals Encoder 10진수를 로마 숫자로 바꾸러면 1, 4, 5, 9, 10, 40, 50, 90, 100, 400..

[python]Roman Numerals Decoder

https://www.codewars.com/kata/51b6249c4612257ac0000005/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 로마 숫자를 입력받으면 10진수로 출력해야 하는 문제입니다. 풀이를 보시려면 더보기를 누르시면 됩니다. 더보기 Roman Numerals Decoder 로마 숫자의 경우 현재 글자와 뒤의 글자를 비교하여 현재 글자가 크거나 같으면 해당되는 ..

[python]IP Validation

https://www.codewars.com/kata/515decfd9dcfc23bb6000006/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 입력 문자열이 ip 값이 맞는지 확인하여 맞으면 True, 틀리면 False를 출력하는 문제입니다. 전체 코드를 보시려면 아래의 더보기를 클릭하시면 됩니다. 더보기 IP Validation # My Code def is_valid_IP(st..

[python]RGB To Hex Conversion

https://www.codewars.com/kata/513e08acc600c94f01000001/train/python Codewars: Achieve mastery through challenge Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 RGB 값을 10진수로 입력받아 16진수로 바꾸어서 출력하는 문제입니다. 여기서 주의할 점은 0 이하의 수는 0으로 표기하고 255 이상인 수는 255로 표기하여야 합니다. RGB 값은 음수가 될 수 없으며 255를 초과할 수도 없기 때문입..

[python]Take the Derivative

https://www.codewars.com/kata/5963c18ecb97be020b0000a2/train/python Codewars: Train your coding skills Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential. www.codewars.com 이 문제는 두 값을 입력받을 때 "두 수의 곲x^두 번째 값-1"를 반환하면 됩니다. 전체 코드 # My Code def derive(coefficient, exponent): return str(coefficient * exponent) + "x^" + str(ex..

728x90