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 tc; | |
cin>>tc; | |
while(tc--) //test cases | |
{ | |
int N; | |
cin>>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
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
//code | |
int tc; | |
cin>>tc; | |
while(tc--) | |
{ | |
int n,l,r; |
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 <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
//code | |
int tc; | |
cin>>tc; | |
while(tc--) | |
{ | |
int n,k; |
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
// C++ linear time solution for stock span problem | |
#include <iostream> | |
#include <stack> | |
using namespace std; | |
// A stack based efficient method to calculate | |
// stock span values | |
void calculateSpan(int price[], int n, int S[]) | |
{ | |
// Create a stack and push index of first |
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
// C++ program to demonstrate auto-complete feature | |
// using Trie data structure. | |
#include<bits/stdc++.h> | |
using namespace std; | |
// Alphabet size (# of symbols) | |
#define ALPHABET_SIZE (26) | |
// Converts key current character into index | |
// use only 'a' through 'z' and lower case |
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
// { Driver Code Starts | |
#include <bits/stdc++.h> | |
using namespace std; | |
// } Driver Code Ends | |
/* Function to check if the given graph contains cycle | |
* V: number of vertices | |
* adj[]: representation of graph | |
*/ |
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
// A Dynamic Programming based C++ program to find minimum | |
// number operations to convert str1 to str2 | |
#include <bits/stdc++.h> | |
using namespace std; | |
// Utility function to find the minimum of three numbers | |
int min(int x, int y, int z) | |
{ | |
return min(min(x, y), z); | |
} |
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; | |
void findMajority(int arr[], int n) | |
{ | |
// Number of bits in the integer | |
int len = sizeof(int) * 8; | |
// Variable to calculate majority element | |
int number = 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
/* C++ Program for finding out | |
majority element in an array */ | |
#include <bits/stdc++.h> | |
using namespace std; | |
/* Function to find the candidate for Majority */ | |
int findCandidate(int a[], int size) | |
{ | |
int maj_index = 0, count = 1; | |
for (int i = 1; i < size; 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
// Program to find minimum number of platforms | |
// required on a railway station | |
#include<iostream> | |
#include<algorithm> | |
using namespace std; | |
// Returns minimum number of platforms reqquired | |
int findPlatform(int arr[], int dep[], int n) | |
{ |
OlderNewer