P

@praveen11

maximum subarray

Python
4 years ago
def maxsubarraysum(l): max = -1 curr_max = 0 start=0 end=0 x=[] for i in range(len(l)): curr_max = curr_max + l[i] if(max < curr_max): max = curr_max

max and mini values of a integer

Python
4 years ago
import sys MIN_INT = -sys.maxsize - 1 #minimum integer value print(MIN_INT) MAX_INT = sys.maxsize #maximum integer value print(MAX_INT)

sum of digits of number different one

C++
4 years ago
#include <iostream> using namespace std; int main() { int n; cin>>n; int a[10],i=0,len; while(n>0){ a[i]=n%10; n=n/10; i++;

python quiz Question

Python
4 years ago
x=2 for i in range(i<2): i=i+3 print(i)

check whether given n is power of given k or not

C++
4 years ago
/* we will be given a number "n" and "k" value we have to check whether the n can be written as power of k example : n=27 and k=3 27 = 3^3 so the output will be true */ #include<iostream>

increasing sequence of n digits

C++
4 years ago
#include<iostream> using namespace std; void increasingseq(int first,string last,int n){ if(n==0){ cout<<last<<" "; return; } else{ for(int i=first;i<=9;i++){

mirror of bst

C++
4 years ago
#include <iostream> using namespace std; // Data structure to store a binary tree node struct Node { int data; Node *left, *right;

height of a bst

C++
4 years ago
#include <iostream> using namespace std; class bst{ public: int data; bst *left,*right; bst(int val){ data = val; left = right = NULL;

right view of bst

C++
4 years ago
#include <iostream> using namespace std; class bst{ public: int data; bst *left,*right; bst(int val){ data = val; left = right = NULL;

left view of a bst

C++
4 years ago
#include <iostream> using namespace std; class bst{ public: int data; bst *left,*right; bst(int val){ data = val; left = right = NULL;

implementing a bst

C++
4 years ago
#include <iostream> using namespace std; class bst{ public: int data; bst *left, *right; bst(int value){ data = value;

stack inplementation using array

C++
4 years ago
#include <iostream> using namespace std; #define max 100 int s[max],top=-1,n; void create(){ int x; cin>>n; for(int i=0;i<n;i++){ cin>>x;

insertion at req position

C++
4 years ago
#include <iostream> using namespace std; class node{ public: int data; node* next; }; node* head;

length of a linked list

C++
4 years ago
#include <iostream> using namespace std; class node{ public: int data; node* next; }; node* head;

Linked list insertion at beginning

C++
4 years ago
#include <iostream> using namespace std; class node{ public: int data; node* next; }; node* head; node* tail;

creating a linked list

C++
4 years ago
#include <iostream> using namespace std; class node{ public: int data; node* next; }; node* head;

mirrored pascals triangle

Python
4 years ago
def pattern(star,space,n): if(star==n): for i in range(star): print("*",end=" ") print() half(star-1,space+1,n) return 0 else: for i in range(space): print(" ",end=" ")

right rotation of an array python

Python
4 years ago
l=[int(i) for i in input().split()] k=int(input()) rl=[] for i in range((len(l)-k),len(l)): rl.append(l[i]) for i in range((len(l)-k)): rl.append(l[i]) print(rl)

print the series using recursion

Python
4 years ago
def prints(n,k): if(n<=0): print(n) else: print(n) prints(n-k,k) print(n) n,k=map(int,input().split()) prints(n,k)

print the series

Python
4 years ago
""" 10 5 0 -5 0 5 10 print the above series when n=10 k=5 """ n=int(input()) k=int(input()) x=n print(x,end=" ")