- Today
- Total
목록leetcode (186)
작심삼일
문제 링크: https://leetcode.com/problems/add-digits/ 문제 Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. 조건 0 int: while len(str(num)) > 1: t_num = 0 for n in str(num): t_num += int(n) num = t_num return num 2) recursion 사용하지 않고 O(1)만에 class Solution: def addDigits(self, num: int) -> int: if num > 9: t_num = 0 for n in str(num): t_num += int(n) ..
문제 링크: https://leetcode.com/problems/find-the-difference/ 문제 You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. 조건 0

문제 링크: https://leetcode.com/problems/contiguous-array/ 문제 Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. 조건 1
문제 링크: https://leetcode.com/problems/4sum-ii/ 문제 Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: 0
문제 링크: https://leetcode.com/problems/design-add-and-search-words-data-structure/ 문제 Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class: WordDictionary() Initializes the object. void addWord(word) Adds word to the data structure, it can be matched later. bool search(word) Returns true if there is a..

문제 링크: https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/ 문제 Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0

문제 링크: https://leetcode.com/problems/all-elements-in-two-binary-search-trees/ 문제 Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order. 조건 The number of nodes in each tree is in the range [0, 5000]. $-10^5$
문제 링크: https://leetcode.com/problems/detect-capital/ 문제 We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first letter in this word is capital, like "Google". Given a string word, return true if the usage of capitals in it is right. 조건 1