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

wherehows

  • 알고리즘/리트코드

    207. Course Schedule

    2021. 5. 23.

    by. 창고

    https://leetcode.com/problems/course-schedule/

     

    Course Schedule - 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

    // ___________________문제___________________

    // Cycle이 있는지 판단하기

     

    // __________________Syntax__________________

    // 

     

    // ________________Algorithms________________

    // 

     

    // ____________________Input___________________

    // prerequisites: [[4, 2], [4, 1], [2, 3], [2, 1], [3, 0], [2, 0], [1, 0]];

     

     

    1. 배열.push(val)의 return 값

     

        for(let i = 0; i < prerequisites.length; i++) {

            let start = prerequisites[i][1];

            let end = prerequisites[i][0];

            array[start] = array[start] ? array[start].push(end) : [end];

        }

     

    array[index] = array[index] ? array[index].push(val) : [val];

    array[index].push(val)은 배열 길이를 return한다.

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

    542. 01 Matrix  (0) 2021.05.27
    210. Course Schedule II  (0) 2021.05.24
    1277. Count Square Submatrices with All Ones  (0) 2021.05.23
    152. Maximum Product Subarray  (0) 2021.05.23
    53. Maximum Subarray  (0) 2021.05.23

    댓글

    관련글

    • 542. 01 Matrix 2021.05.27
    • 210. Course Schedule II 2021.05.24
    • 1277. Count Square Submatrices with All Ones 2021.05.23
    • 152. Maximum Product Subarray 2021.05.23
    맨 위로
전체 글 보기
Tistory 로그인
Tistory 로그아웃
로그아웃 글쓰기 관리

Today

Total

Powered by ⓒ Kakao Corp.

Designed by Nana
블로그 이미지
창고

티스토리툴바