Embercode
✕
Binary Search TreesCoding problems

Binary Search Trees: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 7 solved

  • A shop writes the price of every product on one list each morning. Some prices appear more than once on the list. Print each price once, from smallest to largest, so the manager can read the price list.

    Build the list with your own binary search tree, and ignore a price that is already in the tree.

    Input. First line n, the number of prices (1 to 2000). Second line n integers, each from -1000000000 to 1000000000.

    Output. One line: the distinct prices in increasing order, separated by single spaces.

    Example 1 input

    6
    5 3 8 3 1 5
    

    Output

    1 3 5 8
    

    Example 2 input

    3
    -4 -4 0
    

    Output

    -4 0