Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
929 views
in Online Assessments by Expert (108,280 points) | 929 views

2 Answers

0 like 0 dislike
Best answer

image
Q2. Assume you are playing the game Mortal Kombat. If you have h health and d damage, and you have k opponents whose health and damage are stored in separate arrays, find the maximum coins u can earn in the game (killing a person with m health gives you m coins, and the opponents are against you only)
Q3. Give two numbers n and k, find the number of binary strings of length n which contain <= k zeroes after every 1 in the string.

by Expert (108,280 points)
0 like 0 dislike

Posting questions without test cases doesn't help anyone!
1st one is fairly straightforward :-)

vector<string>m;
void dfs(int i,int j,char ch,int len){

   for(int k=j;k<j+len;k++){
      m[i][k]=ch;
   }

   for(int k=j;k<j+len;k++){
     m[i+len-1][k]=ch;
   }
   for(int k=i+1;k<i+len-1;k++){
    m[k][j]=ch;
    m[k][j+len-1]=ch;
   }

}

void solve(){

    int n;
    cin>>n;
    string s= string(2*n,'*');
    for(int i=0;i<2*n;i++){
      m.push_back(s);
    }
    int i=0;
    int j=0;
    int len=2*n;
    for(char ch='a'+n-1; ch>='a';ch-- ){
        dfs(i,j,ch,len);
        len-=2;
        i++;
        j++;
    }
    for(auto x:m){
        cout<<x<<endl;
    }
}

Q2 is 2D knap-sack.
Q3 is DP.

 

Q2 assume max number of enemies<100, and there are times when you can't earn any coins (when their health/damage is too high )
Q3 no such constraints, but if ans is too big, give the remainder post division by 7+10^9

by Expert (108,280 points)