문제 Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy..
문제 A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Given an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false. arr 배열의 요소들간의 차가 일정하면 true, 일정하지 않다면 false를 반환한다. 예시 Example 1: Input: arr = [3,5,1] Output: true Explanation: We can reorder the eleme..
문제 There is a function signFunc(x) that returns: 1 if x is positive. -1 if x is negative. 0 if x is equal to 0. You are given an integer array nums. Let product be the product of all values in the array nums. Return signFunc(product). nums 배열의 요소들을 모두 곱했을 때 양수면 1 반환, 음수면 -1 반환, 0이면 0을 반환한다. 예시 Example 1: Input: nums = [-1,-2,-3,-4,3,2,1] Output: 1 Explanation: The product of all values in the ar..
문제 You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location. Return the index (0-indexed) of the valid point with the smallest Manhattan distance ..
문제 Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths. If it is impossible to form any triangle of a non-zero area, return 0. nums 배열이 들어오면, 그 중 세 개의 요소로 이루어진 삼각형의 가장 큰 둘레를 반환한다. 삼각형을 만드는 것이 불가능하면 0을 반환한다. 예시 Example 1: Input: nums = [2,1,2] Output: 5 Example 2: Input: nums = [1,2,1] Output: 0 제약조건 Constraints: 3
문제 Given an integer number n, return the difference between the product of its digits and the sum of its digits. 각 자릿수의 곱과 합을 뺀 값을 반환한다. 예시 Example 1: Input: n = 234 Output: 15 Explanation: Product of digits = 2 * 3 * 4 = 24 Sum of digits = 2 + 3 + 4 = 9 Result = 24 - 9 = 15 Example 2: Input: n = 4421 Output: 21 Explanation: Product of digits = 4 * 4 * 2 * 1 = 32 Sum of digits = 4 + 4 + 2 + 1 = ..
문제 Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). low부터 high까지 홀수가 몇 개인지 반환하는 문제이다. 예시 Example 1: Input: low = 3, high = 7 Output: 3 Explanation: The odd numbers between 3 and 7 are [3,5,7]. Example 2: Input: low = 8, high = 10 Output: 1 Explanation: The odd numbers between 8 and 10 are [9]. 제약 조건 Constraints: 0
https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/ Average Salary Excluding the Minimum and Maximum Salary - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 You are given an array of unique integers salary where salary[i] is the salary of the ..
Comment