hopebasedcoder
BAN USERNo recursion
- hopebasedcoder August 22, 2009igore the prev comment
- hopebasedcoder August 08, 2009I think node rev always points to the same element (head)and it doesn't move in the call stack
- hopebasedcoder August 08, 2009Question is not about retaining one node out of the duplicates, but deleting the entire duplicate nodes.
And
The 2 spl cases:
root is to be deleted
last element is to be deleted
all this missing in the above solution
The question asks to retain single space, not completely rip them off
void Squeeze(char *str){
if(str==NULL)
return;
int i=0,index=0;
while(str[i]!='\0'){
while(str[i]!=' ' && str[i]!='\0'){
str[index]=str[i];
index++;i++;
}
str[index++]=str[i++];
while(str[i]==' ' && str[i]!= '\0')
i++;
}
str[index]='\0';
}
Iterate through the sorted list starting from head1. at each step compute the difference of the current value with the previous node value. if the value is -ve proceed till the end. If the difference is positive, then the list is not sorted; break and return false. O(n) may be!
- hopebasedcoder April 29, 2009
while every prime number will satisfy 6k+1 or 6k-1 ,other non prime numbers might also satisfy the condition. for example 25 can be represented as 6(4)+1.
- hopebasedcoder August 25, 2009How can this condition be used to find n the prime number?