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 lis(arr,n): | |
dp = [1 for x in range(0,n)] | |
for i in range(1,n): | |
for j in range(0,i): | |
if dp[j] >= dp[i] and arr[j] < arr[i]: | |
dp[i] += 1 | |
result = [] | |
max_value = max(dp) | |
i = n-1 | |
while i >= 0: |
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
from math import log,ceil | |
arr = [1,3,5,7,9,11] | |
height = ceil(log(len(arr),2)) | |
tree = [-1 for _ in range(0,2**(height+1))] | |
def construct(index,start,end): | |
global tree | |
if start == end: | |
tree[index] = arr[start] |
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> | |
#include <cmath> | |
#include <algorithm> | |
using namespace std; | |
class Node { | |
public: | |
int needLeft; | |
int needRight; | |
Node(){ |
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> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int maximum(int arr[],int n){ | |
int i,max_val; | |
max_val = arr[0]; | |
for(i=0; i<n; i++){ | |
if(arr[i] > max_val){ |
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> | |
#include <map> | |
#include <vector> | |
#include <queue> | |
using namespace std; | |
class Graph{ | |
public: | |
vector<pair<int,int> > adjList[10001]; |
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> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int t,n,testcase; | |
vector<string> bankList; | |
string acc,block; | |
cin>>t; |
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
class min_heap(): | |
def __init__(self): | |
self.tree = [-1] | |
self.length = 0 | |
def insert(self,value): | |
self.tree.append(value) | |
print("Inserted",value) | |
self.length += 1 | |
if self.length == 1: | |
return |
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> | |
#include <algorithm> | |
#include <cmath> | |
using namespace std; | |
void construct(int tree[],int arr[],int index,int start,int end){ | |
int mid,max1; | |
if(start == end){ | |
tree[index] = arr[start]; | |
} |
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
class node(): | |
def __init__(self,val): | |
self.left = None | |
self.right = None | |
self.value = val | |
def insert(root,val): | |
if root is None: | |
root = node(val) | |
else: |
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
/* Lucky numbers are numbers with atleast three distinct prime factors | |
The 1000th lucky number itself lies within 3000 | |
So let's generate primes less than 3000 */ | |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
#include <cmath> | |
using namespace std; | |