# Insert value to linked list ```cpp= struct ListNode { int val; struct ListNode* next; } struct ListNode* creat_linked_list(vector<int> &vec) { struct ListNode *head = new ListNode; struct ListNode *current; head->val = vec[0]; head->next = NULL; current = head; for(int i = 1; i < vec.size(); i++) { struct ListNode *node = new ListNode; node->val = vec[i]; node->next = NULL; current->next = node; current = current->next; } return head; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up