|
|
вернуться в форумwhy the tag for this problem is "data structures"? I do not argue, just I want to know. Thanks. Re: why the tag for this problem is "data structures"? Because it can be solved using data structure called "stack". Re: why the tag for this problem is "data structures"? Now I got it :) Thank you very much. Re: why the tag for this problem is "data structures"? Послано Flux 20 фев 2011 02:25 Stack<char> Stack = new Stack<char>(); foreach (char c in Console.ReadLine()) if (Stack.Count > 0 && Stack.Peek() == c) Stack.Pop(); else Stack.Push(c); foreach (char c in Stack.Reverse()) Console.Write(c); Because of this code. Re: why the tag for this problem is "data structures"? After AC i realized i used stack :) Re: why the tag for this problem is "data structures"? Cuz' String Or a Char array is a data structure and working with data structures actually means changing adding expanding etc. them :) Hope that'll help you Re: why the tag for this problem is "data structures"? Yes, and because choosing the right data structure makes the problem solvable, and choosing the wrong one results in TLE. I had a brain blockage and couldn't think of stacks here (it's been a long time since I used them). Trying to solve using, for example, STL vector or dequeue and erase() will result in TLE on the big input cases. I realized that since very many erase() operations may be performed, delete performance is critically important, so STL list came to the rescue and got AC. |
|
|