We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is Python. The logic is simple - take all possible substrings, split them into two sets according to starting letter, then sum elements in sets.
All possible substrings are string of lenght 1, then strings of length 2 etc. i above is an iterator for that lenght.
And then comes a little optimization - if you know the starting letter, you can add all substrings of different length that start with this letter. It will be len(s) - i
Day 6: Multiple Linear Regression: Predicting House Prices
You are viewing a single comment's thread. Return to all comments →
This is Python. The logic is simple - take all possible substrings, split them into two sets according to starting letter, then sum elements in sets.
All possible substrings are string of lenght 1, then strings of length 2 etc.
iabove is an iterator for that lenght.And then comes a little optimization - if you know the starting letter, you can add all substrings of different length that start with this letter. It will be
len(s) - i