Question about my code

  • 0

    Below is my solution for this problem. When I try to print out the number of ways in the helper function, it shows the correct number. But I couldn't get that value returned. I changed my helper function from void to int and return it in the climbStairs function, but it still doesn't pass the test. Any suggestions on why my solution wouldn't work? Thanks
    0_1506878282114_Screenshot 2017-09-29 14.01.35.png

  • 0

    @syl read about passing by value vs reference?
    in context of c#, primitive types like int, string passed by value and lists/classes etc passed by reference(address).. even though ways is updated inside the Helper function, you are not passing it back to the calling function.. C# provides ref keyword to pass by reference which is a value type (there should be something similar in java)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.