mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-25 03:08:54 +08:00
Add cpp codes for the chapter
computational complexity, sorting, searching.
This commit is contained in:
@ -25,7 +25,7 @@ struct ListNode {
|
||||
* @param list
|
||||
* @return ListNode*
|
||||
*/
|
||||
ListNode* vectorToLinkedList(vector<int> list) {
|
||||
ListNode* vectorToLinkedList(vector<int>& list) {
|
||||
ListNode *dum = new ListNode(0);
|
||||
ListNode *head = dum;
|
||||
for (int val : list) {
|
||||
|
@ -23,7 +23,7 @@ struct TreeNode {
|
||||
* @param list
|
||||
* @return TreeNode*
|
||||
*/
|
||||
TreeNode* vectorToTree(vector<int> list) {
|
||||
TreeNode* vectorToTree(vector<int>& list) {
|
||||
TreeNode *root = new TreeNode(list[0]);
|
||||
queue<TreeNode*> que;
|
||||
que.emplace(root);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <set>
|
||||
#include <random>
|
||||
|
||||
#include "ListNode.hpp"
|
||||
#include "TreeNode.hpp"
|
||||
|
Reference in New Issue
Block a user