Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in Stack file #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"iostream": "cpp"
}
}
4 changes: 2 additions & 2 deletions CPP/Find_all_the_elements_that_appear_twice_in_an_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def findDuplicates(self, nums):
if not nums:
return []

result = []
result = [] # List to store duplicate numbers
for _, num in enumerate(nums):
index = abs(num)-1
if nums[index] < 0:
result.append(index+1)
nums[index]*=-1
return result
return result # Return the list of duplicates
16 changes: 8 additions & 8 deletions DSA/Stack.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#include <bits/stdc++.h>
using namespace std;

struct node
struct Node
{
char data;
node *next;
Node *next;
};

struct MyStack
{
node *top;
Node *top;
MyStack()
{
top = NULL;
}
void push(char value)
{
node *newnode = new node();
Node *newnode = new Node();
newnode->data = value;
newnode->next = top;
top = newnode;
}
bool isEmpty()
{
return top == NULL;
return top == nullptr;
}
char pop()
{
Expand All @@ -32,7 +32,7 @@ struct MyStack
cout << "UNDERFLOW !!!" << endl;
return '\0'; // Changed to '\0'
}
node *temp = top;
Node *temp = top;
char popValue = temp->data;
top = top->next;
delete temp;
Expand All @@ -56,7 +56,7 @@ bool isOperator(char ch)

int precedence(char op)
{
if (op == '+' || op == '-')
if (op == '+' || op == '-')
return 1;
else if (op == '*' || op == '/')
return 2;
Expand Down Expand Up @@ -205,7 +205,7 @@ int main()

do
{
cout << "-------------menu----------------" << endl;
cout << "------------- Menu -------------" << endl;
cout << "1. Convert Infix to Postfix" << endl;
cout << "2. Convert Infix to Prefix" << endl;
cout << "3. Evaluate Postfix Expression" << endl;
Expand Down