Pls help me to debug the code
@Senjuti256,
You are greedily choosing between first and last element of segment, but rather you have to consider both possibilities and recursively find which is better.
why can’t we use greedy technique?
i have tried to solve recursively but still I am getting segmentation fault.Pls help me to debug the code.
@Senjuti256,
Segfault is because you are accessing an invalid index. You are not making sure you don’t go out of bounds. For eg i+2 or j-1 could go out of bound in recursive call, and you don’t have any base case to handle this.