My leetcode submissions.
at main 39 lines 884 B view raw
1/* ======================================================================== 2 * 3 * Filename: 4 * Description: 5 * Author: 6 * Version: 0.0.1 7 * 8 * ======================================================================== */ 9#include <iostream> 10#include <vector> 11 12typedef std::pair<int, int> ii; 13typedef std::vector<ii> vii; 14 15auto validateBinaryTreeNodes(int n, std::vector<int>& leftChild, std::vector<int>& rightChild) 16{ 17 auto nodes = vii(); 18 /* find the parent of each node */ 19 for (size_t i = 0; i < n; i++) { 20 nodes.push_back({ leftChild[i], rightChild[i] }); 21 } 22 23 /* a valid tree: 24 * only 1 parent per node 25 * only 1 node with no parent 26 */ 27 return false; 28} 29 30auto main() -> int 31{ 32 auto c1l = std::vector{ 1, -1, 3, -1 }; 33 auto c1r = std::vector{ 2, -1, -1, -1 }; 34 auto c1n = 4; 35 36 std::cout << validateBinaryTreeNodes(c1n, c1l, c1r) << std::endl; 37 return 0; 38} 39