Created
April 20, 2020 02:07
-
-
Save ABHIINAV12/29507e041c4a45cf5d0164e3bfd56284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int minStartValue(vector<int>& nums) { | |
int ret=1; | |
int mn=1; | |
for(auto it : nums){ | |
ret+=it; | |
mn=min(mn,ret); | |
} | |
if(mn<1){ | |
ret=2-mn; | |
}else{ | |
ret=1; | |
} | |
return ret; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment