본문 바로가기

coding test96

[LEET CODE] 3. Longest Substring Without Repeating Characters # Problem Given a string s, find the length of the longest substring without repeating characters. Constraints: 0 2021. 4. 5.
[LEET CODE] 771. Jewels and Stones # Problem You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so "a" is considered a different type of stone from "A". Constraints: 1 int: freqs = {} count = 0 # 돌(S)의 빈도 수 계산 for.. 2021. 4. 5.
[LEET CODE] 739. Daily Temperatures # Problem Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list of temperatures T = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0]. Note: The length of temp.. 2021. 3. 29.
[LEET CODE] 20. Valid Parentheses # Problem 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. Constraints: 1 bool: stack = [] table = { ')': '(', '}': '{', ']': '[', } # 스택 이용 예외 처리 및 일치 여부 판별 for char in s: if char not in.. 2021. 3. 23.
[LEET CODE] 92. Reverse Linked List II # Problem Given the head of a singly linked list and two integers left and right where left 2021. 3. 23.
[LEET CODE] 24. Swap Nodes in Pairs # Problem Given a linked list, swap every two adjacent nodes and return its head. Constraints: The number of nodes in the list is in the range [0, 100]. 0 ListNode: cur = head while cur and cur.next: # 값만 교환 cur.val, cur.next.val = cur.next.val, cur.val cur = cur.next.next return head # Solution 2 - 반복 구조로 스왑 # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = .. 2021. 3. 23.
반응형