This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<cmath> | |
| #include<iostream> | |
| #include<climits> | |
| using namespace std; | |
| int Maximum_Sum_Subarray(int arr[],int n) //Overall Time Complexity O(n) | |
| { | |
| int ans = A[0],sum = 0; | |
| for(int i = 1;i < n; ++i) //Check if all are negative | |
| ans = max(ans,arr[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def rec(n): | |
| if(n<12): | |
| return n; | |
| if n//4>1000000 : | |
| n_by2=rec(n//2) | |
| n_by3=rec(n//3) | |
| n_by4=rec(n//4) | |
| sum=n_by2+n_by3+n_by4 | |
| if(sum<=n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "cmd": ["g++", "$file", "-o", "$file_base_name", "-I/usr/local/include"], | |
| "selector": "source.c++", | |
| "windows": | |
| { | |
| "cmd": ["cl", "/Fo${file_path}", "/O2", "$file"] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| int main() | |
| { | |
| int sum=0,user=0; | |
| cout<< "Rules:\n--> There are 21 Matchsticks.\n--> You can pick up at max 4 matchsticks in one go.\n--> Whoever picked up the last matchstick will loss the game.\n\n\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Stack - Array based implementation. | |
| // Creating a stack of integers. | |
| #include<stdio.h> | |
| #define MAX_SIZE 101 | |
| int A[MAX_SIZE]; // integer array to store the stack | |
| int top = -1; // variable to mark top of stack in array | |
| // Push operation to insert an element on top of stack. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Stack - Object oriented implementation using arrays | |
| #include <iostream> | |
| using namespace std; | |
| #define MAX_SIZE 101 | |
| class Stack | |
| { | |
| private: | |
| int A[MAX_SIZE]; // array to store the stack | |
| int top; // variable to mark the top index of stack. |