본문 바로가기

python-algorithm1402

leetcode 2651. Calculate Delayed Arrival Time https://leetcode.com/problems/calculate-delayed-arrival-time/description/ Calculate Delayed Arrival Time - LeetCode Can you solve this real interview question? Calculate Delayed Arrival Time - You are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours. Return leetcode.com 1 2 3 class S.. 2023. 7. 6.
leetcode 2544. Alternating Digit Sum https://leetcode.com/problems/alternating-digit-sum/description/ Alternating Digit Sum - LeetCode Can you solve this real interview question? Alternating Digit Sum - You are given a positive integer n. Each digit of n has a sign according to the following rules: * The most significant digit is assigned a positive sign. * Each other digit has an opposit leetcode.com 1 2 3 4 5 6 7 8 9 10 11 class .. 2023. 7. 3.
leetcode 2595. Number of Even and Odd Bits https://leetcode.com/problems/number-of-even-and-odd-bits/description/ Number of Even and Odd Bits - LeetCode Can you solve this real interview question? Number of Even and Odd Bits - You are given a positive integer n. Let even denote the number of even indices in the binary representation of n (0-indexed) with value 1. Let odd denote the number of odd indices in leetcode.com 1 2 3 4 5 6 7 8 9 .. 2023. 6. 27.
leetcode 2716. Minimize String Length https://leetcode.com/problems/minimize-string-length/description/ Minimize String Length - LeetCode Can you solve this real interview question? Minimize String Length - Given a 0-indexed string s, repeatedly perform the following operation any number of times: * Choose an index i in the string, and let c be the character in position i. Delete the closest leetcode.com 1 2 3 4 5 class Solution: de.. 2023. 6. 27.
leetcode 2710. Remove Trailing Zeros From a String https://leetcode.com/problems/remove-trailing-zeros-from-a-string/description/ Remove Trailing Zeros From a String - LeetCode Can you solve this real interview question? Remove Trailing Zeros From a String - Given a positive integer num represented as a string, return the integer num without trailing zeros as a string. Example 1: Input: num = "51230100" Output: "512301" Explan leetcode.com 1 2 3.. 2023. 6. 26.
leetcode 2656. Maximum Sum With Exactly K Elements https://leetcode.com/problems/maximum-sum-with-exactly-k-elements/description/ Maximum Sum With Exactly K Elements - LeetCode Can you solve this real interview question? Maximum Sum With Exactly K Elements - You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your score: 1. Select an e leetcode.com 1 .. 2023. 6. 26.
leetcode 35. Search Insert Position https://leetcode.com/problems/search-insert-position/description/?envType=study-plan-v2&envId=top-interview-150 Search Insert Position - LeetCode Can you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You mus.. 2023. 6. 26.
leetcode 172. Factorial Trailing Zeroes https://leetcode.com/problems/factorial-trailing-zeroes/description/?envType=study-plan-v2&envId=top-interview-150 Factorial Trailing Zeroes - LeetCode Can you solve this real interview question? Factorial Trailing Zeroes - Given an integer n, return the number of trailing zeroes in n!. Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1. Example 1: Input: n = 3 Output: 0 Explanation: 3! = 6,.. 2023. 6. 26.
leetcode 9. Palindrome Number https://leetcode.com/problems/palindrome-number/description/?envType=study-plan-v2&envId=top-interview-150 Palindrome Number - LeetCode Can you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Ex leetcode.. 2023. 6. 26.
백준 1152 단어의 개수 https://www.acmicpc.net/problem/1152 1152번: 단어의 개수 첫 줄에 영어 대소문자와 공백으로 이루어진 문자열이 주어진다. 이 문자열의 길이는 1,000,000을 넘지 않는다. 단어는 공백 한 개로 구분되며, 공백이 연속해서 나오는 경우는 없다. 또한 문자열 www.acmicpc.net 1 2 3 s = input() print(len(s.split())) cs 2023. 6. 24.
백준 1157 단어 공부 https://www.acmicpc.net/problem/1157 1157번: 단어 공부 알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 from collections import Counter s = input().lower() counter = Counter(s) #print(counter.most_common(2)) if len(s) == 1: print(s.upper()) else: most1, most2 = counter.most_common(2) if most1[1] == most2[1]: print(.. 2023. 6. 24.
leetcode 242. Valid Anagram https://leetcode.com/problems/valid-anagram/description/?envType=study-plan-v2&envId=top-interview-150 Valid Anagram - LeetCode Can you solve this real interview question? Valid Anagram - Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using leetcode.com .. 2023. 6. 23.