here is my recursive solution for this problem.

```
`class Solution {
public:
bool wordBreak(string s, unordered_set<string> &dict) {
issegment=false;
wordBreak(s,0,dict);
return issegment;
}
void wordBreak(const string &s,int pos,unordered_set <string> &dict){
if(pos==s.size()) issegment=true;
if(issegment) return;
for(int i=pos;i<s.size();i++){
auto iter=dict.find(s.substr(pos,i-pos+1));
if(iter!=dict.end()){
wordBreak(s,i+1,dict);
}
}
}
private:
bool issegment;
};`
```

I want to know how to calculate the time complexity!

I know that T(n)=n+T(n-1)+.T(n-2)+...+T(1);

who can help me?