dce.sunil
BAN USEROne solution that came into my mind was to prepare a trie. If you get a string, insert into the trie. If you get the string again, delete the node from trie. At the end, we will left with only one string, which is the answer.
another is to get int[] for each string. and then simply xor. It does not include extra memory as well
RepSusanHonda, Analyst at A9
I meet with clients to negotiate terms and prices on sales agreements, draw up the contract, and ensure the documents ...
Repnormadyen99, Android Engineer at ABC TECH SUPPORT
I am the Directory Assistance Operator responsible for assisting the callers by making calls, supplying phone numbers, advising the on-call ...
RepAndreTmily, Area Sales Manager at Axiom Sources
A purchasing manager, also known as a purchasing director or supply manager, responsible for procuring goods and services for resale ...
RepAadenGarcia, Analyst at ADP
I have a knowledgeable professional librarian with more than 4 years of experience in the public library setting. I have ...
RepDorothySanders, Accountant at Amazon
Hello, I am an Engineering manager. I love my work. I also love to read news articles related to the ...
RepSusanBrown, Accountant at AMD
I am a resourceful and seasoned Screen Printing Machine Operator with a strong customer service record across a range of ...
RepAriasBitner, Systems developer at 247quickbookshelp
I am a Systems developer . My duties primarily revolve around building software by writing code, as well as modifying software ...
Solution is pretty simple. We ourself make things complex by not looking at the simple side of it.
- dce.sunil March 17, 20101.) Doubly linked list for queue.
2.) Keep max along with each node till that node.
Let say the queue is
2 ->8 ->6 ->9
struct{
int data
int max
struct * next
struct *prev
}
when 2 inserted, queue will be
(2,2)
when 8 inserted, queue will be
(2,2) -> (8,8)
when 6 inserted, queue will be
(2,2) -> (8,8) -> (6, 8)
when 9 inserted, queue will be
(2,2) -> (8,8) -> (6, 8) -> (9,9)
Here all operations are O(1)