No there is no shortcut possible in general. There may be specific shortcuts but not worth learning.If there was indeed one ,dynamic programming would not be required and the shortcut would have been used.Better practice the conditions its pretty easy itself .