Timeline for Checking the balanced parenthesis as asked in interview
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 17, 2016 at 14:11 | comment | added | njzk2 |
also, it crashes on ")"
|
|
Oct 17, 2016 at 11:13 | history | edited | Bruno Costa | CC BY-SA 3.0 |
deleted 379 characters in body
|
Oct 17, 2016 at 10:54 | comment | added | ilkkachu | Don't get me wrong, I'd be happy to see a better algorithm for checking the parenthesis, I'm just not convinced it can be done as easily as you make it sound. | |
Oct 17, 2016 at 10:53 | comment | added | ilkkachu | @BrunoCosta, I'm pretty sure that to check all the pairs of parenthesis, a stack is needed (to remember the order the different types of parens come up). I can't prove that formally, but there's a couple of questions on balanced parens under shown as "Related", all of them use a stack, so it doesn't seem that clear it can be done without. You stated first "can be made without memory footprint", but now it's "you guess"? That's not very convincing. (To me, it's less convincing than an almost working code with a single bug, but YMMV.) | |
Oct 17, 2016 at 10:31 | history | edited | Bruno Costa | CC BY-SA 3.0 |
added 17 characters in body
|
Oct 17, 2016 at 10:30 | comment | added | Bruno Costa | @ilkkachu I guess that instead of checking for any kind of parenthesis I need to search for opening ones. It doesn't really matter if the fix is easy or not. I only have to take into the account the behavior of the algorithm. Fixed my solution description, thanks. | |
Oct 17, 2016 at 10:27 | comment | added | ilkkachu | Also, you found one bug with a simple fix, and one trivial implementation detail (the fact that the main program printing the "Success" string isn't shown) and that's "far from being desirable"? | |
Oct 17, 2016 at 10:22 | comment | added | ilkkachu |
So how do you deal with nested parenthesis on the way out of the middle? say, how, exactly, would your algorithm check the string [({}{})something] ?
|
|
Oct 17, 2016 at 8:13 | history | edited | Bruno Costa | CC BY-SA 3.0 |
deleted 48 characters in body
|
Oct 17, 2016 at 8:05 | comment | added | Bruno Costa | @greybeard Does it? | |
Oct 17, 2016 at 7:58 | history | answered | Bruno Costa | CC BY-SA 3.0 |