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,109 views
in Online Assessments by Expert (46,090 points) | 1,109 views

1 Answer

0 like 0 dislike

Images of ques

image

 

by Expert (46,090 points)
0 0
//use pascal triangle logic
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    vector<int>arr{1,2,3,4};
    /* 4 5 6 7 //only take right most digit of the adjacent number  when adding
        9 11 13
        10  4
           4
    */
   int n=arr.size();
    
  vector<vector<int>>res;
  res.push_back(arr);

  for(int i=0;i<n;i++)
  {
    vector<int>ans;
    for(int j=0;j<res[i].size()-1;j++)
    {
     int sum=res[i][j]+res[i][j+1];
     sum=sum%10;
     ans.push_back(sum);
    }
    res.push_back(ans);
  }
  string r=to_string(res[n-2][0]);
  r+=to_string(res[n-2][1]);
  cout<<r;
  
}