본문 바로가기

leetcode13

[LeetCode] happyNumber js 문제 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.. 2023. 2. 8.
[LeetCode] Min Cost Climbing Stairs 자바 문제 You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps. You can either start from the step with index 0, or the step with index 1. Return the minimum cost to reach the top of the floor. 문제[번역] cost[] 정수 배열이 주어집니다. 당신은 cost값을 이용해 계단을 1칸또는 2칸 올라갈 수 있습니다. 당신은 0번째 계단이나 1번째 계단에서 시작합니다. 계단 꼭대기에 올라가기 위한 최.. 2022. 6. 27.
[LeetCode] Minimum Knight Moves 자바 문제 In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0]. A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction. Return the minimum number of steps needed to move the knight to the square [x, y]. It is guaranteed the answer exists. 문제[번역] 무.. 2022. 6. 23.
[LeetCode] Climbing Stairs (java) 문제 You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 문제[번역] n개로 이루어진 계단이 있다. 당신은 한번에 1칸 or 2칸만 올라갈 수 있다. 계단 정상에 오르는 방법의 가짓수는 몇개일까요? Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Exp.. 2022. 5. 25.
[LeetCode] Sqrt(x) (java) 문제 Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Note: You are not allowed to use any built-in exponent function or operator, such as pow(x, 0.5) or x ** 0.5. 문제[번역] 양수 x가 주어집니다 x의 제곱근을 구하세요 소수점이 나오면 소수부분을 버리세요 빌트인 함수나 객체를 쓰면 안됩니다.(Math.pow 같은) Ex.. 2022. 5. 25.
[LeetCode] Add Binary (java) 문제 Given two binary strings a and b, return their sum as a binary string. 문제[번역] 두 이진 문자열 a,b가 주어질때 이진 문자열로 합을 출력하라 Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" 제약조건 1 2022. 5. 24.
반응형