add q5/q7/q172

pull/6/head
yuanguangxin 5 years ago
parent fcc19618e9
commit b49321bf97

119
.gitignore vendored

@ -1,57 +1,4 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@ -124,3 +71,69 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
### Java template
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -0,0 +1,282 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="af7ffdf2-4ddc-4ed6-8222-60ed5acbc2ed" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/q5/f1/Solution.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/q5/f2/Solution.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/q7/f1/Solution.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/q7/f2/Solution.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Rocket.md" beforeDir="false" afterPath="$PROJECT_DIR$/Rocket.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/q172/f2/Solution.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/q172/f2/Solution.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DatabaseView">
<option name="SHOW_INTERMEDIATE" value="true" />
<option name="GROUP_DATA_SOURCES" value="true" />
<option name="GROUP_SCHEMA" value="true" />
<option name="GROUP_CONTENTS" value="false" />
<option name="SORT_POSITIONED" value="false" />
<option name="SHOW_EMPTY_GROUPS" value="false" />
<option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
<option name="HIDDEN_KINDS">
<set />
</option>
<expand />
<select />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IgnoredFileRootStore">
<option name="generatedRoots">
<set>
<option value="$PROJECT_DIR$/.idea" />
</set>
</option>
</component>
<component name="ProjectId" id="1VejAt63XWcMUQr7gJbMHyEoS6Q" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/etc/q1" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RecentsManager">
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="etc.ali.q2" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/etc/q1" />
<recent name="$PROJECT_DIR$/src/q206/f2" />
<recent name="$PROJECT_DIR$/src/q206/f1" />
</key>
</component>
<component name="RunManager" selected="Application.Solution (2)">
<configuration name="Main (1)" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="etc.ali.q4.Main" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="etc.ali.q4.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Solution (1)" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="q5.f1.Solution" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="q5.f1.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Solution (2)" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="q7.f2.Solution" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="q7.f2.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Solution" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="q5.f2.Solution" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="q5.f2.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Solution" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="q7.f1.Solution" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="q7.f1.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Solution" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="q1.f2.Solution" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="q1.f1.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Threads" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="etc.ali.q3.Threads" />
<module name="LeetCode" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="etc.ali.q3.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Solution (2)" />
<item itemvalue="Application.Solution (2)" />
<item itemvalue="Application.Solution" />
<item itemvalue="Application.Solution (1)" />
<item itemvalue="Application.Threads" />
</list>
</recent_temporary>
</component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="af7ffdf2-4ddc-4ed6-8222-60ed5acbc2ed" name="Default Changelist" comment="" />
<created>1577620314304</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1577620314304</updated>
<workItem from="1577620315866" duration="43562000" />
<workItem from="1577982884229" duration="21447000" />
<workItem from="1578127677834" duration="13618000" />
<workItem from="1578199845559" duration="13871000" />
<workItem from="1578487058253" duration="2020000" />
<workItem from="1578495070464" duration="2563000" />
<workItem from="1578540562713" duration="5764000" />
<workItem from="1578704626479" duration="2241000" />
<workItem from="1579089408109" duration="3822000" />
<workItem from="1579695121386" duration="2796000" />
<workItem from="1579758668363" duration="319000" />
<workItem from="1579759214129" duration="10251000" />
<workItem from="1580044287086" duration="865000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="533" y="166" key="#com.intellij.ide.util.MemberChooser" timestamp="1578548165321">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="533" y="166" key="#com.intellij.ide.util.MemberChooser/0.0.1440.900@0.0.1440.900" timestamp="1578548165321" />
<state x="303" y="50" key="CommitChangelistDialog2" timestamp="1580045414311">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="303" y="50" key="CommitChangelistDialog2/0.0.1440.900@0.0.1440.900" timestamp="1580045414311" />
<state width="1398" height="193" key="GridCell.Tab.0.bottom" timestamp="1580045093251">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="193" key="GridCell.Tab.0.bottom/0.0.1440.900@0.0.1440.900" timestamp="1580045093251" />
<state width="1398" height="193" key="GridCell.Tab.0.bottom/0.23.1440.797@0.23.1440.797" timestamp="1579796075437" />
<state width="1398" height="193" key="GridCell.Tab.0.center" timestamp="1580045093248">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="193" key="GridCell.Tab.0.center/0.0.1440.900@0.0.1440.900" timestamp="1580045093248" />
<state width="1398" height="193" key="GridCell.Tab.0.center/0.23.1440.797@0.23.1440.797" timestamp="1579796075436" />
<state width="1398" height="193" key="GridCell.Tab.0.left" timestamp="1580045093246">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="193" key="GridCell.Tab.0.left/0.0.1440.900@0.0.1440.900" timestamp="1580045093246" />
<state width="1398" height="193" key="GridCell.Tab.0.left/0.23.1440.797@0.23.1440.797" timestamp="1579796075435" />
<state width="1398" height="193" key="GridCell.Tab.0.right" timestamp="1580045093249">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="193" key="GridCell.Tab.0.right/0.0.1440.900@0.0.1440.900" timestamp="1580045093249" />
<state width="1398" height="193" key="GridCell.Tab.0.right/0.23.1440.797@0.23.1440.797" timestamp="1579796075437" />
<state width="1398" height="303" key="GridCell.Tab.1.bottom" timestamp="1580044282990">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="303" key="GridCell.Tab.1.bottom/0.0.1440.900@0.0.1440.900" timestamp="1580044282990" />
<state width="1398" height="303" key="GridCell.Tab.1.bottom/0.23.1440.797@0.23.1440.797" timestamp="1579765319366" />
<state width="1398" height="303" key="GridCell.Tab.1.center" timestamp="1580044282989">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="303" key="GridCell.Tab.1.center/0.0.1440.900@0.0.1440.900" timestamp="1580044282989" />
<state width="1398" height="303" key="GridCell.Tab.1.center/0.23.1440.797@0.23.1440.797" timestamp="1579765319364" />
<state width="1398" height="303" key="GridCell.Tab.1.left" timestamp="1580044282988">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="303" key="GridCell.Tab.1.left/0.0.1440.900@0.0.1440.900" timestamp="1580044282988" />
<state width="1398" height="303" key="GridCell.Tab.1.left/0.23.1440.797@0.23.1440.797" timestamp="1579765319363" />
<state width="1398" height="303" key="GridCell.Tab.1.right" timestamp="1580044282989">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="303" key="GridCell.Tab.1.right/0.0.1440.900@0.0.1440.900" timestamp="1580044282989" />
<state width="1398" height="303" key="GridCell.Tab.1.right/0.23.1440.797@0.23.1440.797" timestamp="1579765319365" />
<state x="221" y="88" key="SettingsEditor" timestamp="1578704600210">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="221" y="88" key="SettingsEditor/0.0.1440.900@0.0.1440.900" timestamp="1578704600210" />
<state x="378" y="207" width="683" height="486" key="find.popup" timestamp="1578496174047">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="378" y="207" width="683" height="486" key="find.popup/0.0.1440.900@0.0.1440.900" timestamp="1578496174047" />
<state x="385" y="196" width="670" height="676" key="search.everywhere.popup" timestamp="1578547335842">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="385" y="196" width="670" height="676" key="search.everywhere.popup/0.0.1440.900@0.0.1440.900" timestamp="1578547335842" />
</component>
</project>

@ -21,20 +21,6 @@ FastLeaderElection(默认提供的选举算法):
(4)服务器4启动给自己投票同时与之前启动的服务器1,2,3交换信息尽管服务器4的编号大但之前服务器3已经胜出所以服务器4只能成为follower。
(5)服务器5启动后面的逻辑同服务器4成为follower。
4. 节点类型:
(1)持久
(2)持久顺序
(3)临时
(4)临时顺序
5. 如何保证事务的顺序一致性
(1)Leader为每个请求生成zxid下发proposal给FollowerFollower会将请求写入到pendingTxns阻塞队列及txnLog中然后发送ack给Leader。
(2)ack过半Leader发送commit请求给所有FollowerFollower对比commit request的zxid和前面提到的pendingTxns的zxid不一致的话Follower退出重新跟Leader同步。
(3)Follower处理commit请求如果不是本Follower提交的写请求直接调用FinalRequestProcessor做持久化触发watches如果是本Follower提交则做一些特殊处理主要针对客户端连接断开的场景然后调用FinalRequestProcessor等后续处理流程。
(4)FinalRequestProcessor做持久化返回客户端。
## Redis
1. 应用场景
@ -127,6 +113,11 @@ Redis默认是快照RDB的持久化方式。
先更新数据库,再删缓存。数据库的读操作的速度远快于写操作的,所以脏数据很难出现。可以对异步延时删除策略,保证读请求完成以后,再进行删除操作。
12. Redis的管道pipeline
对于单线程阻塞式的RedisPipeline可以满足批量的操作把多个命令连续的发送给Redis Server然后一一解析响应结果。Pipelining可以提高批量处理性能提升的原因主要是TCP连接中减少了“交互往返”的时间。
pipeline 底层是通过把所有的操作封装成流redis有定义自己的出入输出流。在 sync() 方法执行操作,每次请求放在队列里面,解析响应包。
## Mysql
1. 事务的基本要素
@ -150,8 +141,10 @@ Redis默认是快照RDB的持久化方式。
可重复读 | 否 | 否 |是
串行化 | 否 | 否 |否
幻读select某记录是否存在不存在准备插入此记录但执行 insert 时发现此记录已存在,无法插入,此时就发生了幻读。
在MySQL可重复读的隔离级别中并不是完全解决了幻读的问题而是解决了读数据情况下的幻读问题。而对于修改的操作依旧存在幻读问题就是说MVCC对于幻读的解决时不彻底的。
通过索引加锁,间隙锁可以解决幻读的问题。
通过索引加锁,间隙锁next key lock可以解决幻读的问题。
5. Mysql的逻辑结构
@ -213,6 +206,13 @@ Read View判断行的可见性创建一个新事务时copy一份当前系
(5)where不等于
(6)or操作有至少一个字段没有索引
11. 数据库优化指南
(1)创建并使用正确的索引
(2)只返回需要的字段
(3)减少交互次数(批量提交)
(4)设置合理的Fetch Size数据每次返回给客户端的条数
11. Mysql排序原理
## JVM
@ -319,6 +319,8 @@ Java并发包为了解决这个问题提供了一个带有标记的原子引
10. synchronized非公平可重入,ReentrantLock与AQS
AQS内部有3个对象一个是state用于计数器类似gc的回收计数器一个是线程标记当前线程是谁加锁的一个是阻塞队列
11. AtomicInteger
12. i++操作的字节码指令
@ -349,6 +351,8 @@ Map接口和Collection接口是所有集合框架的父接口
由于HashMap是线程不同步的虽然处理数据的效率高但是在多线程的情况下存在着安全问题因此设计了CurrentHashMap来解决多线程安全问题。
HashMap在put的时候插入的元素超过了容量由负载因子决定的范围就会触发扩容操作就是rehash这个会重新将原数组的内容重新hash到新的扩容数组中在多线程的环境下存在同时其他的元素也在进行put操作如果hash值相同可能出现同时在同一数组下用链表表示造成闭环导致在get时会出现死循环所以HashMap是线程不安全的。
HashMap的环若当前线程此时获得ertry节点但是被线程中断无法继续执行此时线程二进入transfer函数并把函数顺利执行此时新表中的某个位置有了节点之后线程一获得执行权继续执行因为并发transfer所以两者都是扩容的同一个链表当线程一执行到e.next = new table[i] 的时候由于线程二之前数据迁移的原因导致此时new table[i] 上就有ertry存在所以线程一执行的时候会将next节点设置为自己导致自己互相使用next引用对方因此产生链表导致死循环。
在JDK1.7版本中ConcurrentHashMap维护了一个Segment数组Segment这个类继承了重入锁ReentrantLock并且该类里面维护了一个 HashEntry<K,V>[] table数组在写操作putremove扩容的时候会对Segment加锁所以仅仅影响这个Segment不同的Segment还是可以并发的所以解决了线程的安全问题同时又采用了分段锁也提升了并发的效率。
在JDK1.8版本中ConcurrentHashMap摒弃了Segment的概念而是直接用Node数组+链表+红黑树的数据结构来实现并发控制使用Synchronized和CAS来操作整个看起来就像是优化过且线程安全的HashMap。
@ -432,24 +436,16 @@ Pull有个缺点是如果broker没有可供消费的消息将导致consume
实时返回,返回值,消费策略(速度)
## Spring
1. Bean的生命周期
## Dubbo
(1)实例化一个Bean也就是我们通常说的new
(2)按照Spring上下文对实例化的Bean进行配置也就是IOC注入
(3)如果这个Bean实现了BeanNameAware接口会调用它实现的setBeanName(String beanId)方法此处传递的是Spring配置文件中Bean的ID
(4)如果这个Bean实现了BeanFactoryAware接口会调用它实现的setBeanFactory()传递的是Spring工厂本身
(5)如果这个Bean实现了ApplicationContextAware接口会调用setApplicationContext(ApplicationContext)方法传入Spring上下文该方式同样可以实现步骤4但比4更好以为ApplicationContext是BeanFactory的子接口有更多的实现方法
(6)如果这个Bean关联了BeanPostProcessor接口将会调用postProcessBeforeInitialization(Object obj, String s)方法BeanPostProcessor经常被用作是Bean内容的更改并且由于这个是在Bean初始化结束时调用After方法也可用于内存或缓存技术
(7)如果这个Bean在Spring配置文件中配置了init-method属性会自动调用其配置的初始化方法
(8)如果这个Bean关联了BeanPostProcessor接口将会调用postAfterInitialization(Object obj, String s)方法
(9)当Bean不再需要时会经过清理阶段如果Bean实现了DisposableBean接口会调用其实现的destroy方法
(10)最后如果这个Bean的Spring配置中配置了destroy-method属性会自动调用其配置的销毁方法
1. Dubbo的容错机制
2.Final类的动态代理
cglib是基于继承的方式实现类的动态代理因此无法实现对final方法的代理。JDK是通过反射
(1)失败自动切换,当出现失败,重试其它服务器。通常用于读操作,但重试会带来更长延迟。可通过 retries="2" 来设置重试次数
(2)快速失败,只发起一次调用,失败立即报错。通常用于非幂等性的写操作,比如新增记录。
(3)失败安全,出现异常时,直接忽略。通常用于写入审计日志等操作。
(4)失败自动恢复,后台记录失败请求,定时重发。通常用于消息通知操作。
(5)并行调用多个服务器,只要一个成功即返回。通常用于实时性要求较高的读操作,但需要浪费更多服务资源。可通过 forks="2" 来设置最大并行数。
(6)广播调用所有提供者,逐个调用,任意一台报错则报错。通常用于通知所有提供者更新缓存或日志等本地资源信息
## 计算机网路
@ -486,7 +482,11 @@ UDP的优点比TCP稍安全 UDP没有TCP的握手、确认、窗口、
第二次握手服务器收到syn包必须确认客户的SYNack=x+1同时自己也发送一个SYN包syn=y即SYN+ACK包此时服务器进入SYN_RECV状态
第三次握手客户端收到服务器的SYN+ACK包向服务器发送确认包ACK(ack=y+1此包发送完毕客户端和服务器进入ESTABLISHEDTCP连接成功状态完成三次握手。
5. 四次挥手
5. 为什么不能两次握手
TCP是一个双向通信协议通信双方都有能力发送信息并接收响应。如果只是两次握手 至多只有连接发起方的起始序列号能被确认, 另一方选择的序列号则得不到确认
6. 四次挥手
(1)客户端进程发出连接释放报文并且停止发送数据。释放数据报文首部FIN=1其序列号为seq=u等于前面已经传送过来的数据的最后一个字节的序号加1此时客户端进入FIN-WAIT-1终止等待1状态。 TCP规定FIN报文段即使不携带数据也要消耗一个序号。
(2)服务器收到连接释放报文发出确认报文ACK=1ack=u+1并且带上自己的序列号seq=v此时服务端就进入了CLOSE-WAIT关闭等待状态。TCP服务器通知高层的应用进程客户端向服务器的方向就释放了这时候处于半关闭状态即客户端已经没有数据要发送了但是服务器若发送数据客户端依然要接受。这个状态还要持续一段时间也就是整个CLOSE-WAIT状态持续的时间。
@ -495,7 +495,7 @@ UDP的优点比TCP稍安全 UDP没有TCP的握手、确认、窗口、
(5)客户端收到服务器的连接释放报文后必须发出确认ACK=1ack=w+1而自己的序列号是seq=u+1此时客户端就进入了TIME-WAIT时间等待状态。注意此时TCP连接还没有释放必须经过2MSL最长报文段寿命的时间后当客户端撤销相应的TCB后才进入CLOSED状态。
(6)服务器只要收到了客户端发出的确认立即进入CLOSED状态。同样撤销TCB后就结束了这次的TCP连接。可以看到服务器结束TCP连接的时间要比客户端早一些
6. 为什么连接的时候是三次握手,关闭的时候却是四次握手
7. 为什么连接的时候是三次握手,关闭的时候却是四次握手
因为当Server端收到Client端的SYN连接请求报文后可以直接发送SYN+ACK报文。其中ACK报文是用来应答的SYN报文是用来同步的。但是关闭连接时当Server端收到FIN报文时很可能并不会立即关闭SOCKET所以只能先回复一个ACK报文告诉Client端"你发的FIN报文我收到了"。只有等到我Server端所有的报文都发送完了我才能发送FIN报文因此不能一起发送。故需要四步握手。

@ -1,7 +1,7 @@
package q172.f2;
/**
* 5o(log(n))
* 5o(log(n))
*/
public class Solution {
public int trailingZeroes(int n) {

@ -0,0 +1,47 @@
package q5.f1;
/**
* o(n^2)
*/
class Solution {
public String getPalindrome(String s, int index) {
String rs = "";
int sLen = s.length();
int i = index;
int j = index;
while (j < sLen) {
if (s.charAt(j) == s.charAt(index)) {
rs = rs + s.charAt(j);
j++;
} else {
break;
}
}
i--;
while (i >= 0 && j < sLen) {
if (s.charAt(i) == s.charAt(j)) {
rs = s.charAt(i) + rs;
rs = rs + s.charAt(i);
i--;
j++;
} else {
break;
}
}
return rs;
}
public String longestPalindrome(String s) {
int maxLen = -1;
String rs = "";
for (int i = 0; i < s.length(); i++) {
String t = getPalindrome(s, i);
if (t.length() > maxLen) {
maxLen = t.length();
rs = t;
}
}
return rs;
}
}

@ -0,0 +1,47 @@
package q5.f2;
/**
* o(n^2)
*
* dpsij
*/
public class Solution {
public String longestPalindrome(String s) {
int len = s.length();
if (len < 2) {
return s;
}
boolean[][] dp = new boolean[len][len];
for (int i = 0; i < len; i++) {
dp[i][i] = true;
}
int maxLen = 1;
int start = 0;
for (int j = 1; j < len; j++) {
for (int i = 0; i < j; i++) {
if (s.charAt(i) == s.charAt(j)) {
if (j - i < 3) {
dp[i][j] = true;
} else {
dp[i][j] = dp[i + 1][j - 1];
}
} else {
dp[i][j] = false;
}
if (dp[i][j]) {
int curLen = j - i + 1;
if (curLen > maxLen) {
maxLen = curLen;
start = i;
}
}
}
}
return s.substring(start, start + maxLen);
}
}

@ -0,0 +1,28 @@
package q7.f1;
/**
* String o(n)
*/
public class Solution {
public int reverse(int x) {
String s = String.valueOf(x);
String rs = "";
boolean f = false;
for (int i = s.length() - 1; i >= 0; i--) {
if (s.charAt(i) == '-') {
f = true;
} else {
rs += s.charAt(i);
}
}
try {
return f ? Integer.parseInt(rs) * (-1) : Integer.parseInt(rs);
} catch (Exception e) {
return 0;
}
}
public static void main(String[] args) {
System.out.println(new Solution().reverse(1234));
}
}

@ -0,0 +1,22 @@
package q7.f2;
/**
* o(log(n))
*/
public class Solution {
public int reverse(int x) {
int rs = 0;
while (true) {
int y = x % 10;
x = x / 10;
if (rs * 10 / 10 != rs) {
return 0;
}
rs = rs * 10 + y;
if (x == 0) {
break;
}
}
return rs;
}
}
Loading…
Cancel
Save