μ˜€λΈ”μ™„

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each column must contain the digits 1-9 without repetition.Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition.Note:A Sudoku board (partially filled) could be valid but is not necess..
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.You must write an algorithm that runs in O(n) time.longest consecutive sequenceλ₯Ό μ°ΎλŠ” 문제! O(n) μ•ˆμœΌλ‘œ ν’€μ–΄μ•Ό ν•œλ‹€.μ£Όμ˜ν•  점은 constraints에 nums의 lengthκ°€ 0λΆ€ν„° κ°€λŠ₯ν•˜λ‹€λŠ” 것  Hash Set을 μ΄μš©ν•œ 풀이class Solution: def longestConsecutive(self, nums: List[int]) -> int: numSet = set(nums) longest = 0 f..
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.Given a string s, return true if it is a palindrome, or false otherwise.μœ νš¨ν•œ palindrome(회문) κ²€μ‚¬ν•˜λŠ” λ©”μ„œλ“œ κ΅¬ν˜„ν•˜κΈ°! ν’€μ΄1: Reverse Stringclass Solution: def isPalindrome(self, s:..
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets.Open brackets must be closed in the correct order.Every close bracket has a corresponding open bracket of the same type.κ΄„ν˜Έκ°€ μ˜¬λ°”λ₯΄κ²Œ μ§μ§€μ–΄μ‘ŒλŠ”μ§€ ν™•μΈν•˜λŠ” 문제! ν’€μ΄1: Stack 이용class Solution: def isValid(sel..
μ œλ„€λ¦­(Generic)μ΄λž€?Cλ‚˜ μžλ°” 같은 정적 μ–Έμ–΄μ—μ„œ λ‹€μ–‘ν•œ νƒ€μž… 간에 μž¬μ‚¬μš©μ„±μ„ 높이기 μœ„ν•΄ μ‚¬μš©ν•˜λŠ” 문법이닀. νƒ€μž…μŠ€ν¬λ¦½νŠΈλ„ 정적 νƒ€μž…μ„ κ°€μ§€λ―€λ‘œ μ œλ„€λ¦­ 문법을 μ§€μ›ν•œλ‹€.μ œλ„€λ¦­μ˜ 사전적 μ˜λ―ΈλŠ” 일반적인 것(general)을 λœ»ν•˜λŠ”λ°, νƒ€μž…μŠ€ν¬λ¦½νŠΈμ˜ μ œλ„€λ¦­λ„ 이와 λΉ„μŠ·ν•˜κ²Œ 'μΌλ°˜ν™”λœ 데이터' νƒ€μž…μ΄λΌ λ³Ό 수 μžˆλ‹€.μ œλ„€λ¦­: ν•¨μˆ˜, νƒ€μž…, 클래슀 λ“±μ—μ„œ λ‚΄λΆ€μ μœΌλ‘œ μ‚¬μš©ν•  νƒ€μž…μ„ 미리 정해두지 μ•Šκ³  νƒ€μž… λ³€μˆ˜λ₯Ό μ‚¬μš©ν•΄μ„œ ν•΄λ‹Ή μœ„μΉ˜λ₯Ό λΉ„μ›Œ λ‘” λ‹€μŒμ—, μ‹€μ œλ‘œ κ·Έ 값을 μ‚¬μš©ν•  λ•Œ μ™ΈλΆ€μ—μ„œ νƒ€μž… λ³€μˆ˜ μžλ¦¬μ— νƒ€μž…μ„ μ§€μ •ν•˜μ—¬ μ‚¬μš©ν•˜λŠ” 방식-> μ΄λ ‡κ²Œ ν•˜λ©΄ ν•¨μˆ˜, νƒ€μž…, 클래슀 λ“± μ—¬λŸ¬ νƒ€μž…μ— λŒ€ν•΄ ν•˜λ‚˜ν•˜λ‚˜ λ”°λ‘œ μ •μ˜ν•˜μ§€ μ•Šμ•„λ„ 되기 λ•Œλ¬Έμ— μž¬μ‚¬μš©μ„±μ΄ 크게 ν–₯μƒλœλ‹€.νƒ€μž… λ³€μˆ˜λŠ” 일반적으둜 와 같이 κΊΎμ‡ κ΄„ν˜Έ 내뢀에..
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.λΉˆλ„μˆ˜κ°€ 높은 μˆœμ„œλŒ€λ‘œ, μƒμœ„ k개의 elementsλ₯Ό 좜λ ₯ν•˜λŠ” λ¬Έμ œλ‹€. ν’€μ΄ 1class Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: count = defaultdict(int) for i in nums: count[i] += 1 result = sorted(count, key=count.get, reverse=Tr..
yesolz
'μ˜€λΈ”μ™„' νƒœκ·Έμ˜ κΈ€ λͺ©λ‘