seeing your solution makes me want to refactor mine(which is pretty inefficent. I didn't have an idea nor the time to write a better one), but I want to precieve my development. and thanks for the magnifecent idea, never thought of using a Map, am really lacking in terms of algorithmic thinking.
It's because numbers.size() returns a size_t (unsigned int), so when the array is empty numbers.size() - 1 is a large unsigned number (0xFFFFFFFF). Then the for loop executes that number of times and an invalid array index is used.
Well if you got a SIGSEGV (signal: segmentation violation), then it's likely that your program tried to access a spot in the vector numbers that was out of bounds. This might be because:
a) you used ++i in the for loop control instead of i++
or
b) you didn't include the -1 in the for loop control (needed to stay in bounds when grabbing [i+1] inside the loop)
Hello! Recently, I tried to solve the problem with the similar method, but it told me "Process exited prematurely with a SIGSEGV signal. "
So, if you know the reason, could you please tell me? Thanks.
seeing your solution makes me want to refactor mine(which is pretty inefficent. I didn't have an idea nor the time to write a better one), but I want to precieve my development. and thanks for the magnifecent idea, never thought of using a Map, am really lacking in terms of algorithmic thinking.
This comment is hidden because it contains spoiler information about the solution
It's because numbers.size() returns a size_t (unsigned int), so when the array is empty numbers.size() - 1 is a large unsigned number (0xFFFFFFFF). Then the for loop executes that number of times and an invalid array index is used.
How about using a HashSet instead of a Map? Also it is only a small sized byte array, so will it make any difference?
Thanks ;-)
Quite a fun challenge for those looking to understand Programming Language Concepts, Parsing, and Tree building!
Nice work.
This comment is hidden because it contains spoiler information about the solution
what is replacement for ALPHABET.indexOf(...)?
This comment is hidden because it contains spoiler information about the solution
still does not work. using exactly what you did and still having a segmentation fault. makes no sense.
I'm surprised not many people forwent importing re,
My solution implements a recursive algorithm that solves from the inside out.
I would like to know the benefits in using regex vs recursive decent for parsing problems like this one
Well if you got a SIGSEGV (signal: segmentation violation), then it's likely that your program tried to access a spot in the vector numbers that was out of bounds. This might be because:
a) you used ++i in the for loop control instead of i++
or
b) you didn't include the -1 in the for loop control (needed to stay in bounds when grabbing [i+1] inside the loop)
Hope this was helpful!
Hello! Recently, I tried to solve the problem with the similar method, but it told me "Process exited prematurely with a SIGSEGV signal. "
So, if you know the reason, could you please tell me? Thanks.
I feel like tendency of majority of voted best solution is about minimum number of lines to finish the task and not about efficiency.
This comment is hidden because it contains spoiler information about the solution
Loading more items...