Algorithm/LeetCode
-
[Leetcode] 1748. Sum of Unique ElementsAlgorithm/LeetCode 2021. 8. 22. 17:02
You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. Return the sum of all the unique elements of nums. Example 1: Input: nums = [1,2,3,2] Output: 4 Explanation: The unique elements are [1,3], and the sum is 4. Example 2: Input: nums = [1,1,1,1,1] Output: 0 Explanation: There are no unique elements, and the sum is 0. Example..
-
[Leetcode] 961. N-Repeated Element in Size 2N ArrayAlgorithm/LeetCode 2021. 8. 22. 16:35
You are given an integer array nums with the following properties: nums.length == 2 * n. nums contains n + 1 unique elements. Exactly one element of nums is repeated n times. Return the element that is repeated n times. Example 1: Input: nums = [1,2,3,3] Output: 3 Example 2: Input: nums = [2,1,2,5,3,2] Output: 2 Example 3: Input: nums = [5,1,5,2,5,3,5,4] Output: 5 Constraints: 2
-
[LeetCode]#682. Baseball GameAlgorithm/LeetCode 2021. 8. 13. 16:19
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty. Example 1: Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac". Example 2: Input: s = "ab##", t = "c#d#" Output: true Explanation: Both s and t become "". Exampl..
-
[Leetcode] 844. Backspace String CompareAlgorithm/LeetCode 2021. 8. 13. 15:06
844. Backspace String Compare Easy 2788126Add to ListShare Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty. Example 1: Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac". Example 2: Input: s = "ab##", t = "c#d..