From b68583c06de1b397408668b79afdea19d9e90722 Mon Sep 17 00:00:00 2001 From: Abdelrahman Elzarka <108380629+Abdelrahmanelzarka@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:00:54 +0200 Subject: [PATCH] Create Code.cpp --- Level 1 Class 3/Practice G/Week 12/Code.cpp | 319 ++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 Level 1 Class 3/Practice G/Week 12/Code.cpp diff --git a/Level 1 Class 3/Practice G/Week 12/Code.cpp b/Level 1 Class 3/Practice G/Week 12/Code.cpp new file mode 100644 index 0000000..b791ed0 --- /dev/null +++ b/Level 1 Class 3/Practice G/Week 12/Code.cpp @@ -0,0 +1,319 @@ +#include + +using namespace std; + +/*vector a; + +/// problem A +int solve(int i) +{ + if(i==a.size()) + return 0; + + + return solve(i+1)+a[i]; +} +///O(n) +*/ + + +/// problem B +int solve2(int i) +{ + if(i<=1) + return i; + + return solve2(i-1)+solve2(i-2); +} +/// O(2^n) + + +/// problem C +/*int super(long long num) +{ + if(num<10) + return num; + + int temp=0; + while(num) + { + + temp+=num%10; + num/=10; + } + + return super(temp); +}*/ +///O(n*k) + +/* +/// problem E +vectora,b; +int prod(int i) +{ + if(i==a.size()) + return 0 ; + + + return prod(i+1)+ a[i]*b[i]; + + +} +/// O(n) + + +///problem f +/*int n,s,d; +vectorx,y; + +int solve3(int i) +{ + if(i==n) + return 0; + + + if(x[i]d) + { + return 1; + } + else{ + return solve3(i+1); + } +}*/ +///problem G +/*string s; +int solve4(int i) +{ + if(i==s.length()) + return 1;///Yes + + if((i%2==0 && (s[i]<'a' || s[i]>'z'))|| (i%2==1 && (s[i]<'A' || s[i]>'Z')) ) + { + return 0; ///NO + } + else + { + return solve4(i+1); + } + +}*/ + +/// problem H +/* +vectora,b,c; +int n; +int mn=INT_MAX; + +void solve5(int i) +{ + if(i==n) + return ; + + if(c[i]>a[i]) + mn=min(mn,b[i]); + + solve5(i+1); + + + +}*/ + +/// problem I +/*vector a; +int x; + +void solve6(int i) +{ + if (i==a.size()) + return; + + if(a[i]!=x) + cout<=n) + { + cout<>t; + for(int i=1 ; i<=t; i++) + { + cin>>n; + + for(int j=0 ; j>x; + a.push_back(x); + } + + cout<<"Case "<>n; + cout<>n>>k; + + for(int j=0 ; j>n; + for(int i=0 ; i>x; + a.push_back(x); + } + for(int i=0 ; i>x; + b.push_back(x); + } + + + if(prod(0)) + { + cout<<"No"; + } + else + { + cout<<"Yes"; + }*/ + + + + /// problem f + + /* cin>>n>>s>>d; + int xx,yy; + for(int i=0 ; i>xx>>yy; + x.push_back(xx); + y.push_back(yy); + } + + if(solve3(0)) + { + cout<<"Yes"; + } + else + cout<<"No";*/ + + + ///problem G + /* cin>>s; + if(solve4(0)) + { + cout<<"Yes"; + } + else + cout<<"No";*/ + +/// problem H +/* + int aa,bb,cc; + cin>>n; + for(int i=0 ; i>aa>>bb>>cc; + a.push_back(aa); + b.push_back(bb); + c.push_back(cc); + } + solve5(0); + + if(mn==INT_MAX) + cout<<-1; + else + cout<>n>>x; + for(int i=0 ; i>aa; + a.push_back(aa); + } + + solve6(0);*/ + + + /// problem J + + /* cin>>s; + solve7(0);*/ + + /// problem K + cin>>n; + solve8(0); + + + + + + return 0; +} + +