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

5 Answers

0 like 0 dislike
Best answer
C++ code for polygon Question :

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define For(i,j,n,in) for (int i = j; i<n;i+=in)
#define loop(i,n) For(i,0,n,1)
const ll mod = 1e9 +7;

int main(){
  int t; cin>>t;
  ll ans = -1; bool okx = true ; int anti = 1e6,prop = 1e8 ; bool oky = true;
  while(t--){
    int x,y; cin>>x>>y;
    if ( okx and x==anti and y!=prop){
      anti =x;
      prop =y;
      okx = false ;
      oky = true;
      ans++;
    }
    else if ( oky and y == prop and x!=anti){
      anti = x; prop = y;
      oky = false;
      okx = true;
      ans++;
    }
    else if ( y!= prop and x!=anti) {
      anti =x; prop = y;
      okx = true; oky = true;
      ans++;

    }
    else{
          anti =x; prop = y;

    }
  }
  cout<<(ans+1);
}
by Expert (107,750 points)
0 like 0 dislike

Docstore Offline Question :-

by Expert (34,270 points)
1 like 0 dislike

Civil War Question :-

by Expert (34,270 points)
1 like 0 dislike

GenerateNewWord Coding Question (C) C++ code : 

#include <bits/stdc++.h>
using namespace std;
int main(){
int t=0;    
string s;
string num="";j
string num1="";
getline(cin,s);
transform(s.begin(), s.end(), s.begin(), ::tolower);
int n =s.length();
string c;
getline(cin,c);
transform(c.begin(), c.end(), c.begin(), ::tolower);
string num2="";
int m = c.length();
   

string w="";
for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
        if(s[i]==c[j]){
            w+=s[i];
            t=1;
        }
        
        
        }
        
    }

for (int i = 0; i < w.length(); i++) {  
        if (w[i] - '0' >= 0 and w[i] - '0' <= 9) {
            num += w[i];
        }
}
for(int i = 0; i< w.length(); i++){
        if(isdigit(w[i])){
            w.erase(i, 1);
            i--;
        }
    }
if(t==0){    
cout<<w<<" "<<num;
}
else{
    cout<<"New Language Error";
}
return 0;

}

 

by Expert (107,750 points)
1 like 0 dislike

CollegeRank1 Question B : 

Code : 

 

import operator
def allocate(clg):
    flag = 0
    for x in clg:
        for y in range(len(seats)):
            if seats[int(x[2:])-1] != 0:
                seats[int(x[2:])-1] -= 1
                flag = 1
                break
        if flag == 1:
            return [True,x]
    return [False]

C, N = list(map(int, input().split()))
seats = list(map(int,input().split()))
students = []
output = []
for x in range(N):
    students.append(input().split(','))
students = sorted(students, key=operator.itemgetter(1), reverse=True)
for x in students:
    val = allocate(x[2:])
    if val[0]:
        print(x[0],val[1])


# 3 5
# 3 1 2
# Student-1,97.05,C-1,C-3,C-2
# Student-2,48.03,C-1,C-2,C-3 
# Student-3,85.69,C-1,C-3,C-2 
# Student-4,80.83,C-1,C-3,C-2 
# Student-5,41.23,C-1,C-2,C-3

 


# 4 5
# 2 1 1 1 
# Student-1,97.05,C-1,C-3,C-2 
# Student-2,48.03,C-1,C-2,C-3
# Student-3,85.69,C-1,C-3,C-2
# Student-4,80.83,C-1,C-3,C-2 
# Student-5,41.23,C-1,C-2,C-34 5

Question : 

by Expert (107,750 points)
0 0
send me answer bro