algorithm - How to eliminate duplicates from a linked list of unicode characters, without using any extra memory -
"Find a recurring element in a linked list of Unicode characters. If a duplicate of a Unicode character / du is found Repeat that node and adjust the list. This barrier was not to use any extra memory. "
My answer:
Assume that the surrogate pair is not included in Unicode characters That i am using c #
i do not know how you do a du Plicate can search the character until you know the values of the previous node during the list, and additional memory (hash table) will be required to maintain the previous values.
Friends, can you think of any solution to this question? This is an interview question on one site, besides it is possible to solve it in O (n) time?
Is there an implementation here? Can you respond to it so that I can do better?
to remove public static zero (node head) {node current 1 = head; Node current 2; While (current 1! = Null) {current2 = current1; While (current 2! = Null) {if (current 2. next! = Null and current 1. data = current 2. next data) {node temp = current2.Next.Next; Current2 Next = temp; Current2 = current1; to continue; } Current 2 = Current 2 next; Break if (current 2 == faucet); } Current 1 = Current 1 next; Break if (current 1 == faucet); }}
For each element in the list, find and delete the list of that element < / P>
I will leave the implementation and other options for you.
Comments
Post a Comment