Problem Solving
-
100. Range Sum of BSTProblem Solving 2023. 1. 19. 20:28
https://leetcode.com/problems/range-sum-of-bst/description/ Range Sum of BST - LeetCode Range Sum of BST - Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high]. Example 1: [https://assets.leetcode.com/uploads/2020/11/05/bst1.jpg] Inp leetcode.com Binary Search Tree를 훑으며 범위 내의 수들을 모두 더하는 문제..
-
99. Transpose MatrixProblem Solving 2023. 1. 19. 17:58
https://leetcode.com/problems/transpose-matrix/description/ Transpose Matrix - LeetCode Transpose Matrix - Given a 2D integer array matrix, return the transpose of matrix. The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices. [https://assets.leetcode.com/uploads/2021/02/10/hint_ leetcode.com matrix를 transpose 하는 문제 class Solution: ..
-
98. 수 뒤집기Problem Solving 2023. 1. 19. 06:21
https://www.acmicpc.net/problem/3062 3062번: 수 뒤집기 수 124를 뒤집으면 421이 되고 이 두 수를 합하면 545가 된다. 124와 같이 원래 수와 뒤집은 수를 합한 수가 좌우 대칭이 되는지 테스트 하는 프로그램을 작성하시오. www.acmicpc.net 입력받은 수를 뒤집어 원래 수와 뒤집은 수의 합이 좌우 대칭인지 확인하는 문제 n = int(input()) for i in range(n): numb = str(input()) revnumb = numb[::-1] sum = int(numb) + int(revnumb) length = len(str(sum)) for j in range(int(length/2)): if str(sum)[j] != str(sum)[l..
-
97. Remove Duplicates from Sorted ArrayProblem Solving 2023. 1. 19. 06:07
https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/ Remove Duplicates from Sorted Array - LeetCode Remove Duplicates from Sorted Array - Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place [https://en.wikipedia.org/wiki/In-place_algorithm] such that each unique element appears only once. The relative order of the e leetcode.com ar..
-
96. Remove ElementProblem Solving 2023. 1. 19. 05:58
https://leetcode.com/problems/remove-element/description/ Remove Element - LeetCode Remove Element - Given an integer array nums and an integer val, remove all occurrences of val in nums in-place [https://en.wikipedia.org/wiki/In-place_algorithm]. The relative order of the elements may be changed. Since it is impossible to change the leng leetcode.com list에서 val과 동일한 값을 지우는 문제 class Solution: de..
-
95. Sort Array By Parity IIProblem Solving 2023. 1. 19. 05:44
https://leetcode.com/problems/sort-array-by-parity-ii/description/ Sort Array By Parity II - LeetCode Sort Array By Parity II - Given an array of integers nums, half of the integers in nums are odd, and the other half are even. Sort the array so that whenever nums[i] is odd, i is odd, and whenever nums[i] is even, i is even. Return any answer array that sa leetcode.com 배열을 입력받고, index가 짝수일 때는 짝수..
-
94. Merge Sorted ArrayProblem Solving 2023. 1. 19. 05:35
https://leetcode.com/problems/merge-sorted-array/description/ Merge Sorted Array - 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-de leetcode.com 두 개의 array를 합치는 문제, array nums1을 수정하..
-
93. 크로아티아 알파벳Problem Solving 2023. 1. 19. 05:27
https://www.acmicpc.net/problem/2941 2941번: 크로아티아 알파벳 예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z= www.acmicpc.net string replace 문제 string = input() if 'c=' in string: string = string.replace('c=', 'c') if 'c-' in string: string = string.replace('c-', 'c') if 'dz=' in string: string = string.replace('dz=', 'd') if ..