列表转链表,再双指针
class node:
def __init__(self, data):
self.val = data
self.next = None
class Solution:
def __init__(self):
self.li=[i for i in range(1,8)]
def get_ans(self,k):
self.head=node(self.li[0])
temp=self.head
for i in self.li[1:]:
i=node(i)
temp.next=i
temp=temp.next
left,right=self.head,self.head
for _ in range(k):
right=right.next
while right:
left=left.next
right=right.next
return left.val
if __name__=="__main__":
k=int(input())
ans=Solution()
print(ans.get_ans(k)) js