Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
class Solution { public: string s; int n; unordered_map
exist; int dp[2222]; int rec(int at) { if(at >= s.size()) { return 1; } if(dp[at] != -1) { return dp[at]; } int res = 0; string tmp = ""; for(int i = at; i < s.size(); i++) { tmp += s[i]; if(exist[tmp]) { res = max(res, rec(at + tmp.size())); } } return dp[at] = res; } int wordBreak(int n, string s, vector
&dictionary) { this->n = n; this->s = s; for(string s : dictionary) { exist[s] = true; } memset(dp, -1, sizeof dp); return rec(0); } };
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)