Company: Citadel_30sep
Difficulty: medium
Code refactor and speedup Problem Description This code was written long ago and works fine on a small sample - but takes too long on a large input. Refactor and simplify the code. Find a faster solution to the problem. #include <vector> #include <limits> // For std::numeric_limits #include <algorithm> // For std::find_if, std::min, std::max #include <cmath> // For std::abs, std::pow, std::sqrt #include <iterator> // For std::advance, std::distance #include <iostream> // For std::cout, std::endl, std::cin, getline #include <fstream> // For std::ofstream #include <string> // For std::string #include <sstream> // For std::stringstream #include <chrono> // For std::chrono #include <cstdlib> // For getenv // Refactor and speed up the code below // The current implementation is correct but slow int root_node(std::vector<int> output) { int leaf = std::numeric_limits<int>::max(); // initialize to minimum value int x