数组循环移位

12-31 7,415 views

题目:给定数组str[],循环左移m位。即如果str=”ABCDEF”,循环左移2位得到 “CDEFAB”。
算法:使用两个倒序,倒序AB得到BA,倒序CDEF得到FEDC,最后全部BAFEDC全部倒序CDEFAB。

Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For exa...

阅读全文

Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not ...

阅读全文

Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space...

阅读全文