String rotation . Given two strings s1 and s2, Please write code check s2 Is it s1 Rotating （ such as ,waterbottle yes erbottlewat Rotated string ）.

Examples 1

input ：s1 = "waterbottle", s2 = "erbottlewat"
output ：True

Examples 2

input ：s1 = "aa", "aba"
output ：False
func isFlipedString(s1 string, s2 string) bool { return len(s1) == len(s2) &&
strings.Contains(s2 + s2, s1) }
Write code , Remove duplicate nodes from unsorted linked list . Keep the first node .

Examples 1:
input ：[1, 2, 3, 3, 2, 1] output ：[1, 2, 3]
Delete all the same nodes after each node .
/** * Definition for singly-linked list. * type ListNode struct { * Val int *
Next *ListNode * } */ func removeDuplicateNodes(head *ListNode) *ListNode { ;
for temp:=head;temp!=nil;temp=temp.Next{ num:=temp.Val; for i:=temp;i!=nil &&
i.Next!=nil;{ if(i.Next.Val==num){ i.Next=i.Next.Next; }else{ i=i.Next } } }
Implement an algorithm , Find the penultimate in a one-way linked list k Nodes . Returns the value of the node .

be careful ： This question is slightly changed from the original one

Examples ：

input ： 1->2->3->4->5 and k = 2
output ： 4
/** * Definition for singly-linked list. * type ListNode struct { * Val int *
Next *ListNode * } */ func kthToLast(head *ListNode, k int) int { length:=0;
for temp:=head;temp!=nil;temp=temp.Next{ length++; } for i:=length-k;i>0;i--{
Implement an algorithm , Delete a node in the middle of a one-way linked list （ That is not the first or last node ）, Suppose you can only access the node .

Examples ：

input ： One way linked list a->b->c->d->e->f Node in c
result ： No data is returned , But the linked list becomes a->b->d->e->f

thinking ： Change the value to the value of the next node , And delete the next node .
/** * Definition for singly-linked list. * type ListNode struct { * Val int *
Next *ListNode * } */ func deleteNode(node *ListNode) { node.Val=node.Next.Val;
node.Next=node.Next.Next; }

Technology
Daily Recommendation