[LeetCode] Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], return its zigzag level order traversal as: [ [3], [20,9], [15,7] ] Solution 1. root를 담은 q가 있는동안 반복한다. 2. q의 길이를 cnt로 놓고 cnt가 있는 동안 반복문을 실행한다. 3. q의 가장 첫번째를 pop하여 그 value값을..
2020. 7. 23.
[LeetCode] Word Search
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. Example: board = [ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E'] ] Given word = "ABCCED", return true. Given word = "SEE", r..
2020. 7. 22.