Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly linked list should have two attributes: val and next. valis the value of the current node, and next is a pointer…
数据结构的题,从网上找到的实现方式,先记录下来. class MyLinkedList { public: /** Initialize your data structure here. */ MyLinkedList() { LinkedList = ; } ListNode *LinkedList; /** Get the value of the index-th node in the linked list. If the index is invalid, return -1. *…