rockettttman

  • 홈
  • 태그
  • 방명록

Algorithm 2

leetcode - 103. Binary Tree Zigzag Level Order Traversal

BFS (breadth first search) Input: root = [3,9,20,null,null,15,7] Output: [[3],[20,9],[15,7]] /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } */ /** * @param {TreeNode} root * @return {number[][]} */ var zigzagLevelOrder = f..

알고리즘 2021.03.24

Leetcode - Kth Largest Element in an Array(215)

JS heap priority queue - javascript 로 heap 우선순위 큐 알고리즘 풀이 /** * @param {number[]} nums * @param {number} k * @return {number} */ var findKthLargest = function(nums, k) { if(nums.length == 1) { return nums[0]; } //k가 1일 때 nums Array에서 바로 max값 return if(k === 1) { var maxNum = 0; return nums.reduce((bef, cur) => { console.log(bef + ", " + cur) return max = Math.max(maxNum, bef, cur) }); } var queu..

알고리즘 2021.03.05
이전
1
다음
더보기

Tag

moking test, attrr, redux, breadth-first search, 비구조화, Vue, Setup, JavaScript, router-link, vue3, map, React, ReactNative, webpack, async/await, Algorithm, priority queue, ducks pattern, git, hoisting,
  • 분류 전체보기 (46)
    • Mobile (3)
      • react-native (2)
      • Flutter (1)
    • Web (23)
      • spring (0)
      • javascript (14)
      • css (2)
      • react (1)
      • frontend (1)
      • vue (5)
    • java (3)
    • python (1)
    • DB (1)
    • Network (1)
    • Linux (1)
    • 개발상식 (7)
    • 알고리즘 (2)
    • git (4)

Copyright © Kakao Corp. All rights reserved.

티스토리툴바