Posts

Showing posts with the label Minimize Cost

HackerEarth's basic programming solutions( Minimize Cost, Magical Word, Best Index ) :

Problem 42: Minimize Cost Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) "Still working on this problem....."         Problem 43: Magical Word Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { int t ;    cin >> t ;     while ( t --)     {        int l ;       string s ;       cin >> l >> s ;        for ( int i = 0 ; i < s . length (); i ++)         {           if ( s [ i ]<= 69 && s [ i ]>= 65 )          s [ i ]= 'C' ;           else if ( s [ i ]<= 72 && s [ i ]>= 70 )          s [ i ]= 'G' ;           else if ( s [ i ]<= 76 && s [ i ]>= 73 )          s [ i ]= 'I' ;           else if ( s [ i ]<= 81 &&