Skip to content

Instantly share code, notes, and snippets.

View supriyanta's full-sized avatar

Supriyanta Poddar supriyanta

View GitHub Profile
#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]);
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):
@supriyanta
supriyanta / C++.sublime-build
Created August 3, 2017 14:04
Getting Sublime Text to build a C++ file.
{
"cmd": ["g++", "$file", "-o", "$file_base_name", "-I/usr/local/include"],
"selector": "source.c++",
"windows":
{
"cmd": ["cl", "/Fo${file_path}", "/O2", "$file"]
}
}
#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";
@supriyanta
supriyanta / Stack_ArrayImplementation.C
Created March 5, 2017 10:07 — forked from mycodeschool/Stack_ArrayImplementation.C
This is a basic array based implementation of stack data structure in C.
// 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.
@supriyanta
supriyanta / Stack_ArrayImplementation_OOP.cpp
Created March 5, 2017 10:01 — forked from mycodeschool/Stack_ArrayImplementation_OOP.cpp
An object oriented implementation of stack using arrays in C++.
// 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.