'How do we model algorithms problems with math equations?

Mathematics has always been a prime tool for making abstract problems into tangible ones thus making their solution easier. let's take this problem from LeetCode:

Given a string s, find the length of the longest substring without repeating characters.

Example 1:

Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3.

Example 2:

Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1.

Is there a method to model this kind of problem or any problem with mathematic equations?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source