분류 전체보기
-
리트코드 - 1768. Merge Strings Alternately코딩테스트 2023. 12. 8. 01:39
https://leetcode.com/problems/merge-strings-alternately/description/?envType=study-plan-v2&envId=leetcode-75 Merge Strings Alternately - LeetCode Can you solve this real interview question? Merge Strings Alternately - You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additiona..
-
[python] pop, popleft의 시간복잡도 (list, deuque)TIL 2023. 12. 7. 01:30
https://daelkdev.tistory.com/32 [Python] Del의 시간복잡도 del list[0] 의 시간복잡도는 어떻게 될까? python의 del의 동작방식을 보기 위해 pypy로 코드를 살펴보았다. rpython의 rtype_delitem은 del의 동작방식을 설명하고 있다. def rtype_delitem((r_lst, r_int), hop): if hop.ha daelkdev.tistory.com 해당 글과 이어진다. List - pop def rtype_method_pop(self, hop): if hop.has_implicit_exception(IndexError): spec = dum_checkidx else: spec = dum_nocheck v_func = hop.inp..
-
리트코드 - Reverse Integer코딩테스트 2023. 12. 7. 00:20
https://leetcode.com/problems/reverse-integer/description/ Reverse Integer - LeetCode Can you solve this real interview question? Reverse Integer - Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the envir leetcode.com 32비트 정수 x를 반환받았다고 가정했을 때, 부호는 유지한 상태에서 해당 ..
-
[TIL] 리트코드 - Two Sum 다르게 풀기 : 정렬과 이진 탐색TIL 2023. 12. 5. 01:10
https://daelkdev.tistory.com/29 리트코드 - Two Sum https://leetcode.com/problems/two-sum/description/ Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may as daelkdev.tistory.com 해당 문제를 당시에 딕셔너리를 활용해서 문제를 풀었었다. 시간 복잡도는 입력값인 리스트의 길이만큼 순회하여야 하므로 O(n), 공간..
-
리트코드 - Zigzag Conversion코딩테스트 2023. 12. 4. 23:17
https://leetcode.com/problems/zigzag-conversion/description/ 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 지그재그 문자열이란 numRow가 주어졌을 때, numRow행까지 만..
-
리트코드 - longest-palindromic-substring코딩테스트 2023. 12. 4. 02:03
https://leetcode.com/problems/longest-palindromic-substring/ str: def check(l, r): while(l >= 0 and r len(res): res = odd if len(even) > len(res): res = even return res 시간 복잡도: O(n^2) 문자열의 각 위치에서 팰린드롬을 확인하는 데 O(n) 시간이 소요된다. 문자열의 길이를 n이라 할 때, 모든 중심에서 팰린드롬..
-
리트코드 - Palindrome Number코딩테스트 2023. 12. 4. 01:52
https://leetcode.com/problems/palindrome-number/description/ Palindrome Number - LeetCode Can you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Ex leetcode.com 해당 숫자가 팰린드롬인지 여부를 확인하는 문제이다. 즉 앞뒤가 똑같아야 한..
-
[Python] Del의 시간복잡도개발 공부의 시작/python 2023. 12. 3. 21:09
del list[0] 의 시간복잡도는 어떻게 될까? python의 del의 동작방식을 보기 위해 pypy로 코드를 살펴보았다. rpython의 rtype_delitem은 del의 동작방식을 설명하고 있다. def rtype_delitem((r_lst, r_int), hop): if hop.has_implicit_exception(IndexError): spec = dum_checkidx else: spec = dum_nocheck v_func = hop.inputconst(Void, spec) v_lst, v_index = hop.inputargs(r_lst, Signed) if hop.args_s[1].nonneg: llfn = ll_delitem_nonneg else: llfn = ll_delitem..