leetcode

    [leetcode] 136. Single Number 해설

    136. Single Number https://leetcode.com/problems/single-number/ Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. Follow up: Could you implement a solution with a linear runtime complexity and without using extra memory? Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: Input: nums = [1] ..

    [leet code]169. Majority Element (최다 요소)

    https://leetcode.com/problems/majority-element/ Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2 이 문제는 배열내의 최대다수 를 구하는것이 문제이다. 여기서 중요한점은 The majority ..