Basic Algorithm practice in C/C++/Java/python