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, Output: 2 K-Periodic Circular String Code Solution C++ K-Periodic Circular String Second GFG Weekly Coding Contest 103 class Solution{ public: string kPeriodic(string s, int K){ // code here map<char,int> hm; for(int i=0;i<s.size();i++){ hm[s[i]]++; } int n= s.size(); int res= n/__gcd(n,K); for(auto t:hm
Job Alerts, Coding Solutions, Interview Material, Placement Material