Professional Documents
Culture Documents
Worksheet 1.3
Worksheet 1.3
Worksheet 1.3
problem 1 code:
#include <bits/stdc++.h>
class SinglyLinkedListNode {
public:
int data;
SinglyLinkedListNode *next;
SinglyLinkedListNode(int node_data) {
this->data = node_data;
this->next = nullptr;
}
};
class SinglyLinkedList {
public:
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
SinglyLinkedList() {
this->head = nullptr;
this->tail = nullptr;
}
if (!this->head) {
this->head = node;
} else {
this->tail->next = node;
}
this->tail = node;
}
};
node = node->next;
if (node) {
fout << sep;
}
}
}
/*
* Complete the 'reverse' function below.
*
* The function is expected to return an INTEGER_SINGLY_LINKED_LIST.
* The function accepts INTEGER_SINGLY_LINKED_LIST llist as parameter.
*/
/*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
while(current) {
SinglyLinkedListNode* next = current->next;
current->next = prev;
prev = current;
current = next;
}
return prev;
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string tests_temp;
getline(cin, tests_temp);
int tests = stoi(ltrim(rtrim(tests_temp)));
string llist_count_temp;
getline(cin, llist_count_temp);
llist->insert_node(llist_item);
}
fout.close();
return 0;
}
s.erase(
s.begin(),
find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))
);
return s;
}
s.erase(
find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(),
s.end()
);
return s;
}
3. Result/Output/Writing Summary:
problem 1:
Evaluation Grid: