DEV Community 👩‍💻👨‍💻

ZeeshanAli-0704
ZeeshanAli-0704

Posted on

Length of the Longest Alphabetical Continuous Substring

var longestContinuousSubstring = function(s) {
let n = s.length, count = 1, ans = 1;
  for (let i = 1; i < n; i++) {
    let currCharcode = s.charCodeAt(i);
    let prevCharcode = s.charCodeAt(i - 1);
    if (currCharcode - prevCharcode === 1) count++;
    else count = 1;
    ans = Math.max(ans, count);
  }
  return ans;
};

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Classic DEV Post from 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!