Программы на C++. Форум разработчиков
-
Anonymous
Почему я получаю эту ошибку при попытке решить проблему 133 в LeetCode?
Сообщение
Anonymous »
Код: Выделить всё
/*
// Definition for a Node.
class Node {
public:
int val;
vector neighbors;
Node() {
val = 0;
neighbors = vector();
}
Node(int _val) {
val = _val;
neighbors = vector();
}
Node(int _val, vector _neighbors) {
val = _val;
neighbors = _neighbors;
}
};
*/
class Solution {
private:
void BreadthFirstSearch (struct Node* node) {
bool check[128] = { 0, };
queue buffer;
buffer.push (node);
while (!buffer.empty()) {
auto current = buffer.front(); buffer.pop();
if (check[current->val] == true) continue;
else check[current->val] = true;
cout val neighbors) {
buffer.push (element);
cout val val;
copyBuffer.push (clone);
while (!buffer.empty()) {
auto& current = buffer.front(); buffer.pop();
auto& destination = copyBuffer.front(); copyBuffer.pop();
if (check[current->val] == true) continue;
else check[current->val] = true;
// cout val val = element->val;
destination->neighbors.push_back (newNode);
copyBuffer.push (newNode);
}
}
BreadthFirstSearch (node); cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78733241/why-do-i-get-this-error-when-trying-to-solve-problem-133-on-leetcode[/url]
1736684396
Anonymous
[code]/*
// Definition for a Node.
class Node {
public:
int val;
vector neighbors;
Node() {
val = 0;
neighbors = vector();
}
Node(int _val) {
val = _val;
neighbors = vector();
}
Node(int _val, vector _neighbors) {
val = _val;
neighbors = _neighbors;
}
};
*/
class Solution {
private:
void BreadthFirstSearch (struct Node* node) {
bool check[128] = { 0, };
queue buffer;
buffer.push (node);
while (!buffer.empty()) {
auto current = buffer.front(); buffer.pop();
if (check[current->val] == true) continue;
else check[current->val] = true;
cout val neighbors) {
buffer.push (element);
cout val val;
copyBuffer.push (clone);
while (!buffer.empty()) {
auto& current = buffer.front(); buffer.pop();
auto& destination = copyBuffer.front(); copyBuffer.pop();
if (check[current->val] == true) continue;
else check[current->val] = true;
// cout val val = element->val;
destination->neighbors.push_back (newNode);
copyBuffer.push (newNode);
}
}
BreadthFirstSearch (node); cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78733241/why-do-i-get-this-error-when-trying-to-solve-problem-133-on-leetcode[/url]