This file contains 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 <stack> | |
bool isBalanced(std::string sequence) { | |
std::stack<char> stk; | |
for (int i = 0; i < sequence.size(); i++) { | |
if (sequence[i] == '[' || sequence[i] == '{' || sequence[i] == '(') | |
stk.push(sequence[i]); | |
else if (sequence[i] == ']' || sequence[i] == '}' || sequence[i] == ')') { | |
if (stk.empty()) return false; |
This file contains 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
// Author: Aakriti Sharma | |
// Date: 3rd August 2020 | |
#include<iostream> | |
#include<string> | |
#include<algorithm> | |
// Funtion to compare if the number of digits are equal or not | |
// if not then add string of zeros in from of the smaller number | |
void addZeros(std::string* num1, std::string* num2) { |
This file contains 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> | |
void printArray(int arr[], size_t size) { | |
// Function to print the array of size arr | |
for (int i = 0; i < size; i++) { | |
std::cout << arr[i] << std::endl; | |
} | |
} | |
int* insertElement(int arr[], size_t size, int ele, int index) { // Note: size is the size of argument arr[] |