Friedrich Ewald My Personal Website


  • Leetcode: Binary tree zigzag level order traversal

    Traverse a tree where the root node is given with a zig-zag level and return the values in a list with one entry per level. For example:

    -->    3
        /     \
       9       5      <--
            /     \
    -->    7       8
    Returns: [[3], [5,9], [7,8]]

    Continue reading

  • Leetcode: Binary tree level order traversal

    Given the root node of a binary tree, print all values in order, meaning from left to right on the same level. To solve this, we can use the standard breadth-first-search (BFS) algorithm in an iterative fashion with a queue. As an output we use a list and leverage the position -1 to add the current level to the list. For every level we append one new element to the end of the list.

    Continue reading

  • Leetcode: Valid sudoku

    Given a Sudoku field as a two-dimension list, determine if the field is valid. A valid field only has the number 1-9 once in each sub-field, each row, and each column. The field is not completely filled and we don’t need to check for a valid solution.

    Continue reading

  • Leetcode: Top k frequent elements

    Given a list nums and a positive integer k, return the top k frequent items from the list. A time complexity constraint is not given for this task.

    Continue reading

  • Leetcode: Find peak element

    Given an array n of integers, find one peak in O(log*n) time. A peak is defined as a number where the two numbers immediately left and right are strictly less than the number. Numbers outside of the bounds of this array are considered to be smaller.

    Continue reading

Page: 6 of 28