본문 바로가기

Easy13

[리트코드LeetCode][EASY][JAVA]2011. Final Value of Variable After Performing Operations 문제There is a programming language with only four operations and one variable X:++X and X++ increments the value of the variable X by 1.--X and X-- decrements the value of the variable X by 1.Initially, the value of X is 0.Given an array of strings operations containing a list of operations, return the final value of X after performing all the operations. Example 1:Input: operations = ["--X","X++.. 2025. 2. 8.
[리트코드LeetCode][Easy][JAVA]1929. Concatenation of Array 문제Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0  (0-indexed).Specifically, ans is the concatenation of two nums arrays.Return the array ans. Example 1:Input: nums = [1,2,1]Output: [1,2,1,1,2,1]Explanation: The array ans is formed as follows:- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]- an.. 2025. 1. 26.
[리트코드LeetCode][Easy][JAVA]88. Merge Sorted Array 문제You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.Merge nums1 and nums2 into a single array sorted in non-decreasing order.The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a lengt.. 2024. 12. 31.
[리트코드LeetCode][Easy][JAVA]3110. Score of a String 문제You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters.Return the score of s. Example 1:Input: s = "hello"Output: 13Explanation:The ASCII values of the characters in s are: 'h' = 104, 'e' = 101, 'l' = 108, 'o' = 111. So, the score of s would be |104 - 101| + |101 - 108| + |108 - 108| + |108 - 111| = 3 + 7.. 2024. 12. 29.
[리트코드LeetCode][Easy][JAVA]2769. Find the Maximum Achievable Number 문제Given two integers, num and t. A number is achievable if it can become equal to num after applying the following operation:Increase or decrease the number by 1, and simultaneously increase or decrease num by 1.Return the maximum achievable number after applying the operation at most t times. Example 1:Input: num = 4, t = 1Output: 6Explanation:Apply the following operation once to make the maxi.. 2024. 12. 29.
[리트코드][LeetCode][Easy][JAVA]35. 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 must write an algorithm with O(log n) runtime complexity. Example 1:Input: nums = [1,3,5,6], target = 5Output: 2Example 2:Input: nums = [1,3,5,6], target = 2Output: 1Example 3:Input: nums = [1,3,5,6], target = 7Output.. 2024. 9. 21.