wisdompeak / LeetCode

This repository contains the solutions and explanations to the algorithm problems on LeetCode. Only medium or above are included. All are written in C++/Python and implemented by myself. The problems attempted multiple times are labelled with hyperlinks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

115.Distinct-Subsequences

xymabinogi opened this issue · comments

https://github.com/wisdompeak/LeetCode/blob/master/Dynamic_Programming/115.Distinct-Subsequences/115.Distinct-Subsequences.cpp

现在新增的两个样例会导致overflow的问题。因为题中虽然保证了最终结果是INT_MAX内,但是不保证中间的结果也是如此。
可以直接改成unsigned long long, 或者用top down DP,避免产生一下无谓的中间状态。

谢谢提醒。在代码中加了个max cap,过了这几个case。