ScanLeft | Scala | Concise Solution with Explanation
We would use scanLeft starting with initial value empty string("")\nNow we for Binary Operator op: (B, A) => B, we would provide substring function that would s
We would use scanLeft starting with initial value empty string("")\nNow we for Binary Operator op: (B, A) => B, we would provide substring function that would substring till it would find current character in previously calculated String, and we postfix the current character to current substring to start looking for further character.\n```\ndef lengthOfLongestSubstring(s: String): Int = {\n\ts.scanLeft("")((currStr: String, currChar: Char) => \n\tcurrStr.substring(1 + currStr.indexOf(currChar)) + currChar)\n\t// Up to this point we would get vector like this\n\t// Vector(, a, ab, abc, bca, cab, abc, cb, b)\n\t// now if we take max of length would get the answer\n\t.map(_.length)\n\t.reduce(Math.max)\n}\n```
['Scala']