Definition of substring
A sequence of consecutive characters within a larger string.
In other words, it is a smaller string that is written without changing the order of the characters selected from the original string or skipping any characters in the middle.
Example of substrings
Substrings of "abc": "", "a", "b", "c", "ab", "bc", "abc"
In mathematics, the empty string ("") is also considered a substring.
However, in programming problems, whitespace characters are usually not considered as substrings.
How to find substrings
Example
public static int countSubstring(String str) {
int n = str.length();
return n*(n+1)/2;
}
댓글 없음:
댓글 쓰기