본문 바로가기

분류 전체보기126

[Codility] Lesson 3 : PermMissingElem - JAVA 문제 An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. Your goal is to find that missing element. Write a function: class Solution { public int solution(int[] A); } that, given an array A, returns the value of the missing element. For example, given array A such that: A[0] = 2 A[1] = 3 A[2.. 2022. 6. 1.
[Codility] Lesson 3 : FrogJmp - JAVA 문제 A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. Count the minimal number of jumps that the small frog must perform to reach its target. Write a function: class Solution { public int solution(int X, int Y, int D); } that, given three i.. 2022. 6. 1.
[Codility] Lesson 2 : OddOccurrencesInArray - JAVA 문제 A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For example, in array A such that: A[0] = 9 A[1] = 3 A[2] = 9 A[3] = 3 A[4] = 9 A[5] = 7 A[6] = 9 the elements at indexes 0 and 2 have value 9, the elements a.. 2022. 5. 31.
[Codility] Lesson 2 : CyclicRotation - JAVA 문제 An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7] (elements are shifted right by one index and 6 is moved to the first place). The goal is to rotate array A K times; that is, each eleme.. 2022. 5. 30.
[Codility] Lesson 1 - JAVA 문제 A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binar.. 2022. 5. 29.
[Python] 문자열 포매팅 1번 고객님 주문하신 햄버거 나왔습니다. 21번 고객님 주문하신 피자 나왔습니다. ... 201번 고객님 주문하신 아메리카노 나왔습니다. 식당에서 주문한 음식이 나왔을 때 이런 소리를 많이 들어봤죠? 문장을 보면 **대기 번호**와 **주문한 음식**만 다른 것을 알 수 있어요! 프로그래밍을 통해서 똑같이 만들 수 있는데요. 대기 번호와 주문한 음식을 변수로 받아서 문장을 작성하면 되요. 그럼 어떻게 작성하는지 알아볼까요? 가장 먼저 포매팅을 사용하지 않고 문장을 만들어 볼게요. wating_number = 1 food = '햄버거' print(str(wating_number) + '번 고객님 주문하신 ' + food + ' 나왔습니다.') >> (출력) 1번 고객님 주문하신 햄버거 나왔습니다. 출력문을.. 2022. 5. 23.