Compare commits
7 Commits
61f2db0b72
...
486c2e2ebf
| Author | SHA1 | Date |
|---|---|---|
|
|
486c2e2ebf | |
|
|
e87aebda39 | |
|
|
4f5b97f255 | |
|
|
91dc6e535c | |
|
|
4f8f925c39 | |
|
|
4bbeb20508 | |
|
|
0f79392ef4 |
|
|
@ -56,4 +56,4 @@ hs_err_pid*
|
|||
replay_pid*
|
||||
|
||||
>>>>>>> gitea/master
|
||||
idea/
|
||||
.idea/
|
||||
|
|
@ -5,7 +5,10 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="45f625e1-36c7-4942-8f7c-ba3ebe9a7d53" name="变更" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/src/Solution.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Solution.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/solution/test.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Solution.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/solution/Solution.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
@ -47,6 +50,26 @@
|
|||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager">
|
||||
<configuration name="test" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="solution.test" />
|
||||
<module name="Solution" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="solution.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="应用程序.test" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
|
|
@ -55,11 +78,22 @@
|
|||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1693822719192</updated>
|
||||
<workItem from="1693822720224" duration="1148000" />
|
||||
<workItem from="1693822720224" duration="5742000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/solution/test.java</url>
|
||||
<line>36</line>
|
||||
<option name="timeStamp" value="3" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
package solution;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package solution;
|
||||
|
||||
|
||||
public class test {
|
||||
public static void main(String[] args) {
|
||||
String s = "abcabcbb";
|
||||
Character a = 'a';
|
||||
// int length = lengthOfLongestSubstring(s);
|
||||
// System.out.println(isInString(a,));
|
||||
|
||||
}
|
||||
|
||||
public static int lengthOfLongestSubstring(String s) {
|
||||
StringBuilder longestString = new StringBuilder();
|
||||
StringBuilder lastMaxString = new StringBuilder();
|
||||
if (s != null){
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char temp = s.charAt(i);
|
||||
if (i == 0){
|
||||
continue;
|
||||
}
|
||||
Character prChar = s.charAt(i-1);
|
||||
if (prChar != temp){
|
||||
boolean in = isInString(temp,longestString);
|
||||
if (!in){
|
||||
lastMaxString.append(temp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return longestString.length();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean isInString(Character a,StringBuilder b){
|
||||
if (b != null) {
|
||||
for (int i = 0; i < b.length(); i++) {
|
||||
Character temp = b.charAt(i);
|
||||
if (temp == a) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue