rahul_kumar
BAN USER
I am a pre-final year engineering student.
easy to understand
#include<bits/stdc++.h>
using namespace std;
struct node{
int data;
node *left,*right;
};
bool is_mirror(node *first_tree,node *second_tree)
{
if(first_tree==NULL && second_tree ==NULL)
return true;
if(first_tree== NULL || second_tree==NULL)
return false;
return (first_tree->data == second_tree->data) &&
is_mirror(first_tree->left,second_tree->right) &&
is_mirror(first_tree->right ,second_tree->left);
}
node *newnode(int d)
{
node * temp=new node;
temp->data=d;
temp->left=NULL;
temp->right=NULL;
return temp;
}
int main()
{
node *first_tree = newnode(1);
first_tree->left = newnode(2);
first_tree->right = newnode(3);
first_tree->left->left = newnode(4);
first_tree->left->right = newnode(5);
first_tree->right->left = newnode(6);
first_tree->right->right = newnode(3);
node *second_tree = newnode(1);
second_tree->left = newnode(3);
second_tree->right = newnode(2);
second_tree->left->left = newnode(7);
second_tree->left->right = newnode(6);
second_tree->right->left = newnode(5);
second_tree->right->right = newnode(4);
is_mirror(first_tree,second_tree)?cout<<"yes"<<endl:cout<<"no"<<endl;
}
handles all cases easy ans simple
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
while(b!=0)
{
int carry= a&b;
a = a ^ b;
b = carry<<1;
}
cout<< a<<endl;;
}
simple and easy code
#include<bits/stdc++.h>
using namespace std;
void print(vector<int>vec1,vector<int> vec2,int sum)
{
unordered_set<int> s;
for(int i=0;i<vec1.size();i++)
s.insert(vec1[i]);
for(int j=0;j<vec2.size();j++)
if(s.find(sum-vec2[j])!=s.end())
cout<<sum-vec2[j]<<" "<<vec2[j]<<endl;
}
int main()
{
int n,m;
cin>>n>>m;
vector<int> vec1(n),vec2(m);
for(int i=0;i<n;i++)
cin>>vec1[i];
for(int i=0;i<m;i++)
cin>>vec2[i];
int sum;
cin>>sum;
print(vec1,vec2,sum);
}
Simple and easy code
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
cin>>str;
char sym;
int ans=0,res=0;
for(int i=0;i<str.length();i++)
{
while(str[i]==str[i+1])
{
ans++;
i++;}
sym=str[i];
res=max(res,ans);
ans=0;
}
cout<<sym<<" "<<res+1<<endl;
}
RepI am working as a Software quality assurance analyst in Turtle's Records company. I look for flaws and weaknesses ...
Repharryhamesh, Android Engineer at ADP
I placement officers usually work in colleges and universities. One of My friends taught me about prayers that break curses ...
Replimlocica, News reporter at Smitty's Marketplace
Hello, I am a News reporter. Master's Degree in astrology and News reporter and 10 years of experience working ...
- rahul_kumar May 24, 2017