[Easy] 1768. Merge Strings Alternately
leetCode 2022. 6. 2. 10:44

문제 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. Return the merged string. 예시 Example 1: Input: word1 = "abc", word2 = "pqr" Output: "apbqcr" Explanation: The merged string will be merged as so: word1: a b c word2: p q ..

[Easy] 1672. Richest Customer Wealth
leetCode 2022. 5. 31. 11:57

문제 You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has. A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth. 고객이 은행 에 가지고 있는 금액은 m x n정수 그리드 accounts가 ..

[Easy] 496. Next Greater Element I
leetCode 2022. 5. 31. 00:55

문제 The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. For each 0

[Easy] 1232. Check If It Is a Straight Line
leetCode 2022. 5. 30. 14:53

문제 You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane. 예시 Example 1: Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] Output: true Example 2: Input: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]] Output: false 제약 조건 Constraints: 2

[Easy] 1790. Check if One String Swap Can Make Strings Equal
leetCode 2022. 5. 30. 01:21

문제 You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices. Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false. 예시 Example 1: Input: s1 = "bank", s2 = "kanb" Outp..

[Easy] 202. Happy Number
leetCode 2022. 5. 30. 01:02

문제 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..

[Easy] 1502. Can Make Arithmetic Progression From Sequence
leetCode 2022. 5. 30. 00:30

문제 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..

[Easy] 1822. Sign of the Product of an Array
leetCode 2022. 5. 30. 00:21

문제 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..