LeetCode(52)
-
[LeetCode]Medium - 238. Product of Array Except Self
Medium - 238. Product of Array Except Self https://leetcode.com/problems/product-of-array-except-self/description/ 문제 해석 반복문을 한번만 돌려 나를 제외한 모든 값들의 곱을 구해야 한다. 대신! 나누기 연산을 사용하지 않을 것! 풀이 방법 풀이 접근 과정 인터넷 힌트 참고함. 자신을 기준으로 왼쪽값들의 곱을 구하고 자신을 기준으로 오른쪽값들의 곱을 구해 그 곱을 다시 곱하면 된다. 최종 소스코드 class Solution { fun productExceptSelf(nums: IntArray): IntArray { val answer = IntArray(nums.size) { 1 } for (i in 1 unti..
2024.03.21 -
[LeetCode/Kotlin]442. Find All Duplicates in an Array
LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 해석 배열 안에서 중복된 값만 뽑아내야 한다. 하지만 조건에 O(N)을 사용하라고 하였으므로 반복문은 한번만 돌아야 함. 그리고 추가 공간만 사용해야 한다는 사실을 명심하자 !! 풀이 방법 풀이 접근 과정 반복문을 한 번만 돌기 위해 map을 사용하여 중복된 값을 걸러내고자 하였다. 최종 소스코드 class..
2024.02.14 -
[LeetCode/Kotlin]Medium - 6. Zigzag Conversation
Zigzag Conversion - LeetCode Can you solve this real interview question? Zigzag Conversion - The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I leetcode.com 문제 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: ..
2023.11.02 -
[LeetCode/Kotlin]Medium - 12. Integer to Roman
Integer to Roman - LeetCode Can you solve this real interview question? Integer to Roman - Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw leetcode.com 문제 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. SymbolValue I 1 V..
2023.11.02 -
[LeetCode/Kotlin]Medium - 396. Rotate Function
Rotate Function - LeetCode Can you solve this real interview question? Rotate Function - You are given an integer array nums of length n. Assume arrk to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow: * F(k) = 0 * leetcode.com 문제 You are given an integer array nums of length n. Assume arrk to be an array obtained by rotating n..
2023.10.13 -
[LeetCode/Kotlin]Medium - 2807. Insert Greatest Common Divisors in Linked List
Insert Greatest Common Divisors in Linked List - LeetCode Can you solve this real interview question? Insert Greatest Common Divisors in Linked List - Given the head of a linked list head, in which each node contains an integer value. Between every pair of adjacent nodes, insert a new node with a value equal to t leetcode.com 문제 Given the head of a linked list head, in which each node contains a..
2023.10.13