├── Coin Change Problem.cpp ├── Day 8: Dictionaries and Maps.cpp ├── README.md ├── The Hurdle Race.cpp ├── a very big sum.cpp ├── apple and orange.cpp ├── array introduction.cpp ├── between two sets.cpp ├── big data types.cpp ├── birthday cake candles.cpp ├── bon appetit.cpp ├── breaking-best-and-worst-records.cpp ├── compare the triples.cpp ├── conditional if else.cpp ├── counting valleys.cpp ├── designer pdf viewer.cpp ├── divisible sum pairs.cpp ├── electronics shop.cpp ├── equalize the array.cpp ├── find-digits.cpp ├── for loop.cpp ├── grading students.cpp ├── hello world.cpp ├── input and output.cpp ├── jumping on the cloud revisited.cpp ├── kickstart round d 2020 alien piano ├── library fine.cpp ├── migratory birds.cpp ├── mini max sum.cpp ├── picking numbers.cpp ├── sequence equation.cpp ├── sherlock and squares.cpp ├── simple array sum.cpp └── viral advertising.cpp /Coin Change Problem.cpp: -------------------------------------------------------------------------------- 1 | //Have A good day visitor 2 | //Author:Saksham Goel 3 | 4 | //Link TO the problem: https://www.hackerrank.com/challenges/coin-change/problem 5 | 6 | /* 7 | Problem Description: 8 | You are working at the cash counter at a fun-fair, and you have different types of coins available to you in infinite quantities. 9 | The value of each coin is already given. 10 | Can you determine the number of ways of making change for a particular number of units using the given types of coins? 11 | */ 12 | 13 | #include 14 | 15 | using namespace std; 16 | 17 | long long int count(long long int S[],long long int m,long long int n ) 18 | { 19 | long long int i, j, x, y; 20 | long long int table[n + 1][m]; 21 | for (i = 0; i < m; i++) 22 | table[0][i] = 1; 23 | for (i = 1; i < n + 1; i++) 24 | { 25 | for (j = 0; j < m; j++) 26 | { 27 | x = (i-S[j] >= 0) ? table[i - S[j]][j] : 0; 28 | y = (j >= 1) ? table[i][j - 1] : 0; 29 | table[i][j] = x + y; 30 | } 31 | } 32 | return table[n][m - 1]; 33 | } 34 | int main() 35 | { 36 | long long int n,m; 37 | cin>>n>>m; 38 | long long int arr[m]; 39 | for(int i=0;i>arr[i]; 41 | cout << count(arr, m, n); 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Day 8: Dictionaries and Maps.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | 10 | int main() { 11 | /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 12 | int t; 13 | cin>>t; 14 | map book; 15 | string s; 16 | int n; 17 | for(int i=0;i>s>>n; 19 | book[s]=n; 20 | } 21 | while(cin>>s){ 22 | 23 | 24 | if(!book[s]){ 25 | cout<<"Not found"< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int n; 8 | cin >>n; 9 | long long int ans=0; 10 | for (int i =0;i> num; 13 | ans+=num; 14 | } 15 | cout << ans < 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int s,t,a,b,m,n; 7 | cin>>s>>t>>a>>b>>m>>n; 8 | int arr[m]; 9 | int arr1[n]; 10 | int apple=0; 11 | int orange=0; 12 | 13 | for(int i=0;i>arr[i]; 15 | if(a+arr[i]>=s && a+arr[i]<=t){ 16 | apple++; 17 | } 18 | } 19 | 20 | for(int i=0;i>arr1[i]; 22 | if(b+arr1[i]>=s && b+arr1[i]<=t){ 23 | orange++; 24 | } 25 | } 26 | 27 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 11 | 12 | int n; 13 | cin >> n; 14 | 15 | int arr[n]; 16 | int arr2[n]; 17 | 18 | for (int i=0; i> arr[i]; 20 | arr2[(n-i-1)]=arr[i]; 21 | } 22 | 23 | for (int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n,m; 7 | cin>>n>>m; 8 | int arr[n]; 9 | int arr1[m]; 10 | int max=0; 11 | int min=100; 12 | for(int i=0;i>arr[i]; 14 | if(max>arr1[i]; 20 | if (min>arr1[i]){ 21 | min=arr1[i]; 22 | } 23 | } 24 | 25 | if(max>min){ 26 | cout<<"0"<0){ 31 | count=n; 32 | for(int i=0;imin){ 60 | flag=false; 61 | } 62 | } 63 | 64 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | // Complete the code. 8 | int a; 9 | long b; 10 | char c; 11 | float d; 12 | double e; 13 | 14 | scanf("%d %ld %c %f %lf",&a,&b,&c,&d,&e); 15 | cout << a << endl ; 16 | cout < 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | int a=0,b=0; 8 | cin >>n; 9 | 10 | int arr[n]; 11 | for (int i=0;i>arr[i]; 13 | } 14 | 15 | 16 | for (int j=0;ja){ 18 | a=arr[j]; 19 | } 20 | 21 | } 22 | 23 | 24 | for (int k=0;k 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n,k; 7 | cin>>n>>k; 8 | int bill=0; 9 | int s; 10 | int arr[n]; 11 | for(int i=0;i>arr[i]; 13 | if(i!=k){ 14 | bill+=arr[i]; 15 | } 16 | } 17 | bill=bill/2; 18 | cin>>s; 19 | 20 | if(bill==s){ 21 | cout<<"Bon Appetit"< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int t; 7 | cin>>t; 8 | int arr[t]; 9 | for(int i=0;i>arr[i]; 11 | } 12 | int max; 13 | int min; 14 | int count=0; 15 | int count1=0; 16 | max=arr[0]; 17 | min=arr[0]; 18 | for(int i=1;imax){ 20 | max=arr[i]; 21 | count++; 22 | } 23 | if(arr[i] 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int a[3]; 8 | for (int i=0;i<3;i++){ 9 | cin >> a[i]; 10 | } 11 | 12 | int b[3]; 13 | for (int i=0;i<3;i++){ 14 | cin >> b[i]; 15 | } 16 | 17 | int x=0,y=0; 18 | for (int i=0;i<3;i++){ 19 | if (a[i]b[i]){ 23 | x++; 24 | } 25 | } 26 | 27 | cout << x <<" "<< y<< endl; 28 | } -------------------------------------------------------------------------------- /conditional if else.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | 7 | int main() 8 | { 9 | int n; 10 | cin >> n; 11 | cin.ignore(numeric_limits::max(), '\n'); 12 | 13 | // Write Your Code Here 14 | if (n > 9){ 15 | cout << "Greater than 9" < 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | string arr; 9 | cin>>arr; 10 | int a=0; 11 | int b=0; 12 | int count=0; 13 | 14 | for (int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int height[26]; 7 | string s; 8 | 9 | for(int i=0;i<26;i++){ 10 | cin>>height[i]; 11 | 12 | } 13 | cin>>s; 14 | int l; 15 | l=s.length(); 16 | 17 | int h=0; 18 | int temp; 19 | int local; 20 | 21 | for(int i=0;i=h){ 28 | h=local; 29 | } 30 | } 31 | 32 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n,s; 7 | cin>>n>>s; 8 | int arr[n]; 9 | int sum=0; 10 | int count=0; 11 | 12 | for(int i=0;i>arr[i]; 14 | } 15 | 16 | for(int i=0;i=s){ 21 | count++; 22 | 23 | } 24 | } 25 | } 26 | 27 | } 28 | 29 | count=count/2; 30 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int money; 7 | cin>>money; 8 | int k,m; 9 | cin>>k>>m; 10 | int key[k]; 11 | int mouse[m]; 12 | int bill; 13 | int maxbill=0; 14 | for(int i=0;i>key[i]; 16 | } 17 | 18 | for(int i=0;i>mouse[i]; 20 | } 21 | 22 | for(int i=0;i=maxbill && bill<=money){ 27 | maxbill=bill; 28 | } 29 | 30 | } 31 | } 32 | if(maxbill==0){ 33 | cout<<"-1"< arr) { 3 | unordered_mapmp; 4 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | 6 | 7 | int main() 8 | { 9 | int t; 10 | cin>>t; 11 | int n,a; 12 | for(int i=0;i>n; 14 | a=n; 15 | int d; 16 | int count=0; 17 | while(a>0){ 18 | d=a%10; 19 | if(d!=0){ 20 | if(n%d==0 ){ 21 | count++; 22 | } 23 | } 24 | 25 | a=a/10; 26 | 27 | } 28 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | // Complete the code. 7 | int a,b,n; 8 | cin >> a >>b ; 9 | 10 | for (n=a ; n<=b ;n++){ 11 | switch(n){ 12 | case 1: 13 | cout <<"one\n"; 14 | break; 15 | 16 | case 2: 17 | cout <<"two\n"; 18 | break; 19 | case 3: 20 | cout <<"three\n"; 21 | break; 22 | case 4: 23 | cout <<"four\n"; 24 | break; 25 | case 5: 26 | cout <<"five\n"; 27 | break; 28 | case 6: 29 | cout <<"six\n"; 30 | break; 31 | case 7: 32 | cout <<"seven\n"; 33 | break; 34 | case 8: 35 | cout <<"eight\n"; 36 | break; 37 | case 9: 38 | cout <<"nine\n"; 39 | break; 40 | 41 | } 42 | 43 | if (n>9 && n%2==0 && n<=b){ 44 | cout << "even"<9 && n%2!=0 && n<=b){ 47 | cout << "odd"< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin >>n; 8 | int g; 9 | int a,b; 10 | 11 | for (int i=0;i>g; 13 | a=0; 14 | b=0; 15 | if (g>37){ 16 | a=g/5; //g=43,a=8,b=3 17 | b=g%5; 18 | 19 | if(b>2){ 20 | a++; //a=9 21 | g=a*5; //9*5=45=g 22 | } 23 | } 24 | 25 | cout < 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | printf("Hello, World!"); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /input and output.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | 9 | int main() { 10 | /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 11 | int a,b,c; 12 | cin >> a >> b >> c; 13 | cout << a+b+c << endl; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /jumping on the cloud revisited.cpp: -------------------------------------------------------------------------------- 1 | // Complete the jumpingOnClouds function below. 2 | int jumpingOnClouds(vector c, int k) { 3 | int power=100; 4 | int i=0; 5 | int l=c.size(); 6 | bool f1=true; 7 | while(f1){ 8 | i=i+k; 9 | if(i 2 | 3 | using namespace std; 4 | 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | vector v(n); 9 | for(int i=0;i>v[i]; 11 | } 12 | pairrange={1,4}; 13 | int count=0; 14 | for(int j=1;jv[j-1]){ 16 | range.first+=1; 17 | range.second=4; 18 | } 19 | else if(v[j]range.second){ 28 | count++; 29 | range={1,4}; 30 | } 31 | } 32 | cout<>t; 38 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int d1,m1,y1; 7 | cin>>d1>>m1>>y1; 8 | int d2,m2,y2; 9 | cin>>d2>>m2>>y2; 10 | 11 | if(y1==y2){ 12 | if(m1==m2){ 13 | if(d1==d2){ 14 | cout<<"0"< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | int arr[n]; 9 | int a1=0,a2=0,a3=0,a4=0,a5=0; 10 | 11 | for(int i=0;i>arr[i]; 13 | if(arr[i]==1){ 14 | a1++; 15 | } 16 | else if(arr[i]==2){ 17 | a2++; 18 | } 19 | else if(arr[i]==3){ 20 | a3++; 21 | } 22 | else if(arr[i]==4){ 23 | a4++; 24 | } 25 | else { 26 | a5++; 27 | } 28 | } 29 | 30 | if(a1>=a2 &&a1>=a3 && a1>=a4 && a1>=a5){ 31 | cout<<"1"<=a1 && a2>=a3 && a2>=a4 && a2>=a5){ 34 | cout<<"2"<=a2 && a3>=a1 && a3>=a4 && a1>=a5){ 37 | cout<<"3"<=a2 && a4>=a3 && a4>=a1 && a4>=a5){ 40 | cout<<"4"<=a2 && a5>=a3 && a5>=a4 && a5>=a1){ 43 | cout<<"5"< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int arr[5]; 7 | long long int total=0; 8 | 9 | for(int i=0;i<5;i++){ 10 | cin>>arr[i]; 11 | total+=arr[i]; //total sum of all five int 12 | } 13 | 14 | int* max; 15 | int* min; 16 | max=max_element(arr,arr+5); //find max int in array 17 | min=min_element(arr,arr+5); //find min int in array 18 | 19 | long long int maxsum; 20 | long long int minsum; 21 | maxsum=total-*min; // maximum sum of 4 int is =total - min int 22 | minsum=total-*max; //minimum sum of 4 int is =total -max int 23 | 24 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; //array length 7 | cin>>n; 8 | int arr[n]; //array 9 | for(int i=0;i>arr[i]; 11 | } 12 | int temp; //variable 13 | int a; //variable 14 | int count; //variable 15 | int num=0; //variable 16 | for(int i=0;icount){ 37 | count=temp; 38 | } 39 | } 40 | if(count>num){ 41 | num=count; 42 | } 43 | } 44 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin>>n; 8 | int arr[n]; 9 | for(int i=0;i>arr[i]; 11 | } 12 | int temp; 13 | vectorresult; 14 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int t; 7 | cin>>t; 8 | int a,b; 9 | int z; 10 | int sq; 11 | int count; 12 | for(int i=0;i>a>>b; 14 | count=0; 15 | for(int j=a;j<=b;j++){ 16 | z=sqrt(j); 17 | z=z*z; 18 | if(z==j){ 19 | count++; 20 | z=sqrt(z); 21 | break; 22 | 23 | } 24 | 25 | } 26 | bool flag=true; 27 | while(flag){ 28 | z=z+1; 29 | sq=z*z; 30 | if(sq<=b){ 31 | count++; 32 | } 33 | else{ 34 | flag=false; 35 | } 36 | } 37 | cout< 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | int n; 7 | cin >> n; 8 | int arr[n]; 9 | int sum=0; 10 | 11 | for (int i=0;i>arr[i]; 13 | sum+=arr[i]; 14 | } 15 | cout << sum; 16 | } -------------------------------------------------------------------------------- /viral advertising.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // Complete the viralAdvertising function below. 6 | int viralAdvertising(int n) { 7 | int people=5; 8 | int like=0; 9 | while(n>0){ 10 | like+=people/2; 11 | people=(people/2)*3; 12 | n--; 13 | } 14 | return like; 15 | } 16 | 17 | int main() 18 | { 19 | ofstream fout(getenv("OUTPUT_PATH")); 20 | 21 | int n; 22 | cin >> n; 23 | cin.ignore(numeric_limits::max(), '\n'); 24 | 25 | int result = viralAdvertising(n); 26 | 27 | fout << result << "\n"; 28 | 29 | fout.close(); 30 | 31 | return 0; 32 | } 33 | --------------------------------------------------------------------------------