Mr.karthik.p
BAN USER@eugene my bad we can do it O(nlogn) . find the change index and consider second array as min heap and whenever the head element of array is less swap with the index of the first array , increment the count of index of first array and heapify the second array.
 Mr.karthik.p March 08, 2013we can do it O(n) . The given input is a two sorted array merged together . We just need to find the index of an element which has a condition (array[index1] < array[index] ) && (array[index] > array[index+1]) . Then just a simple merge will do the job
 Mr.karthik.p March 08, 2013you cant solve it in linear time ..it will O(n^2) for 1D array .
 Mr.karthik.p March 07, 2013public static void findKthElement(Tree node , int k)
{
if(node == null)
{
System.out.println("TREE NULL");
return;
}
Stack<Tree> stack = new Stack<>();
int n =0 ;
while(true)
{
while(node != null)
{
stack.add(node);
node = node.right;
}
if(stack.isEmpty())
{
System.out.println("ELEMENT COUNT OUT OF RANGE");
return;
}
node = stack.pop();
n++;
if(n == k)
{
System.out.println("THE KTh ELEMENT: "+ node.getValue());
return;
}
node = node.left;
}
}
How do you check if a word is valid or not ?? meaning how to validated if "dad" , "daddy" is valid word ?
 Mr.karthik.p March 06, 2013Inorder traversal with min and max element as input
public void printBetweenNodes(Tree node , int min , int max)
{
if(node == null)
return;
printBetweenNode(node.left,min,max);
if(node.data >= min && node.data <= max)
syso(node.data);
printBetweenNode(node.right,min,max);
}
public static void printMatrix(int[][] array)
{
if(array == null)
{
return ;
}
int rowCount = array.length;
int columnCount = array[1].length;
for(int i=0 ;i<rowCount ; i++)
{
int k =0;
int v = i;
while(v!= 1 && k <= i)
{
System.out.print(array[k][v]);
v;
k++;
}
System.out.println();
}
for(int i = 1 ; i< columnCount ; i++)
{
int k = i;
int v = rowCount1 ;
while(k<rowCount)
{
System.out.print(array[k][v]);
k++;
v;
}
System.out.println();
}
}

Mr.karthik.p
February 09, 2013 set.contains(val) is O(n) operation so your complexity turns out to be O(n*n)
 Mr.karthik.p February 08, 2013Is it a single or double link list ? . What about the values of link list are they sorted or unsorted ? .
 Mr.karthik.p February 01, 2013Open Chat in New Window
Here we need to find the max product not the sum ..so i don't think u need to skip the negative numbers.
 Mr.karthik.p March 10, 2013