분류 전체보기
![[LeetCode] Replace Elements with Greatest Element on Right Side](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcPeG2o%2FbtrCFKtpsNn%2FAAAAAAAAAAAAAAAAAAAAAITdqSLp8mZZ8v9xq3J1hjZEcTaqAvJ7uYPdfmlprCKH%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DHgzKWkf5PNym9V6Ip1qFO7jhb%252BQ%253D)
[LeetCode] Replace Elements with Greatest Element on Right Side
🔍 문제 Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: - index 0 --> the greatest element to the right of index 0 is index 1 (18). - index 1 --> the greatest element to the right of index 1 is in..
![[LeetCode] Valid Mountain Array](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FlxqS0%2FbtrCEdvXVn6%2FAAAAAAAAAAAAAAAAAAAAAIgi7Ku8ciuGpOqzKVpxk8-x92Ft-aY378VzOk7InrMx%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DaH04dsk42nHWnsF0S3r6TY747UA%253D)
[LeetCode] Valid Mountain Array
🔍 문제 Given an array of integers arr, return true if and only if it is a valid mountain array. Recall that arr is a mountain array if and only if: arr.length >= 3 There exists some i with 0 ... > arr[arr.length - 1] Input: arr = [2,1] Output: false Input: arr = [3,5,5] Output: false Input: arr = [0,3,2,1] Output: true 🖥 실행 ..
![[LeetCode] Merge Sorted Array](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FcRBhhr%2FbtrCEopEAtU%2FAAAAAAAAAAAAAAAAAAAAAO6UPJi1rU7OVnw3CPfBCWtb8F_TCNSuT6PqvA8fBTal%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DQobiGzXqDuTvxCpTWHr10jWU35c%253D)
[LeetCode] Merge Sorted Array
🔍 문제 You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a ..
![[LeetCode] Find Numbers with Even Number of Digits](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FxjYDb%2FbtrCDKzId4L%2FAAAAAAAAAAAAAAAAAAAAAEJbVDWQAGCgBnqcddKy27qYn6jrXUwKldZvf-xgWGAb%2Fimg.jpg%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DKhHHPeVq07cxMxagb%252F01NNa%252BPmo%253D)
[LeetCode] Find Numbers with Even Number of Digits
🔍 문제 Given an array nums of integers, return how many of them contain an even number of digits. nums = [12,345,2,6,7896] Output: 2 Explanation: 12 contains 2 digits (even number of digits). 345 contains 3 digits (odd number of digits). 2 contains 1 digit (odd number of digits). 6 contains 1 digit (odd number of digits). 7896 contains 4 digits (even number of digits). Therefore only 12 and 7896 c..
![[while 반복문] 소인수 분해](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FbbKXyK%2FbtrCBMYl0bF%2FAAAAAAAAAAAAAAAAAAAAAEX-z5z-SCSITLAJHCpsKAD8upZ7N1r2736foZuQfp1I%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DNRwNaQjhM1SMeJInU%252FSSiMhteN0%253D)
[while 반복문] 소인수 분해
🔍 문제 - 입력 받은 수를 반복문을 통해 소인수 분해 🖥 실행 inputNum = int(input("수 입력: ")) n = 2 searchNum = [] while n
![[for 반복문] 최소 공배수 구하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2F0P6c2%2FbtrCAqgY6t8%2FAAAAAAAAAAAAAAAAAAAAAMvKXk5RneoLT2gN868NuDMO-N9kmqEM4Bv-R06JwJzD%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DN8273XnZpVG9F7uqhYCftP7b3W0%253D)
[for 반복문] 최소 공배수 구하기
🔍 문제 -어느 음식점의 식료품 배달 주기가 각각 다를 때, 3 가지 물품이 동시에 들어오는 날짜를 계산 과일 = 3일 주기, 생선 = 4일 주기, 야채 = 5일 주기 🖥 실행 fruit = 3 fish = 4 vege = 5 maxNum = 0 for i in range(1, fruit+1): if fruit % i ==0 and fish % i == 0: print('공약수는 {}'.format(i)) maxNum = i print('최대공약수는 {}'.format(maxNum)) minNum = (fruit*fish)//maxNum newNum = minNum for i in range(1, newNum+1): if newNum % i == 0 and vege % i ==0: maxNum = i ..
![[while 반복문] 공약수, 최대 공약수 구하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FPvQHW%2FbtrCyePfMLt%2FAAAAAAAAAAAAAAAAAAAAALMSHPRBGxXOb2_muVCJ6R7CtCDVB-p5YzTyqrXpe45u%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3DTeyFy8s%252Bhc31G6TMWRyBASr8Esw%253D)
[while 반복문] 공약수, 최대 공약수 구하기
🔍 문제 반복문을 이용하여 공약수, 최대 공약수 구하기 🖥 실행 num1 = int(input('0보다 큰 수 입력:')) num2 = int(input('0보다 큰 수 입력:')) temp1 = num1 temp2 = num2 while temp2 > 0: temp = temp2 temp2 = temp1 % temp2 temp1 = temp print('{}와 {}의 최대공약수 : {}'.format(num1,num2,temp1)) for i in range(1, temp1+1): if temp1 % i == 0: print('{}와 {}의 공약수: {}'.format(num1,num2,i)) 📝 결과물 0보다 큰 수 입력:27 0보다 큰 수 입력:90 27와 90의 최대공약수 : 9 27와 90의 공..
![[기초수학] 순열과 조합](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdna%2FciAAlJ%2FbtrCBZwj2OX%2FAAAAAAAAAAAAAAAAAAAAADwQC3qggiuF_w0Z2paT-ogqTK2OTPwfkQrJrVVhCcn0%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1753973999%26allow_ip%3D%26allow_referer%3D%26signature%3Dm7g18UNQxjis9ovq5jMQTF9mnHA%253D)
[기초수학] 순열과 조합
🎯 순열 - n개에서 r개를 택하여 나열하는 경우의 수(순서 상관 있음) $_{n}\mathrm{P}_{r}= \frac{n!}{(n-r)!}$ (단, $0