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

1 Answer

0 like 0 dislike
Best answer

Images of ques

imageimageimageimageimageimage

 

by Expert (46,090 points)
selected by
0 0
//1.
#include <bits/stdc++.h>
using namespace std;


string f(string s)
{
    string ans = "";
    int temp = 0;
    for(int i = 1 ; i < s.size() ; i++)
    {
        if(s[i] == ' ')
        {
            ans = ans + to_string(temp);
            temp = 0;
            //ans.push_back(' ');
        }
        else
        {
            if(s[i-1] != ' ' && s[i] > s[i-1])
            {
                temp++;}
        }
    }
    ans = ans + to_string(temp);
            
            
    return ans;
}



int main()
{
    
    
    string s;
    getline(cin , s);
    
    cout<<f(s);
    
    
    return 0;
}





//2.
#include <bits/stdc++.h>
using namespace std;

#define pp pair<int , int>


pair<int , int> f(pp a , pp b , pp c)
{
    
    if(a.first == b.first && a.second == c.second)
    {
        return {abs(a.second - b.second) , abs(a.first - c.first)};
    }
    
    else if(a.first == c.first && a.second == b.second)
    {
        return {abs(a.second - b.second) , abs(a.first - c.first)};
    }
    
    return {-1 , -1};
}


int main()
{
    pp a;
    pp b;
    pp c;
    cin>>a.first>>a.second;
    cin>>b.first>>b.second;
    cin>>c.first>>c.second;
    
    double p = 0;
    double q = 0;
    double r = 0;
    
    
    if(f(a , b , c).first != -1)
    {
        p = f(a , b , c).first;
        q = f(a , b , c).second;
    }
    
    else if(f(b , a , c).first != -1)
    {
        p = f(b , a , c).first;
        q = f(b , a , c).second;
    }
    
    else
    {
        p = f(c , b , a).first;
        q = f(c , b , a).second;
    }
    
    r = sqrt((p*p) + (q*q));
    
    double x = p + q + r;
    double area = (p*q)/2;
    cout<<"p"<<" "<<x<<endl;
    cout<<"area"<<" "<<area<<endl;
    
    return 0;
}

/*
If there is any mistake or edge case , pls let me know

*/
0 0
Awesome Job bro