본문 바로가기

전체 글1534

leetcode 739. Daily Temperatures https://leetcode.com/problems/daily-temperatures/description/ Daily Temperatures - LeetCode Can you solve this real interview question? Daily Temperatures - Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer leetcode.com 1 2 3 4 5 6 7 8 9 10 11 class Solutio.. 2023. 2. 23.
leetcode 316. Remove Duplicate Letters https://leetcode.com/problems/remove-duplicate-letters/description/ Remove Duplicate Letters - LeetCode Can you solve this real interview question? Remove Duplicate Letters - Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible re leetcode.com 1 2 3 4 5 6 7 8 9 10 11 .. 2023. 2. 23.
leetcode 20. Valid Parentheses https://leetcode.com/problems/valid-parentheses/description/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 cl.. 2023. 2. 23.
백준 9773 ID Key https://www.acmicpc.net/problem/9773 9773번: ID Key บรรทัดแรกคือค่า N (1 ≤ N ≤ 100) ระบุจํานวนคน และ N บรรทัดต่อมา แต่ละบรรทัดคือเลขประจําตัวประชาชน 13 ห www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 def sol(s) -> int: first, last_three_number = 0, 0 for i in s: first += int(i) last_three_number = int(s[-3] + s[-2] + s[-1]) * 10 answer = first + last_three_number if first + answer 2023. 2. 21.
leetcode 92. Reverse Linked List II https://leetcode.com/problems/reverse-linked-list-ii/description/ Reverse Linked List II - LeetCode Can you solve this real interview question? Reverse Linked List II - Given the head of a singly linked list and two integers left and right where left ListNode: if not head or not head.next or left == right: return head # left-1 노드를 찾습니다. dummy = ListNode(-1) dummy.next = head prev = dummy for i i.. 2023. 2. 17.
leetcode 328. Odd Even Linked List https://leetcode.com/problems/odd-even-linked-list/description/ Odd Even Linked List - LeetCode Odd Even Linked List - Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. N leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14.. 2023. 2. 17.
leetcode 24. Swap Nodes in Pairs https://leetcode.com/problems/swap-nodes-in-pairs/description/ Swap Nodes in Pairs - LeetCode Swap Nodes in Pairs - Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) Example 1: [https://assets.leetcode leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # Defi.. 2023. 2. 17.
leetcode 2. Add Two Numbers https://leetcode.com/problems/add-two-numbers/description/ Add Two Numbers - LeetCode Add Two Numbers - You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may as leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1.. 2023. 2. 17.
leetcode 206. Reverse Linked List https://leetcode.com/problems/reverse-linked-list/ Reverse Linked List - LeetCode Reverse Linked List - Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: [https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg] Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: [https://asset leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # Definition for.. 2023. 2. 17.
백준 9772 Quadrants https://www.acmicpc.net/problem/9772 9772번: Quadrants Given the coordinates (x,y) of some points in 2-dimensional plane, find out which quadrant(Q1-Q4) the points are located. If a point is located on X-axis or Y-axis, print out AXIS instead. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def sol(x, y): if x == 0 or y == 0: return 'AXIS' elif x > 0 and y > 0: return 'Q1' elif.. 2023. 2. 17.
leetcode 989. Add to Array-Form of Integer https://leetcode.com/problems/add-to-array-form-of-integer/description/ Add to Array-Form of Integer - LeetCode Add to Array-Form of Integer - The array-form of an integer num is an array representing its digits in left to right order. * For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form of an integer, and an integer k, return the ar leetcode.com 1 2 3 4 5 6 7 8 .. 2023. 2. 15.
leetcode 21. Merge Two Sorted Lists https://leetcode.com/problems/merge-two-sorted-lists/ Merge Two Sorted Lists - LeetCode Merge Two Sorted Lists - You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 # Definition .. 2023. 2. 13.