-
268. Missing Number릿코드(LEETCODE) 2020. 2. 13. 11:42반응형
https://leetcode.com/problems/missing-number/
0~N 까지 중 없는 숫자를 출력하는 문제
Source
class Solution { public: int missingNumber(vector<int>& nums) { int result = 0; for (int i = 0; i < nums.size(); ++i) { result += (i+1)-nums[i]; } return result; } };
반응형'릿코드(LEETCODE)' 카테고리의 다른 글
389. Find the Difference (0) 2020.02.13 136. Single Number (0) 2020.02.13 1342. Number of Steps to Reduce a Number to Zero (0) 2020.02.13 70. Climbing Stairs (0) 2020.02.12 746. Min Cost Climbing Stairs (0) 2020.02.12