Heramb
BAN USERfor a tree like
1
/ \
2 3
\ \
4 5
/
6
The above code fails.. as mentioned above the postion of
(node.left== null)
check should be as shown below
TreeNode ChangeOrder(TreeNode node){
TreeNode leftree= null, rightree = null;
if(node==null)
return null;
leftree = ChangeOrder(node.left);
rightree = ChangeOrder(node.right);
if(node.left==null)
return node;
node.right = leftree;
while(leftree.right!=null)
leftree = leftree.right;
leftree.right = rightree;
return node;
}
H1 is a nested hashmap. Its key is username and value is the H2 Hashmap.
and H2 has pagestring as key and day count as value.
What I am not understanding in this solution is, if we encounter the same pagestring more than once in a single day, will this algo ignore the day count? how to trace that on which date the day count has been increased?
int main(void)
{
int number,n,i=0,j=0,icount=0, jcount=0;
printf("Enter n : ");
scanf("%d",&n);
int arr[n][n];
number = n*n;
number -= 1;
while(number >= 0)
{
i = icount;
for(j=jcount;j<n-jcount;j++)
arr[i][j]= number--;
j--;
for(i=icount+1;i<n-icount;i++)
arr[i][j] = number--;
i--;
for(j=(j-1);j>=jcount;j--)
arr[i][j]=number--;
j++;
for(i=(n-icount-2);i>icount;i--)
arr[i][j]=number--;
icount++;
jcount++;
}
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf(" %d ", arr[i][j]);
}
return 0;
}
- Heramb January 17, 2014