Google Kickstart
It’s that time of the year again. Google Kickstart is back! Here are some tools that you can use to boost your skills as a developer
Tip 1:
In order to sum up an std::vector<int>
use the <numeric>
library and do the following
std::vector<int> some_container = {1, 2, 3, 4, 5}// The late value is the initialisation value which is typically 0
std::accumulate(some_container.begin(), some_container.end(), 0);
Tip 2:
Make use of the number of arguments given to receive your input. For example if the first value of the input is the number of test cases, use a for loop (or any other loop) to obtain each computation cycle.
int main()
{
// This will read the input
int T;
std::cin >> T; // Iterate through each of the test cases
for (int case_num = 1; case_num <= T; case_num++)
{ std::string s_input;
std::string f_input; std::cin >> s_input;
std::cin >> f_input;
}
}
Tip 3:
Often times input will be read as strings. However, what if the computation needs to be performed on an integer. Use std::stoi
!
std::string some_val = "5";
int some_int_val = std::stoi(some_val);
Tip 4:
Every wrong submission will incur a penalty on the kickstart platform. So instead of that use an alternative environment to feed in your input and test it out. I use codechef to help me out.
Happy hacking away!