×

# SUMTRIAN - Getting WA

 0 I submitted this answer for the question SUMTRIAN. But I am getting WA. The test cases provided are working. I also tried some cases on my own. All seem to be giving the right answer. Can someone please point out the error? Thanks! asked 25 Sep '13, 21:50 26●2●5●8 accept rate: 0%

 1 Your problem is on first line of function maxFromTop(). Because you have condition: if(i>n) return 0;  If I understand your code properly, variable i indicates rows. But rows are numbered from 0 to n-1 inclusive, so they don't obtain row number n. So you should end, when i>=n. if(i>=n) return 0;  Now the code should be correct. answered 25 Sep '13, 23:07 5★michal27 1.1k●2●10●17 accept rate: 13% Thanks a lot for sparing your time to find this silly error!! (25 Sep '13, 23:13) you're welcome :) (25 Sep '13, 23:31) michal275★
 0 When I add first test case at the end it returns 5, 9, 8 instead of expected 5, 9, 5... http://ideone.com/yQWiEq answered 25 Sep '13, 22:54 16.9k●49●115●225 accept rate: 11%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,671
×938
×280
×103
×47

question asked: 25 Sep '13, 21:50

question was seen: 1,730 times

last updated: 25 Sep '13, 23:31