์ „์ฒด ๊ธ€ 88

[LeetCode] 234. Palindrome_Linked_list (Easy) 2023/5/4

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 234. Palindrome-Linked-list 50.3% Easy Palindrome Linked List - LeetCode Can you solve this real interview question? Palindrome Linked List - Given the head of a singly linked list, return true if it is a palindrome or false otherwise. Example 1: [https://assets.leetcode.com/uploads/2021/03/03/pal1linked-list.jpg] Input: hea leetcode.com ๋ฌธ์ œ์š”์•ฝ ๋‹จ์ผ ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๊ฐ€ ํŒฐ๋ฆฐ๋“œ๋กฌ์ธ์ง€ ํŒ๋‹จํ•˜์—ฌ๋ผ ์กฐ๊ฑด 1) ๋‹จ์ผ ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ์˜..

[LeetCode] 121. Best_Time_to_Buy_and_Sell_Stock (Easy) 2023/5/3

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 121. Best-Time-to-Buy-and-Sell-Stock 54.3% Easy Best Time to Buy and Sell Stock - LeetCode Can you solve this real interview question? Best Time to Buy and Sell Stock - You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosin leetcode.com ๋ฌธ์ œ์š”์•ฝ ์ฃผ์‹ ๊ฑฐ๋ž˜๋ฅผ ํ†ตํ•ด ์ด์ต์˜ ์ตœ๋Œ“๊ฐ’์„..

[LeetCode] 238. product_of_array_except_self (Medium) 2023/5/2

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 238. product-of-array-except-self 65.1% Medium Product of Array Except Self - LeetCode Can you solve this real interview question? Product of Array Except Self - Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nu leetcode.com ๋ฌธ์ œ์š”์•ฝ ๋ฐฐ์—ด์˜ ์š”์†Œ ์ค‘ ์ž์‹ ์„ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€์˜ ..

[LeetCode] 561. array_partition_i (Easy) 2023/5/2

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 561. array-partition-i 77.3% Easy Array Partition - LeetCode Can you solve this real interview question? Array Partition - Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Return the maximized sum. leetcode.com ๋ฌธ์ œ์š”์•ฝ 2n ๊ฐœ์˜ ์ •์ˆ˜ํ˜• ๋ฐฐ์—ด์ด ์ฃผ์–ด์งˆ ๋•Œ, ์ž„์˜์˜ ๋‘ ์›์†Œ๋กœ ๊ตฌ์„ฑ๋œ n๊ฐœ์˜ ์Œ์ด ์žˆ๋‹ค๊ณ  ํ•˜์ž..

[LeetCode] 15. 3sum (Medium) 2023/5/1

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 15. 3sum 32.6% Medium 3Sum - LeetCode Can you solve this real interview question? 3Sum - Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain du leetcode.com ๋ฌธ์ œ์š”์•ฝ ์ •์ˆ˜ํ˜• ๋ฐฐ์—ด์ด ์ฃผ์–ด์ง€๋ฉด ํ•ฉ์ด 0์ด ๋˜๋Š” 3๊ฐœ์˜ ์ˆซ์ž์Œ์„ ๋ชจ๋‘ ๋ฐ˜ํ™˜ํ•˜์—ฌ๋ผ ์กฐ๊ฑด 1) ์›์†Œ๊ฐ€ 3๊ฐœ ์ด์ƒ 1000๊ฐœ ์ดํ•˜์ธ ์ •์ˆ˜ํ˜• ๋ฐฐ..

[python] 2. ์ฝ”๋”ฉํ…Œ์ŠคํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” Python ๊ธฐ๋ณธ

์ฝ”๋”ฉํ…Œ์ŠคํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” Python ๊ธฐ๋ณธ ๐ŸŽต์ธ๋ดํŠธ ๊ณต๋ฐฑ 4์นธ์ด ์›์น™ ๐ŸŽต๋„ค์ด๋ฐ ์›์น™ Snake Case์„ ์ง€ํ–ฅ - ์†Œ๋ฌธ์ž + ๋‹จ์–ด๋ฅผ ๋ฐ‘์ค„(_)๋กœ ๊ตฌ๋ถ„ ๐ŸŽต๋žŒ๋‹ค ํ‘œํ˜„์‹ lambda ๋งค๊ฐœ๋ณ€์ˆ˜: ํ‘œํ˜„์‹์˜ ํ˜•ํƒœ๋กœ ์‚ฌ์šฉ๋˜๋ฉฐ, ์ฃผ๋กœ map ํ•จ์ˆ˜์™€ ํ•จ๊ป˜ ์‚ฌ์šฉ๋จ map(lambda ๋งค๊ฐœ๋ณ€์ˆ˜: ํ‘œํ˜„์‹, input๊ฐ’) ๐ŸŽตList Comprehension : ๊ธฐ์กด ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ƒˆ๋กœ์šด ๋ฆฌ์ŠคํŠธ๋ฅผ ๋งŒ๋“ค์–ด๋‚ด๋Š” ๋ฌธ์žฅ(๋ฒ„์ „ 2.7 ์ดํ›„ ๋”•์…”๋„ˆ๋ฆฌ๋„ ๊ฐ€๋Šฅ) ๋ฌธ๋ฒ•๊ณผ ์˜๋ฏธ๋ฅผ ์ถ•์•ฝํ•˜์—ฌ ๋‚˜ํƒ€๋‚ด๊ธฐ ๋•Œ๋ฌธ์— ๋งค์šฐ ๊ฐ•๋ ฅํ•˜์ง€๋งŒ, ๊ฐ€๋…์„ฑ์„ ๋–จ์–ด๋œจ๋ฆฌ๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค. ์˜ˆ์ œ) 100 ์ดํ•˜ ์ง์ˆ˜์— 100์„ ๊ณฑํ•˜์—ฌ๋ผ [n*100 for n in range(1, 100+1) if n%2==0] ๐ŸŽตGenerator : ๋ฐ˜๋ณต๋ฌธ์˜ ๋™์ž‘์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋Š” ๋ฃจํ‹ด ํ˜•ํƒœ ๋ฉ”๋ชจ..

[LeetCode] 1. two_sum (Easy) 2023/4/29

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 1. two-sum 49.8% Easy 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 assume that each input would have exactly one solution, and you may not leetcode.com ๋ฌธ์ œ์š”์•ฝ ํƒ€๊นƒ ์ˆซ์ž๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ ๋ฐฐ์—ด ์›์†Œ์˜ ํ•ฉ์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋‹ค๋ฉด ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ด๋ผ ์กฐ๊ฑด 1) ์ •์ˆ˜ํ˜• ํƒ€๊นƒ ์ˆซ์ž์™€ ์ •์ˆ˜ํ˜• ๋ฐฐ์—ด์ด..

[LeetCode] 5. longest_palindromic_substring (Medium) 2023/4/28

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 5. longest-palindromic-substring 32.4% Medium ํ•ด๋‹น ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๊ฐ€ 1์ผ ๊ฒฝ์šฐ -> ํ•ด๋‹น ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜ ๋ฌธ์ž์—ด ์ž์ฒด๊ฐ€ ํŒฐ๋ฆฐ๋“œ๋กฌ ์ผ ๊ฒฝ์šฐ -> ํ•ด๋‹น ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜ Step1. ์ œ์ผ ๊ธด ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ์„ธ๋Š” ๋ฌธ์ œ์ด๋ฏ€๋กœ ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ถ€ํ„ฐ ์ฐจ๋ก€๋Œ€๋กœ ๊ณ„์‚ฐ ๊ตฌํ˜„ (4406 ms) class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ #Step 0 if len(s)=2): for left_index in range(0, len(s)-nowlen+1): nowstr=s[left_index:left_index+nowlen] if(nowstr..

[LeetCode] 49. group-anagrams (Medium) 2023/4/28

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 49. group-anagrams 66.8% Medium Group Anagrams - LeetCode Can you solve this real interview question? Group Anagrams - Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase leetcode.com ๋ฌธ์ œ์š”์•ฝ ๋ฌธ์ž์—ด ๋ฐฐ์—ด์„ ์• ๋„ˆ๊ทธ๋žจ ๊ธฐ์ค€์œผ๋กœ ๋ฌถ์–ด๋ผ ์กฐ๊ฑด 1) ๋ฌธ์ž์—ด ๋ฐฐ์—ด์ด ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง„๋‹ค ์กฐ๊ฑด 2)..

[LeetCode] 937. reorder-data-in-log-files (Easy) 2023/4/27

๋ฌธ์ œ ์ œ๋ชฉ ์ •๋‹ต๋ฅ  ๋‚œ์ด๋„ 937. reorder-data-in-log-files 56.4% Easy Reorder Data in Log Files - LeetCode Can you solve this real interview question? Reorder Data in Log Files - You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: * Letter-logs: All words (except the leetcode.com ๋ฌธ์ œ ์š”์•ฝ. ๋กœ๊ทธ ํŒŒ์ผ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์žฌ์ •๋ ฌํ•ด๋ผ. ์กฐ๊ฑด 1) ๋กœ๊ทธ ..

728x90