diff --git a/11-05-2020/Ques1.JPG b/11-05-2020/Ques1.JPG new file mode 100644 index 0000000..b36f5a3 Binary files /dev/null and b/11-05-2020/Ques1.JPG differ diff --git a/11-05-2020/Ques1.cpp b/11-05-2020/Ques1.cpp new file mode 100644 index 0000000..2a616b5 --- /dev/null +++ b/11-05-2020/Ques1.cpp @@ -0,0 +1,31 @@ +/* +Question 1: +Single Number +Given an array of integers, every element appears twice except for one. Find that single +one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without +using extra memory? +*/ +#include +#include +using namespace std; + +int main() +{ vector a; + int n,p,e=0; + cout<<"Enter the no. Of Element In array:"<>n; + cout<<"Enter an Array"<>p; + a.push_back(p); + } + + for (int i = 0;i +#include +using namespace std; + +int main() +{ +int n; +cout<<"Enter the number:"; +cin>>n; +float h = n; +float l = 1; +float mid; + +for(int i = 1;i n) + { + h = mid-1; + } + else + {if(mid*mid < n) + { + l = mid+1; + } + } +} +cout<<"Using B search:"< +#include +#include +using namespace std; +int main(){ + int n; + cout<<"Enter the no. of Blocks:"<>n; + int x; + x= (-1+sqrt(1+8*n))/2; + cout<<"The Height is "< +#include +using namespace std; + +int main() +{ + int r; + cout<<"Enter A:"<>r; + vector> a(r ,vector(r,0)); + cout<<"Array:"< +#include +using namespace std; + +int main() +{ vector a; + int n,p; + cout<<"Enter the no. Of Element In array:"<>n; + cout<<"Enter an Array"<>p; + a.push_back(p); + } + + + int i,s,m=INT_MAX; + sort(a.begin(),a.end()); + for(int i =0;is) + m=s; + } + cout<<"Min X-or Value:"< +using namespace std; +int gcd(int a,int b) +{ + int q,r; + q=a/b; + r=a%b; + if (r==0){ + return b; + } + else{ + gcd(b,r); + } +} +int main(){ +int x,y,a,b; +cout<<"Enter the Numbers For GCD:"; +cin>>x>>y; +cout<y?x:y); +b=((x+y)-a); +cout<<"Greatest divisor that divides both "< +using namespace std; +int gcd(int a,int b) +{ + int q,r; + q=a/b; + r=a%b; + if (r==0){ + return b; + } + else{ + gcd(b,r); + } +} + +int main(){ + + int a,b,c; + cout<<"Enter A:"; + cin>>a; + cout<<"\nEnter B:"; + cin>>b; + cout<<"\nEnter C:"; + cin>>c; + int lcm=(b*c)/gcd(b,c); + cout<<"Total nos between range 1 to "< +using namespace std; +int main(){ + int n; + cout<<"How May Array elements:"<>n; + vector A(n); + cout<<"Enter an Array"<>A[i]; + cout< +using namespace std; +int gcd(int a,int b) +{ + int q,r; + q=a/b; + r=a%b; + if (r==0){ + return b; + } + else{ + gcd(b,r); + } +} +int main(){ +int x,y,a,b; +cout<<"Enter the Numbers For GCD:"; +cin>>x>>y; +cout<y?x:y); +b=((x+y)-a); +int gd = (b==1?1:gcd(a,b)); +cout<<"Greatest divisor that divides both "< 0 || sum > 9) + { + if (n == 0) + { + n = sum; + sum = 0; + } + sum += n % 10; + n /= 10; + } + + return (sum == 1); +} +*/ + +#include +using namespace std; +int main(){ + int n = 1000; + int i = 1; + cout<<"All Magic Numbers Between 1 to 1000:"<