Skip to content

Added Data Structure Conversion #118

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

Merged
merged 2 commits into from
Jan 2, 2025
Merged
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
18 changes: 18 additions & 0 deletions public/consolidated/cpp.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
}
]
},
{
"categoryName": "Data Structure Conversion",
"snippets": [
{
"title": "Vector to Queue",
"description": "Convert vector into queue quickly",
"author": "mrityunjay2003",
"tags": [
"cpp",
"data structures",
"queue",
"vector"
],
"contributors": [],
"code": "#include<queue>\n#include<vector>\n#include<deque>\n\nstd::queue<int> vectorToQueue(const std::vector<int>& v) {\n return std::queue<int>(std::deque<int>(v.begin(), v.end()));\n}\n"
}
]
},
{
"categoryName": "Math And Numbers",
"snippets": [
Expand Down
16 changes: 16 additions & 0 deletions snippets/cpp/data-structure-conversion/vector-to-queue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Vector to Queue
description: Convert vector into queue quickly
tags: cpp, data structures,queue,vector
author: mrityunjay2003
---

```cpp
#include<queue>
#include<vector>
#include<deque>

std::queue<int> vectorToQueue(const std::vector<int>& v) {
return std::queue<int>(std::deque<int>(v.begin(), v.end()));
}
```
Loading