Skip to content

Commit 2a84916

Browse files
committed
feat: add cpp solution to lc problem: No.0332
1 parent 78245a3 commit 2a84916

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

solution/0300-0399/0332.Reconstruct Itinerary/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ class Solution {
103103
```cpp
104104
class Solution {
105105
public:
106-
std::vector<std::string> findItinerary(std::vector<std::vector<std::string>> &tickets) {
107-
std::unordered_map<std::string, std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>>> g;
108-
std::vector<std::string> ret;
106+
vector<string> findItinerary(vector<vector<string>>& tickets) {
107+
unordered_map<string, priority_queue<string, vector<string>, greater<string>>> g;
108+
vector<string> ret;
109109

110110
// Initialize the graph
111-
for (const auto &t : tickets) {
111+
for (const auto& t : tickets) {
112112
g[t[0]].push(t[1]);
113113
}
114114

@@ -119,7 +119,7 @@ public:
119119
return ret;
120120
}
121121

122-
void findItineraryInner(std::unordered_map<std::string, std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>>> &g, std::vector<std::string> &ret, std::string cur) {
122+
void findItineraryInner(unordered_map<string, priority_queue<string, vector<string>, greater<string>>>& g, vector<string>& ret, string cur) {
123123
if (g.count(cur) == 0) {
124124
// This is the end point
125125
ret.push_back(cur);

solution/0300-0399/0332.Reconstruct Itinerary/README_EN.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ class Solution {
9393
```cpp
9494
class Solution {
9595
public:
96-
std::vector<std::string> findItinerary(std::vector<std::vector<std::string>> &tickets) {
97-
std::unordered_map<std::string, std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>>> g;
98-
std::vector<std::string> ret;
96+
vector<string> findItinerary(vector<vector<string>>& tickets) {
97+
unordered_map<string, priority_queue<string, vector<string>, greater<string>>> g;
98+
vector<string> ret;
9999

100100
// Initialize the graph
101-
for (const auto &t : tickets) {
101+
for (const auto& t : tickets) {
102102
g[t[0]].push(t[1]);
103103
}
104104

@@ -109,7 +109,7 @@ public:
109109
return ret;
110110
}
111111

112-
void findItineraryInner(std::unordered_map<std::string, std::priority_queue<std::string, std::vector<std::string>, std::greater<std::string>>> &g, std::vector<std::string> &ret, std::string cur) {
112+
void findItineraryInner(unordered_map<string, priority_queue<string, vector<string>, greater<string>>>& g, vector<string>& ret, string cur) {
113113
if (g.count(cur) == 0) {
114114
// This is the end point
115115
ret.push_back(cur);

0 commit comments

Comments
 (0)