没记错的话这其实是一个DP的解法。但是提交后,给出Memory Limit Exceeded错误,那就是O(n)的空间复杂度不符合要求了。于是给出了下面的空间复杂度为常量的code: 1 public boolean canWinNim2(int stoneCount) { 2 boolean canWin = false; 3 4 if(stoneCount<=0) { 5 System.out.println("illegal input...
没记错的话这其实是一个DP的解法。但是提交后,给出Memory Limit Exceeded错误,那就是O(n)的空间复杂度不符合要求了。于是给出了下面的空间复杂度为常量的code: 1publicbooleancanWinNim2(intstoneCount) {2booleancanWin =false;34if(stoneCount<=0) {5System.out.println("illegal input");6returnfalse;7}...
359 Logger Rate Limiter.py 360 Sort Transformed Array.py 361 Bomb Enemy.py 362 Design Hit Counter.py 364 Nested List Weight Sum II.py 365 Water and Jug Problem.py 366 Find Leaves of Binary Tree.py 367 Valid Perfect Square.py 368 Largest Divisible Subset.py 369 Plus One Lin...
没记错的话这其实是一个DP的解法。但是提交后,给出Memory Limit Exceeded错误,那就是O(n)的空间复杂度不符合要求了。于是给出了下面的空间复杂度为常量的code: 1 public boolean canWinNim2(int stoneCount) { 2 boolean canWin = false; 3 4 if(stoneCount<=0) { 5 System.out.println("illegal input...