GEEKS FOR GEEKS WEEKLY CODING CONTEST 103 SOLUTIONS Refueling Code Answer C++ Refueling First GFG Weekly Coding Contest 103 class Solution{ public: long long refueling(int X) { long long a, b; for(int i=0; i<X; i++){ a = pow(2,i); if(a == X)return a; else if(a>X){ b = pow(2,i-1); if(abs(X-a) == abs(X-b))return a; if(abs(X-a) < abs(X-b))return a; else return b; } } return -1; } }; Input: X = 3, Output: 4 Input: X = 2,...
Job Alerts, Coding Solutions, Interview Material, Placement Material