Skip to content

leetcode questions and java code implement

Notifications You must be signed in to change notification settings

jessica0530/leetcode

This branch is 16 commits ahead of zicat/leetcode:master.

Repository files navigation

Analyzing leetcode questions and Giving java code

Question 1: Max Unrepeated Substring

Description: Input a string, output the max substring that not contains repeated chars.
Solution: Sliding window.

  1. Define two points left-point&&right-point than point to the beginning of the string.
  2. Using right-point to foreach string, add each char to the set.
  3. Before add the char to the set, checking whether it already exist in the set.
  4. If the char in the set, recompute the max-size-substring and removing all chars in the set that is font the char and left-point point to the char + 1.
  5. After the end of foreach, recompute the max-size-substring again avoiding all chars are different.

Code: StringUtils.maxUnrepeatedSubString(String s)

About

leetcode questions and java code implement

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%