본문 바로가기

LeetCode342

leetcode 326. Power of Three https://leetcode.com/problems/power-of-three/description/ Power of Three - LeetCode Power of Three - Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Input: n = 27 Output: true Explanation: 27 = 33 Example 2: leetcode.com 1 2 3 4 5 6 7 8 9 import math def Log3(x): retur.. 2023. 1. 17.
leetcode 263. Ugly Number https://leetcode.com/problems/ugly-number/description/ Ugly Number - LeetCode Ugly Number - An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return true if n is an ugly number. Example 1: Input: n = 6 Output: true Explanation: 6 = 2 × 3 Example 2: Input: n = 1 Output: true leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2.. 2023. 1. 17.
leetcode 231. Power of Two https://leetcode.com/problems/power-of-two/description/ Power of Two - LeetCode Power of Two - Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. Example 1: Input: n = 1 Output: true Explanation: 20 = 1 Example 2: Input: n leetcode.com 1 2 3 4 5 6 7 8 def Log2(x): return (math.log10(x) .. 2023. 1. 17.
leetcode 1446. Consecutive Characters https://leetcode.com/problems/consecutive-characters/description/ Consecutive Characters - LeetCode Consecutive Characters - The power of the string is the maximum length of a non-empty substring that contains only one unique character. Given a string s, return the power of s. Example 1: Input: s = "leetcode" Output: 2 Explanation: The substring "ee" leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 14.. 2023. 1. 14.
leetcode 2042. Check if Numbers Are Ascending in a Sentence https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/description/ Check if Numbers Are Ascending in a Sentence - LeetCode Check if Numbers Are Ascending in a Sentence - A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of .. 2023. 1. 13.
leetcode 191. Number of 1 Bits https://leetcode.com/problems/number-of-1-bits/description/ Number of 1 Bits - LeetCode Number of 1 Bits - Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight [http://en.wikipedia.org/wiki/Hamming_weight]). Note: * Note that in some languages, such as Java, there is no un leetcode.com 1 2 3 class Solution: def hammingWeight(.. 2023. 1. 13.
leetcode 2138. Divide a String Into Groups of Size k https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/description/ Divide a String Into Groups of Size k - LeetCode Divide a String Into Groups of Size k - A string s can be partitioned into groups of size k using the following procedure: * The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, leetcode.co.. 2023. 1. 12.
leetcode 2180. Count Integers With Even Digit Sum https://leetcode.com/problems/count-integers-with-even-digit-sum/description/ Count Integers With Even Digit Sum - LeetCode Count Integers With Even Digit Sum - Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even. The digit sum of a positive integer is the sum of all its digits. Example 1: Input: num = 4 Ou leetcode.com 1 2 3 4.. 2023. 1. 12.
leetcode2351. First Letter to Appear Twice https://leetcode.com/problems/first-letter-to-appear-twice/description/ First Letter to Appear Twice - LeetCode First Letter to Appear Twice - Given a string s consisting of lowercase English letters, return the first letter to appear twice. Note: * A letter a appears twice before another letter b if the second occurrence of a is before the second occurrence of b. * leetcode.com 1 2 3 4 5 6 7 8 .. 2023. 1. 11.
leetcode 1768. Merge Strings Alternately https://leetcode.com/problems/merge-strings-alternately/description/ Merge Strings Alternately - LeetCode Merge Strings Alternately - You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string. Ret leetcode.com 1 2 3 4 5 6 7 8 9 clas.. 2023. 1. 11.
leetcode 728. Self Dividing Numbers https://leetcode.com/problems/self-dividing-numbers/description/ Self Dividing Numbers - LeetCode Self Dividing Numbers - A self-dividing number is a number that is divisible by every digit it contains. * For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. A self-dividing number is not allowed to contain the leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 13 .. 2023. 1. 10.
leetcode 2427. Number of Common Factors https://leetcode.com/problems/number-of-common-factors/description/ Number of Common Factors - LeetCode Number of Common Factors - Given two positive integers a and b, return the number of common factors of a and b. An integer x is a common factor of a and b if x divides both a and b. Example 1: Input: a = 12, b = 6 Output: 4 Explanation: The common facto leetcode.com 1 2 3 4 5 6 7 8 9 10 11 12 .. 2023. 1. 10.