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

2 Answers

0 like 0 dislike
Best answer

Images of ques : Constraints :-------> n<=1000 

imageimageimage

 

by Expert (46,090 points)
edited by
0 like 0 dislike

CODE :

string getEncryptedNumber(vector <int> numbers){
    
    int l = numbers.size();
    l = l-2 ;
    int kk = 1 ;
    while(kk<=l) {
        
        vector <int> gg ;
        gg.clear();
        int i = 0 ;
        int vm = numbers.size();
        while(i<vm-1) {
            int yy = numbers[i] + numbers[i+1];
            gg.push_back(yy%10);
            
            i++;
        }
        numbers = gg ;
        kk++;
    }
    
    //cout<<numbers[0]<<" "<<numbers[1];
    //cout<<"\n";
    //return "ram";
    string s0 = to_string(numbers[0]);
    string s2 = to_string(numbers[1]);
    //cout<<s0<<"\n";
    string s5 = s0 + s2 ;
    //cout<<s5<<"\n";
    return (s5);
}
by Expert (46,090 points)
edited by