wherehows
Home
  • 분류 전체보기 (35)
    • 알고리즘 (31)
      • 코드트리 (0)
      • 백준 (1)
      • 리트코드 (21)
      • 프로그래머스 (9)
Home
  • 분류 전체보기 (35)
    • 알고리즘 (31)
      • 코드트리 (0)
      • 백준 (1)
      • 리트코드 (21)
      • 프로그래머스 (9)
블로그 내 검색

wherehows

  • 알고리즘/리트코드

    209. Minimum Size Subarray Sum

    2021. 7. 18.

    by. 창고

    https://leetcode.com/problems/minimum-size-subarray-sum/

     

    Minimum Size Subarray Sum - LeetCode

    Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

    leetcode.com

     var minSubArrayLen = function(target, nums) {
         let left = right = 0;
         let min = Number.MAX_SAFE_INTEGER;
         let sum = 0;
    
         for(right = 0; right < nums.length; right++) {
            sum += nums[right];
    
            while(sum >= target) {
                min = Math.min(min, right - left + 1);
            
                sum -= nums[left];
                left++;
            }
         }
    
         if(min === Number.MAX_SAFE_INTEGER) return 0;
    
         return min;
    };

    '알고리즘 > 리트코드' 카테고리의 다른 글

    856. Score of Parentheses  (0) 2021.07.14
    47. Permutations II  (1) 2021.06.20
    137. Single Number II  (0) 2021.06.19
    287. Find the Duplicate Number  (0) 2021.06.18
    153. Find Minimum in Rotated Sorted Array  (0) 2021.06.17

    댓글

    관련글

    • 856. Score of Parentheses 2021.07.14
    • 47. Permutations II 2021.06.20
    • 137. Single Number II 2021.06.19
    • 287. Find the Duplicate Number 2021.06.18
    맨 위로
전체 글 보기
Tistory 로그인
Tistory 로그아웃
로그아웃 글쓰기 관리

Today

Total

Powered by ⓒ Kakao Corp.

Designed by Nana
블로그 이미지
창고

티스토리툴바