We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I was facing the same problem.I gave several attempts but the issue couldn't be solved. Can you please tell me how to define a loop for a set of array with so many elements as such... :)
Arrays: Left Rotation
You are viewing a single comment's thread. Return to all comments →
I was facing the same problem.I gave several attempts but the issue couldn't be solved. Can you please tell me how to define a loop for a set of array with so many elements as such... :)
In java8 the problem was in String; You have to use more efficient StringBuilder instead; And of couse use only one loop to iterate over array;
here is my code snippet:
Thnx
okay
okay
okay
okay
okay
okay
Better to use linked list, so no need to LOOP fully:
val z = LinkedList(a.toList()) for(i in 0 until n) z.addLast(z.pollFirst())
why it is not working if we are using same array to store modified array i.e. a[i]=a[i+k)%n]
include
void reverse(int *str,int length) { int start,end; for(start=0,end=length-1;start
} int main(){
}