This is the solution of a Google Interview Question asked in a video (Google Coding Interview With A College Student) in Clement Mihailescu's channel
The actual problem statement for this algorithm was asked by Clement Mihailescu in his youtube channel link in the video
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
🔹 Basic understanding of algorithmic complexity
🔹 Greedy algorithm
Please read the code carefully everything is written in the comments, if you still have difficulty understanding the code then dry run the code hopefully it will make the concept clear for you.
↪️ How to compile and run c++ code?
Linux
~$ g++ filename.cpp -o outputFile
~$ ./outputFile
Windows
g++ filename.cpp -o outputFile
outputFile.exe
↪️ g++ command not working
Windows Install MinGW in your pc and add the path of bin folder in MinGW to system variable 'path'. Linux
~$ sudo apt-get update
~$ sudo apt-get upgrade
~$ sudo apt install g++
then open terminal and check the version of your gcc.
gcc --version
It will show your gcc version.