Skip to content

Instantly share code, notes, and snippets.

View Firoz-Thakur's full-sized avatar
❤️
Code Game

Firoz Kumar Firoz-Thakur

❤️
Code Game
  • SWE -1 at Navi || Ex Securonix
  • Banglore
View GitHub Profile
// A Stack based C++ program to find next
// greater element for all array elements.
#include <bits/stdc++.h>
using namespace std;
/* prints element and NGE pair for all
elements of arr[] of size n */
void printNGE(int arr[], int n) {
stack < int > s;
@Firoz-Thakur
Firoz-Thakur / BalancedParentheses.cpp
Created April 16, 2020 12:19 — forked from mycodeschool/BalancedParentheses.cpp
C++ Program to check for balanced parentheses in an expression using stack.
/*
C++ Program to check for balanced parentheses in an expression using stack.
Given an expression as string comprising of opening and closing characters
of parentheses - (), curly braces - {} and square brackets - [], we need to
check whether symbols are balanced or not.
*/
#include<iostream>
#include<stack>
#include<string>
using namespace std;
// 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