본문 바로가기

분류 전체보기1534

leetcode 1523. Count Odd Numbers in an Interval Range https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/description/ Count Odd Numbers in an Interval Range - LeetCode Can you solve this real interview question? Count Odd Numbers in an Interval Range - Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). Example 1: Input: low = 3, high = 7 Output: 3 Explanati leetcode.com .. 2023. 2. 13.
leetcode 234. Palindrome Linked List https://leetcode.com/problems/palindrome-linked-list/ Palindrome Linked List - LeetCode 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: head = [1,2,2,1] Output: true Example 2: [https leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1.. 2023. 2. 11.
leetcode 121. Best Time to Buy and Sell Stock https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - LeetCode 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 choosing a different day in the future to sell that leetcode.com 1 2 3 4 5 6 7 8 9 10 c.. 2023. 2. 11.
leetcode 2149. Rearrange Array Elements by Sign https://leetcode.com/problems/rearrange-array-elements-by-sign/description/ Rearrange Array Elements by Sign - LeetCode Can you solve this real interview question? Rearrange Array Elements by Sign - You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers. You should rearrange the elements of nums such that leetcode.com 1 2 3 4 5.. 2023. 2. 10.
leetcode 238. Product of Array Except Self https://leetcode.com/problems/product-of-array-except-self/description/ Product of Array Except Self - LeetCode 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 nums is guaranteed to fit in a 32-bit integer. leetcode.com 1 2 3 4 5 6 7 8 .. 2023. 2. 10.
leetcode 15. 3Sum https://leetcode.com/problems/3sum/description/ 3Sum - LeetCode 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 duplicate triplets. Example 1: Input: nums leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26.. 2023. 2. 9.
leetcode 42. Trapping Rain Water https://leetcode.com/problems/trapping-rain-water/description/ Trapping Rain Water - LeetCode Trapping Rain Water - Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: [https://assets.leetcode.com/uploads/2018/10/22/rainwatertrap.png] Input: he leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1.. 2023. 2. 9.
백준 27389 Metronome https://www.acmicpc.net/problem/27389 27389번: Metronome A Metronome is a mechanical device used by musicians for keeping time. It is a very clever device, based on a spring, an inverted pendulum, and an escapement gear. Milo is learning to play the glockenspiel, and has purchased a metronome to help him keep ti www.acmicpc.net 1 2 3 4 5 6 7 8 def sol(n): answer = round(n/4, 2) return answer if _.. 2023. 2. 9.
백준 27434 팩토리얼 3 https://www.acmicpc.net/problem/27434 27434번: 팩토리얼 3 0보다 크거나 같은 정수 N이 주어진다. 이때, N!을 출력하는 프로그램을 작성하시오. www.acmicpc.net 1 2 3 4 5 6 from math import factorial if __name__ == '__main__': n = int(input()) print(factorial(n)) cs 2023. 2. 9.
백준 27433 팩토리얼 2 https://www.acmicpc.net/problem/27433 27433번: 팩토리얼 2 0보다 크거나 같은 정수 N이 주어진다. 이때, N!을 출력하는 프로그램을 작성하시오. www.acmicpc.net 1 2 3 4 5 6 from math import factorial if __name__ == '__main__': n = int(input()) print(factorial(n)) cs 2023. 2. 9.
leetcode 5. Longest Palindromic Substring https://leetcode.com/problems/longest-palindromic-substring/description/ Longest Palindromic Substring - LeetCode Longest Palindromic Substring - Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Constraints: * 1 str: def expand(left: int, right: int) ->.. 2023. 2. 8.
백준 25630 팰린드롬 소떡소떡 https://www.acmicpc.net/problem/25630 25630번: 팰린드롬 소떡소떡 소떡소떡은 기다란 꼬치에 소세지와 떡을 끼운 음식이다. 편의상 소떡소떡을 알파벳 s와 t로만 구성된 길이 $N$의 문자열로 생각하자. 알파벳 s는 소세지를, t는 떡을 의미한다. 위 그림은 길이가 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def sol(n, s): answer = 0 if n % 2 == 0: left, right = s[:n // 2], s[n // 2:][::-1] else: left, right = s[:n // 2], s[n // 2 + 1:][::-1] for i in range(n // 2): if left[i] !=.. 2023. 2. 8.