Skip to content
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
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Ignore build and output directories
bin/
out/
build/
target/
release/
dist/
.idea/
.vscode/
*.suo
*.user
*.sdf

# Ignore compiler-generated files
*.o
*.out
*.class
*.jar
*.exe
*.dll

# Ignore text editor/IDE-specific files
*.swo
*.swp
*.swn
*.suo
*.user
*.log
*.orig

# Ignore OS-generated files
.DS_Store
Thumbs.db
Binary file removed C++/RadixSort.exe
Binary file not shown.
58 changes: 58 additions & 0 deletions C++/StackUsingQueue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <iostream>
#include <queue>

using namespace std;

class StackUsingQueues {
public:
void push(int x) {
tempQueue.push(x);
while (!mainQueue.empty()) {
tempQueue.push(mainQueue.front());
mainQueue.pop();
}

// Swap the main and temporary queues (main = temp, temp = empty)
mainQueue.swap(tempQueue);
}

void pop() {
mainQueue.pop();
}

int top() {
return mainQueue.front();
}

bool empty() {
return mainQueue.empty();
}

private:
queue<int> mainQueue;
queue<int> tempQueue;
};

int main() {

StackUsingQueues stack;

stack.push(1);
stack.push(2);
stack.push(3);
stack.push(4);
stack.push(5);

cout << "Top element: " << stack.top() << endl; // Output: 5

stack.pop();

cout << "Top element after pop: " << stack.top() << endl; // Output: 4

stack.push(6);

cout << "Top element: " << stack.top() << endl; // Output: 6

system("pause");
return 0;
}
Binary file removed C++/TowerofHanoi
Binary file not shown.
Binary file removed C++/bubbleSort.exe
Binary file not shown.
Binary file removed C++/circularQueue
Binary file not shown.
Binary file removed C++/reverseLinkedList
Binary file not shown.
Binary file removed C++/stackOperations
Binary file not shown.