Subrahmanyam
BAN USERAccording to the question all the coins are mixed and they look identical... how could you divide them into different sets as xxx,yyy,A and B??
- Subrahmanyam April 17, 2013Deleting a row in Dept will have effect on the employee table.... we have to mention on delete for that..
- Subrahmanyam April 17, 2013Inserting a new row into DEPARTMENT with a primary key that is not the value of the DEPT column of any row in EMPLOYEE
- Subrahmanyam April 17, 2013What if I did pop() and then min ??
Our algo will produce erroneous output . Am I right ?
@Jack : I didnt get you exactly. However I guess we wont be able to find the min value in O(1) time complexity.
@mr:
The problem statement is find the minimum value in a stack .. no that how to maintain a min value while creating a stack. For that matter with every structure you can keep track of the min values .. need not be stack.
@Victor:
even if you encapsulate the things running times wont change from the perspective of algorithmics.. so I guess thats not going to help us.
public MyCircularDoubleLinkedList union(MyCircularDoubleLinkedList list1,MyCircularDoubleLinkedList list2){
MyCircularDoubleLinkedListNode temp1,temp2,temp3;
temp1=list1.headNode.prev;
//System.out.println("\n temp1 value"+temp1.getValue());
temp2=list2.headNode.prev;
//System.out.println("\n temp2 value"+temp2.getValue());
//System.out.println("\n head2s next value"+list2.headNode.getNext().getValue());
temp3=list2.headNode.next;
//System.out.println("\n temp3 value"+temp3.getValue());
temp1.next=temp3;
temp3.prev=temp1;
temp2.next=list1.headNode;
list1.headNode.prev=temp2;
return list1;
}
It looks like we can use doubly linked circular linked list to represent the problem.
Then we can perform this operation in O(1) whatever be the size of the two given sets.
Ofcourse I am not taking space constraints into consideration.
awesome logic :)
- Subrahmanyam April 17, 2013