gdsrinivasan
BAN USER- 0of 2 votes
AnswersRotating K times a Linked List
- gdsrinivasan in United States
Given: k=3
LinkedList: 10->20->30->40->50->60->70->80
Output:
Sry, I dont remember the exact output as the list was almost zigzag sorted like:
30->40->10->20->60->50->70->80
any possibles hunches for a valid qn...?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Linked Lists
Hi All,
How about adding the elements of Array1 into array2 and then sort the Array2 using quicksort..
Is this something good..?
Hi Anonymous,
Even I expected the output to be straightforward as you mentioned above, like
30->40->50->10->20
but this wasn't the case in the question. It was in random order like I mentioned in the question which made me little puzzled.
I think, perhaps we have to do multiple such rotations for K times to arrive at the solution..
The program crashes for this input......
int a[] = {221,9,3,3,5,5,5,7,7,8,8,8,3};
Hi,
Could someone explain me the significance of the variables used in the program...
int N=5; // what is N ?
int count=0; // What is count...?
void sumKN(int k, int n, int r) // and most chiefly on what is k,n,r..?
sumKN(1,6,3); // why is this 1, 6 ,3...? Where does this 6 came from...?
Slightly confusing for me and many Thanks in advance.
Hi... As per the input, the given arrays are not sorted.
- gdsrinivasan October 07, 2012