diff --git a/.gitignore b/.gitignore
index a387c72b8..cd1fbccc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,115 +1,7 @@
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
-# C extensions
-*.so
-
-# Distribution / packaging
-.Python
-env/
-build/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-wheels/
-*.egg-info/
-.installed.cfg
-*.egg
-
-# PyInstaller
-# Usually these files are written by a python script from a template
-# before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*.cover
-.hypothesis/
-
-# Translations
-*.mo
-*.pot
-
-# Django stuff:
-*.log
-local_settings.py
-
-# Flask stuff:
-instance/
-.webassets-cache
-
-# Scrapy stuff:
-.scrapy
-
-# Sphinx documentation
-docs/_build/
-
-# PyBuilder
-target/
-
-# Jupyter Notebook
-.ipynb_checkpoints
-
-# pyenv
-.python-version
-
-# celery beat schedule file
-celerybeat-schedule
-
-# SageMath parsed files
-*.sage.py
-
-# dotenv
-.env
-
-# virtualenv
-.venv
-venv/
-ENV/
-
-# Spyder project settings
-.spyderproject
-.spyproject
-
-# Rope project settings
-.ropeproject
-
-# mkdocs documentation
-/site
-
-# mypy
-.mypy_cache/
.DS_Store
-
-# gitbook
-_book
-
-# node.js
-node_modules
-
-# windows
Thumbs.db
-
-# word
-~$*.docx
-~$*.doc
+db.json
+*.log
+node_modules/
+public/
+.deploy*/
diff --git a/404.html b/404.html
deleted file mode 100644
index 5705bebe5..000000000
--- a/404.html
+++ /dev/null
@@ -1,4 +0,0 @@
----
-permalink: /404.html
----
-
diff --git a/CNAME b/CNAME
deleted file mode 100644
index ad71e6f3f..000000000
--- a/CNAME
+++ /dev/null
@@ -1 +0,0 @@
-algo.apachecn.org
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 65e2ef590..000000000
--- a/Dockerfile
+++ /dev/null
@@ -1,2 +0,0 @@
-FROM httpd:2.4
-COPY ./ /usr/local/apache2/htdocs/
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..9cecc1d46
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+ .
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/NAV.md b/NAV.md
deleted file mode 100644
index a91cdb26a..000000000
--- a/NAV.md
+++ /dev/null
@@ -1,196 +0,0 @@
-+ 编程
- + [JavaTPoint 编程语言中文教程📚](https://apachecn.github.io/javatpoint-prog-zh)
- + [JavaTPoint .NET 中文教程📚](https://apachecn.github.io/javatpoint-dotnet-zh)
- + [JavaTPoint Java 中文教程📚](https://apachecn.github.io/javatpoint-java-zh)
- + [JavaTPoint Python 中文教程📚](https://apachecn.github.io/javatpoint-python-zh)
- + [GeeksForGeeks 编程语言杂项中文教程📚](https://apachecn.github.io/geeksforgeeks-lang-misc-zh)
- + [GeeksForGeeks C# 中文教程📚](https://apachecn.github.io/geeksforgeeks-csharp-zh)
- + [GeeksForGeeks Scala 中文教程📚](https://apachecn.github.io/geeksforgeeks-scala-zh)
- + [GeeksForGeeks Python 中文教程📚](https://apachecn.github.io/geeksforgeeks-python-zh)
- + [GeeksForGeeks C/C++ 中文教程📚](https://apachecn.github.io/geeksforgeeks-c-cpp-zh)
- + [GeeksForGeeks Java 中文教程📚](https://apachecn.github.io/geeksforgeeks-java-zh)
- + [GeeksForGeeks JavaScript 中文教程📚](https://apachecn.github.io/geeksforgeeks-js-zh)
- + [ApacheCN C# 译文集📚](https://apachecn.github.io/apachecn-csharp-zh)
- + [ApacheCN C# 译文集(二)📚](https://apachecn.github.io/apachecn-csharp-zh-pt2)
- + [ApacheCN C# 译文集(三)📚](https://apachecn.github.io/apachecn-csharp-zh-pt3)
- + [ApacheCN C# 译文集(四)📚](https://apachecn.github.io/apachecn-csharp-zh-pt4)
- + [ApacheCN Golang 译文集📚](https://apachecn.github.io/apachecn-golang-zh)
- + [ApacheCN Golang 译文集(二)📚](https://apachecn.github.io/apachecn-golang-zh-pt2)
- + [ApacheCN C/C++ 译文集📚](https://apachecn.github.io/apachecn-c-cpp-zh)
- + [ApacheCN C/C++ 译文集(二)📚](https://apachecn.github.io/apachecn-c-cpp-zh-pt2)
- + [ApacheCN C/C++ 译文集(三)📚](https://apachecn.github.io/apachecn-c-cpp-zh-pt3)
- + [ApacheCN Java 译文集📚](https://apachecn.github.io/apachecn-java-zh)
- + [ApacheCN Java 译文集(二)📚](https://apachecn.github.io/apachecn-java-zh-pt2)
- + [ApacheCN Java 译文集(三)📚](https://apachecn.github.io/apachecn-java-zh-pt3)
- + [ApacheCN JavaScript 译文集📚](https://apachecn.github.io/apachecn-js-zh)
- + [ApacheCN JavaScript 译文集(二)📚](https://apachecn.github.io/apachecn-js-zh-pt2)
- + [ApacheCN JavaScript 译文集(三)📚](https://apachecn.github.io/apachecn-js-zh-pt3)
- + [ApacheCN JavaScript 译文集(四)📚](https://apachecn.github.io/apachecn-js-zh-pt4)
- + [ApacheCN Python 译文集📚](https://apachecn.github.io/apachecn-python-zh)
- + [ApacheCN Python 译文集(二)📚](https://apachecn.github.io/apachecn-python-zh-pt2)
- + [ApacheCN Python 译文集(三)📚](https://apachecn.github.io/apachecn-python-zh-pt3)
- + [ApacheCN Python 译文集(四)📚](https://apachecn.github.io/apachecn-python-zh-pt4)
- + [ApacheCN Ruby 译文集📚](https://apachecn.github.io/apachecn-ruby-zh)
- + [BeginnersBook 中文系列教程📚](https://apachecn.github.io/beginnersbook-zh)
- + [JavaScript 编程精解 中文第三版](https://apachecn.github.io/eloquent-js-3e-zh)
- + [Guru99 中文系列教程📚🚧](https://apachecn.github.io/guru99-zh)
- + [HowToDoInJava 中文系列教程📚](https://apachecn.github.io/howtodoinjava-zh)
- + [OverIQ 中文系列教程📚](https://apachecn.github.io/overiq-zh)
- + [LearnETutroials 中文系列教程📚](https://apachecn.github.io/learnetutorials-zh)
- + [StudyTonight 中文系列教程📚](https://apachecn.github.io/studytonight-zh)
- + [TutorialGateway 中文系列教程📚](https://apachecn.github.io/tutorialgateway-zh)
- + [TutorialGateway BI 中文系列教程📚](https://apachecn.github.io/tutorialgateway-bi-zh)
- + [TutorialsTeacher 中文系列教程📚](https://apachecn.github.io/tutorialsteacher-zh)
- + [通过示例学 Golang 2020 中文版](https://apachecn.github.io/golang-by-example-2020-zh)
- + [写给不耐烦程序员的 JavaScript🚧](https://apachecn.github.io/impatient-js-zh)
- + [JavaBeginnersTutorial 中文系列教程📚](https://apachecn.github.io/jbt-zh)
- + [JavaTutorialNetwork 中文系列教程📚](https://apachecn.github.io/jtn-zh)
- + [笨办法学C 中文版](https://apachecn.github.io/lcthw-zh)
- + [笨办法学 Python · 续 中文版](https://apachecn.github.io/lmpythw-zh)
- + [Programiz 中文系列教程📚](https://apachecn.github.io/programiz-zh)
- + [PythonBasics 中文系列教程📚](https://apachecn.github.io/pythonbasics-zh)
- + [PythonGuru 中文系列教程📚](https://apachecn.github.io/pythonguru-zh)
- + [PythonSpot 中文系列教程📚](https://apachecn.github.io/pythonspot-zh)
- + [Think Python](https://apachecn.github.io/think-py-2e-zh)
- + [ZetCode 中文系列教程📚](https://apachecn.github.io/zetcode-zh)
-+ 前端
- + [JavaTPoint 移动开发中文教程📚](https://apachecn.github.io/javatpoint-mobi-zh)
- + [GeeksForGeeks Web 杂项中文教程📚](https://apachecn.github.io/geeksforgeeks-web-misc-zh)
- + [GeeksForGeeks Angular/Vue/React 中文教程📚](https://apachecn.github.io/geeksforgeeks-ng-vue-react-zh)
- + [GeeksForGeeks jQuery 中文教程📚](https://apachecn.github.io/geeksforgeeks-jquery-zh)
- + [GeeksForGeeks CSS 中文教程📚](https://apachecn.github.io/geeksforgeeks-css-zh)
- + [GeeksForGeeks HTML 中文教程📚](https://apachecn.github.io/geeksforgeeks-html-zh)
- + [ApacheCN Vue 译文集📚](https://apachecn.github.io/apachecn-vue-zh)
- + [ApacheCN Angular 译文集📚](https://apachecn.github.io/apachecn-angular-zh)
- + [ApacheCN React 译文集📚](https://apachecn.github.io/apachecn-react-zh)
- + [ApacheCN jQuery 译文集📚](https://apachecn.github.io/apachecn-jquery-zh)
- + [ApacheCN jQuery 译文集(二)📚](https://apachecn.github.io/apachecn-jquery-zh-pt2)
-+ 后端/大数据
- + [JavaTPoint 大数据中文教程📚](https://apachecn.github.io/javatpoint-bigdata-zh)
- + [JavaTPoint Web 开发中文教程📚](https://apachecn.github.io/javatpoint-web-zh)
- + [JavaTPoint 数据库中文教程📚](https://apachecn.github.io/javatpoint-db-zh)
- + [JavaTPoint PHP 中文教程📚](https://apachecn.github.io/javatpoint-php-zh)
- + [GeeksForGeeks ASP 中文教程📚](https://apachecn.github.io/geeksforgeeks-asp-zh)
- + [GeeksForGeeks SQL 中文教程📚](https://apachecn.github.io/geeksforgeeks-sql-zh)
- + [GeeksForGeeks NodeJS 中文教程📚](https://apachecn.github.io/geeksforgeeks-nodejs-zh)
- + [GeeksForGeeks PHP 中文教程📚](https://apachecn.github.io/geeksforgeeks-php-zh)
- + [ApacheCN 数据库译文集📚](https://apachecn.github.io/apachecn-db-zh)
- + [ApacheCN 数据库译文集(二)📚](https://apachecn.github.io/apachecn-db-zh-pt2)
- + [ApacheCN Python Web 译文集📚](https://apachecn.github.io/apachecn-pythonweb-zh)
- + [ApacheCN Python Web 译文集(二)📚](https://apachecn.github.io/apachecn-pythonweb-zh-pt2)
- + [ApacheCN Asp.NET 译文集📚](https://apachecn.github.io/apachecn-asp-dotnet-zh)
- + [ApacheCN Asp.NET 译文集(二)📚](https://apachecn.github.io/apachecn-asp-dotnet-zh-pt2)
- + [ApacheCN Asp.NET 译文集(三)📚](https://apachecn.github.io/apachecn-asp-dotnet-zh-pt3)
- + [ApacheCN Asp.NET 译文集(四)📚](https://apachecn.github.io/apachecn-asp-dotnet-zh-pt4)
- + [ApacheCN NodeJS 译文集📚](https://apachecn.github.io/apachecn-node-zh)
- + [ApacheCN NodeJS 译文集(二)📚](https://apachecn.github.io/apachecn-node-zh-pt2)
- + [ApacheCN PHP 译文集📚](https://apachecn.github.io/apachecn-php-zh)
- + [ApacheCN PHP 译文集(二)📚](https://apachecn.github.io/apachecn-php-zh-pt2)
- + [ApacheCN 大数据译文集(二)📚](https://apachecn.github.io/apachecn-bigdata-zh-pt2)
- + [ApacheCN 大数据译文集(三)📚](https://apachecn.github.io/apachecn-bigdata-zh-pt3)
- + [ApacheCN 大数据译文集📚](https://apachecn.github.io/apachecn-bigdata-zh)
- + [ApacheCN Java Web 译文集📚](https://apachecn.github.io/apachecn-javaweb-zh)
- + [ApacheCN Java Web 译文集(二)📚](https://apachecn.github.io/apachecn-javaweb-zh-pt2)
- + [Airflow 中文文档](https://apachecn.github.io/airflow-doc-zh)
- + [Elasticsearch 5.4 中文文档](https://apachecn.github.io/elasticsearch-doc-zh)
- + [Flink 中文文档](https://apachecn.github.io/flink-doc-zh)
- + [HBase™ 中文参考指南 3.0🚧](https://apachecn.github.io/hbase-doc-zh)
- + [HighScalability 中文示例📚🚧](https://apachecn.github.io/highscalability-examples-zh)
- + [Kibana 5.2 中文文档](https://apachecn.github.io/kibana-doc-zh)
- + [Kudu 1.4.0 中文文档](https://apachecn.github.io/kudu-doc-zh)
- + [Apache Spark 官方文档中文版](https://apachecn.github.io/spark-doc-zh)
- + [Apache Kafka 官方文档中文版](https://apachecn.github.io/kafka-site-zh)
- + [Spring Boot 1.5.2 中文文档](https://apachecn.github.io/spring-boot-doc-zh)
- + [Storm 1.1.0 中文文档](https://apachecn.github.io/storm-doc-zh)
- + [Zeppelin 0.7.2 中文文档](https://apachecn.github.io/zeppelin-doc-zh)
-+ 工具
- + [JavaTPoint 实用工具中文教程📚](https://apachecn.github.io/javatpoint-util-zh)
- + [ApacheCN DevOps 译文集📚](https://apachecn.github.io/apachecn-devops-zh)
- + [ApacheCN DevOps 译文集(二)📚](https://apachecn.github.io/apachecn-devops-zh-pt2)
- + [ApacheCN DevOps 译文集(三)📚](https://apachecn.github.io/apachecn-devops-zh-pt3)
- + [ApacheCN DevOps 译文集(四)📚](https://apachecn.github.io/apachecn-devops-zh-pt4)
- + [ApacheCN DevOps 译文集(五)📚](https://apachecn.github.io/apachecn-devops-zh-pt5)
- + [ApacheCN Linux 译文集📚](https://apachecn.github.io/apachecn-linux-zh)
- + [ApacheCN Linux 译文集(二)📚](https://apachecn.github.io/apachecn-linux-zh-pt2)
- + [ApacheCN Linux 译文集(三)📚](https://apachecn.github.io/apachecn-linux-zh-pt3)
- + [Cython 3.0 中文文档🚧](https://apachecn.github.io/cython-doc-zh)
- + [Git 中文参考🚧](https://apachecn.github.io/git-doc-zh)
- + [Gitlab 中文文档🚧](https://apachecn.github.io/gitlab-doc-zh)
- + [笨办法学 Linux 中文版](https://apachecn.github.io/llthw-zh)
- + [Numba 0.44 中文文档🚧](https://apachecn.github.io/numba-doc-zh)
- + [PyQt4 中文文档🚧](https://apachecn.github.io/pyqt4-doc-zh)
- + [Scrapy 1.6 中文文档](https://apachecn.github.io/scrapy-doc-zh)
-+ 数据科学
- + [ApacheCN 数据科学译文集📚](https://apachecn.github.io/apachecn-ds-zh)
- + [ApacheCN 数据科学译文集(二)📚](https://apachecn.github.io/apachecn-ds-zh-pt2)
- + [ApacheCN 数据科学译文集(三)📚](https://apachecn.github.io/apachecn-ds-zh-pt3)
- + [ApacheCN 数据科学译文集📚](https://apachecn.github.io/apachecn-ds-zh)
- + [MIT 18.03 面向初学者的微积分🚧](https://apachecn.github.io/calc4b-zh)
- + [UCB Data8 计算与推断思维](https://apachecn.github.io/data8-textbook-zh)
- + [数据可视化的基础知识](https://apachecn.github.io/dataviz-zh)
- + [数据科学和人工智能技术笔记](https://apachecn.github.io/ds-ai-tech-notes)
- + [数据科学 IPython 笔记本📚](https://apachecn.github.io/ds-ipynb-zh)
- + [UCB DS100 数据科学的原理与技巧🚧](https://apachecn.github.io/ds100-textbook-zh)
- + [ApacheCN 数据科学和人工智能知识库](https://apachecn.github.io/dsai-wiki)
- + [Matplotlib 用户指南](https://apachecn.github.io/matplotlib-doc-zh)
- + [MIT 18.06 线性代数笔记](https://apachecn.github.io/mit-18.06-linalg-notes)
- + [利用 Python 进行数据分析 · 第 2 版](https://apachecn.github.io/pyda-2e-zh)
- + [QuantLearning](https://apachecn.github.io/quant-learning)
- + [seaborn 0.9 中文文档](https://apachecn.github.io/seaborn-doc-zh)
- + [社交媒体挖掘 - 翻译版](https://apachecn.github.io/socialmediamining-zh)
- + [斯坦福 Stats60 21 世纪的统计思维🚧](https://apachecn.github.io/stats-thinking-21-zh)
- + [复杂性思维 中文第二版](https://apachecn.github.io/think-comp-2e-zh)
- + [PyMiner 开发者指南](https://apachecn.github.io/pyminer-dev-guide)
-+ 人工智能
- + [JavaTPoint 数据科学与人工智能中文教程📚](https://apachecn.github.io/javatpoint-dsai-zh)
- + [GeeksForGeeks 人工智能中文教程📚](https://apachecn.github.io/geeksforgeeks-ai-zh)
- + [AILearning📚](https://apachecn.github.io/ailearning)
- + [ApacheCN 计算机视觉译文集📚](https://apachecn.github.io/apachecn-cv-zh)
- + [ApacheCN 计算机视觉译文集(二)📚](https://apachecn.github.io/apachecn-cv-zh-pt2)
- + [ApacheCN 深度学习译文集📚](https://apachecn.github.io/apachecn-dl-zh)
- + [ApacheCN 深度学习译文集(二)📚](https://apachecn.github.io/apachecn-dl-zh-pt2)
- + [ApacheCN 深度学习译文集(三)📚](https://apachecn.github.io/apachecn-dl-zh-pt3)
- + [ApacheCN 机器学习译文集📚](https://apachecn.github.io/apachecn-ml-zh)
- + [ApacheCN 机器学习译文集(二)📚](https://apachecn.github.io/apachecn-ml-zh-pt2)
- + [ApacheCN 机器学习译文集(三)📚](https://apachecn.github.io/apachecn-ml-zh-pt3)
- + [FastText 中文文档](https://apachecn.github.io/fasttext-doc-zh)
- + [面向机器学习的特征工程](https://apachecn.github.io/fe4ml-zh)
- + [Gensim 中文文档](https://apachecn.github.io/gensim-doc-zh)
- + [Sklearn 与 TensorFlow 机器学习实用指南第二版](https://apachecn.github.io/hands-on-ml-2e-zh)
- + [LightGBM 中文文档](https://apachecn.github.io/lightgbm-doc-zh)
- + [Machine Learning Mastery 博客文章翻译📚🚧](https://apachecn.github.io/ml-mastery-zh)
- + [Machine Learning Mastery 博客文章翻译(二)📚🚧](https://apachecn.github.io/ml-mastery-zh-pt2)
- + [Python 自然语言处理 第二版](https://apachecn.github.io/nlp-py-2e-zh)
- + [PyTorch 自然语言处理](https://apachecn.github.io/nlp-pytorch-zh)
- + [台湾大学林轩田机器学习笔记](https://apachecn.github.io/ntu-hsuantienlin-ml)
- + [OpenCV 中文文档 4.0.0](https://apachecn.github.io/opencv-doc-zh)
- + [PythonProgramming.net 系列教程📚](https://apachecn.github.io/python-programming-net-zh)
- + [PyTorch 中文教程](https://apachecn.github.io/pytorch-doc-zh)
- + [scikit-learn (sklearn) 官方文档中文版](https://apachecn.github.io/sklearn-doc-zh)
- + [XGBoost 中文文档](https://apachecn.github.io/xgboost-doc-zh)
-+ 计算机科学
- + [JavaTPoint 计算机科学中文教程📚](https://apachecn.github.io/javatpoint-cs-zh)
- + [ApacheCN 数据结构与算法译文集📚](https://apachecn.github.io/apachecn-algo-zh)
- + [ApacheCN 计算机系统译文集📚](https://apachecn.github.io/apachecn-sys-zh)
- + [NUS CS1101s SICP JavaScript 描述🚧](https://apachecn.github.io/sicp-js-zh)
- + [UCB CS61a SICP Python 描述](https://apachecn.github.io/sicp-py-zh)
- + [数据结构思维中文版](https://apachecn.github.io/think-dast-zh)
- + [UIUC CS241 系统编程中文讲义🚧](https://apachecn.github.io/uiuc-cs241-notes-zh)
-+ 安全
- + [ApacheCN Kali Linux 译文集📚](https://apachecn.github.io/apachecn-kali-zh)
- + [ApacheCN 网络安全译文集📚](https://apachecn.github.io/apachecn-sec-zh)
- + [ApacheCN 网络安全译文集(二)📚](https://apachecn.github.io/apachecn-sec-zh-pt2)
- + [SecLearning——零组文库备份📚](https://apachecn.github.io/sec-learning)
- + [ApacheCN 安全知识库📚](https://apachecn.github.io/sec-wiki)
- + [Web Hacking 101 中文版](https://apachecn.github.io/web-hacking-101-zh)
-+ 其它
- + [生化环材劝退文集](https://apachecn.github.io/bio-chem-env-mat-discourage)
- + [5 分钟商学院精细笔记](https://apachecn.github.io/business-5min-notes)
- + [iBooker 布客](https://apachecn.github.io/home)
- + [iBooker 布客老实人报](https://apachecn.github.io/ibooker-plain-dealer)
- + [使用 Qiskit 学习量子计算 - 翻译版](https://apachecn.github.io/lqcuq-zh)
- + [原则 · 中文版](https://apachecn.github.io/principles-zh)
- + [斯坦福 CS183 & YC 创业课系列中文笔记📚](https://apachecn.github.io/stanford-cs183-notes)
- + [iBooker 团队知识库📚](https://apachecn.github.io/team-wiki)
- + [ApacheCN 技术评论](https://apachecn.github.io/tech-review)
- + [通往财富自由之路精细笔记](https://apachecn.github.io/the-way-to-wealth-freedom-notes)
diff --git a/README.md b/README.md
index 3bb1958c7..54c60e39d 100644
--- a/README.md
+++ b/README.md
@@ -1,64 +1,31 @@
-# ApacheCN 数据结构与算法译文集
+# Algorithms
-> 协议:[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/)
->
-> 程序员的双手是魔术师的双手,他们把枯燥无味的代码变成了丰富多彩的软件。——《疯狂的程序员》
+## 1. [LeetCode 题解和总结](/docs/Leetcode_Solutions/)
-* [在线阅读](https://algo.apachecn.org)
-* [在线阅读(Gitee)](https://apachecn.gitee.io/apachecn-algo-zh/)
-* [ApacheCN 学习资源](http://docs.apachecn.org/)
+## 2. [面试问答](/docs/Interview/)
-## 目录
+* [Google 面试题](/docs/interview/Google/Google.md)
+* [pocketgems 面试题](/docs/interview/pocketgems/pocketgems.md)
+* [WePay 面试题](/docs/interview/WePay/WePay.md)
+* [拍拍贷面试题](/docs/interview/拍拍贷/paipaidai.md)
-+ [数据结构思维中文版](docs/think-dast-zh/SUMMARY.md)
-+ [Leetcode C++ 题解](docs/leetcode/cpp/SUMMARY.md)
-+ [Leetcode Java 题解](docs/leetcode/java/SUMMARY.md)
-+ [Leetcode JavaScript 题解](docs/leetcode/javascript/SUMMARY.md)
-+ [Leetcode Python 题解](docs/leetcode/python/SUMMARY.md)
-+ [剑指 Offer Java 题解](docs/jianzhioffer/java/SUMMARY.md)
+## 3. [算法模版](/docs/Algorithm_Templates/)
-## 贡献指南
-为了不断改进翻译质量,我们特此启动了【翻译、校对、笔记整理活动】,开设了多个校对项目。贡献者校对一章之后可以领取千字2\~4元的奖励。进行中的校对活动请见[活动列表](https://home.apachecn.org/#/docs/activity/docs-activity)。更多详情请联系飞龙(Q562826179,V:wizardforcel)。
+## 推荐的一些LeetCode网站
-## 联系方式
+1. [KrisYu的GItuhub](https://github.com/KrisYu/LeetCode-CLRS-Python)
+2. [kamyu104的Github](https://github.com/kamyu104/LeetCode)
+3. [数据结构与算法/leetcode/lintcode题解](https://algorithm.yuanbin.me/zh-hans/)
+4. [Leetcode 讨论区](https://discuss.leetcode.com/)
+5. [visualgo算法可视化网站](https://visualgo.net/en)
+6. [Data Structure Visualization](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html)
+7. [我的算法学习之路 - Lucida](http://zh.lucida.me/blog/on-learning-algorithms/)
+8. [HiredInTech](https://www.hiredintech.com/) System Design 的总结特别适合入门
+9. [mitcc的Github](https://github.com/mitcc/AlgoSolutions)
+10. [小土刀的面试刷题笔记](http://wdxtub.com/interview/14520594642530.html)
-### 负责人
-* [飞龙](https://github.com/wizardforcel): 562826179
+### Please note, this repository is inspired from [KrisYu](https://github.com/KrisYu/LeetCode-CLRS-Python). However, it has been modified, added and improved to reflect our knowledge, wisdom and effort.
-### 其他
-
-* 在我们的 [apachecn/apachecn-algo-zh](https://github.com/apachecn/apachecn-algo-zh) github 上提 issue.
-* 发邮件到 Email: `apachecn@163.com`.
-* 在我们的 [组织学习交流群](http://www.apachecn.org/organization/348.html) 中联系群主/管理员即可.
-
-## 下载
-
-### Docker
-
-```
-docker pull apachecn0/apachecn-algo-zh
-docker run -tid -p :80 apachecn0/apachecn-algo-zh
-# 访问 http://localhost:{port} 查看文档
-```
-
-### PYPI
-
-```
-pip install apachecn-algo-zh
-apachecn-algo-zh
-# 访问 http://localhost:{port} 查看文档
-```
-
-### NPM
-
-```
-npm install -g apachecn-algo-zh
-apachecn-algo-zh
-# 访问 http://localhost:{port} 查看文档
-```
-
-## 赞助我们
-
-
+ - 💪就是干!
diff --git a/SUMMARY.md b/SUMMARY.md
deleted file mode 100644
index 24fbf429f..000000000
--- a/SUMMARY.md
+++ /dev/null
@@ -1,651 +0,0 @@
-+ [数据结构思维中文版](docs/think-dast-zh/README.md)
- + [前言](docs/think-dast-zh/0.md)
- + [第一章 接口](docs/think-dast-zh/1.md)
- + [第二章 算法分析](docs/think-dast-zh/2.md)
- + [第三章 `ArrayList`](docs/think-dast-zh/3.md)
- + [第四章 `LinkedList`](docs/think-dast-zh/4.md)
- + [第五章 双链表](docs/think-dast-zh/5.md)
- + [第六章 树的遍历](docs/think-dast-zh/6.md)
- + [第七章 到达哲学](docs/think-dast-zh/7.md)
- + [第八章 索引器](docs/think-dast-zh/8.md)
- + [第九章 `Map`接口](docs/think-dast-zh/9.md)
- + [第十章 哈希](docs/think-dast-zh/10.md)
- + [第十一章 `HashMap`](docs/think-dast-zh/11.md)
- + [第十二章 `TreeMap`](docs/think-dast-zh/12.md)
- + [第十三章 二叉搜索树](docs/think-dast-zh/13.md)
- + [第十四章 持久化](docs/think-dast-zh/14.md)
- + [第十五章 爬取维基百科](docs/think-dast-zh/15.md)
- + [第十六章 布尔搜索](docs/think-dast-zh/16.md)
- + [第十七章 排序](docs/think-dast-zh/17.md)
-+ [Leetcode C++ 题解](docs/leetcode/cpp/README.md)
- + [1. Two Sum](docs/leetcode/cpp/0001._Two_Sum.md)
- + [2. Add Two Numbers](docs/leetcode/cpp/0002._Add_Two_Numbers.md)
- + [3. Longest Substring Without Repeating Characters](docs/leetcode/cpp/0003._Longest_Substring_Without_Repeating_Characters.md)
- + [004. Median of Two Sorted Arrays](docs/leetcode/cpp/0004._Median_of_Two_Sorted_Arrays.md)
- + [5. Longest Palindromic Substring](docs/leetcode/cpp/0005._Longest_Palindromic_Substring.md)
- + [6. ZigZag Conversion](docs/leetcode/cpp/0006._ZigZag_Conversion.md)
- + [7. Reverse Integer](docs/leetcode/cpp/0007._Reverse_Integer.md)
- + [8. String to Integer (atoi)](docs/leetcode/cpp/0008._String_to_Integer_(atoi).md)
- + [9. Palindrome Number](docs/leetcode/cpp/0009._Palindrome_Number.md)
- + [10. Regular Expression Matching](docs/leetcode/cpp/0010._Regular_Expression_Matching.md)
- + [11. container with most water](docs/leetcode/cpp/0011._Container_With_Most_Water.md)
- + [12. Integer to Roman](docs/leetcode/cpp/0012._Integer_to_Roman.md)
- + [14. Longest Common Prefix](docs/leetcode/cpp/0014._Longest_Common_Prefix.md)
- + [15. 3sum](docs/leetcode/cpp/0015._3sum.md)
- + [16. 3Sum Closest](docs/leetcode/cpp/0016._3Sum_Closest.md)
- + [17. Letter Combinations of a Phone Number](docs/leetcode/cpp/0017._Letter_Combinations_of_a_Phone_Number.md)
- + [18. 4Sum](docs/leetcode/cpp/0018._4Sum.md)
- + [19. Remove Nth Node From End of List](docs/leetcode/cpp/0019._Remove_Nth_Node_From_End_of_List.md)
- + [20. Valid Parentheses](docs/leetcode/cpp/0020._Valid_Parentheses.md)
- + [21. Merge Two Sorted Lists](docs/leetcode/cpp/0021._Merge_Two_Sorted_Lists.md)
- + [22. Generate Parentheses](docs/leetcode/cpp/0022._Generate_Parentheses.md)
- + [23. merge k sorted lists](docs/leetcode/cpp/0023._Merge_K_Sorted_Lists.md)
- + [24. Swap Nodes in Pairs](docs/leetcode/cpp/0024._Swap_Nodes_in_Pairs.md)
- + [25.reverse nodes in k group](docs/leetcode/cpp/0025._Reverse_Nodes_In_K_Group.md)
- + [26.Remove Duplicates From Sorted Array](docs/leetcode/cpp/0026._Remove_Duplicates_From_Sorted_Array.md)
- + [27.Remove Element](docs/leetcode/cpp/0027._Remove_Element.md)
- + [28.implement strstr](docs/leetcode/cpp/0028._Implement_Strstr.md)
- + [29.divide two integers](docs/leetcode/cpp/0029._Divide_Two_Integers.md)
- + [30.substring with concatenation of all words](docs/leetcode/cpp/0030._Substring_With_Concatenation_Of_All_Words.md)
- + [31.Next Permutatio](docs/leetcode/cpp/0031._Next_Permutatio.md)
- + [32. Longest Valid Parentheses](docs/leetcode/cpp/0032._Longest_Valid_Parentheses.md)
- + [033. Search in Rotated Sorted Array](docs/leetcode/cpp/0033._Search_in_Rotated_Sorted_Array.md)
- + [34. Find First and Last Position of Element in Sorted Array](docs/leetcode/cpp/0034._Find_First_and_Last_Position_of_Element_in_Sorted_Array.md)
- + [???????](docs/leetcode/cpp/0035._Search_Insert_Position.md)
- + [36. Valid Sudoku](docs/leetcode/cpp/0036._Valid_Sudoku.md)
- + [38. Count and Say](docs/leetcode/cpp/0038._Count_and_Say.md)
- + [39. Combination Sum](docs/leetcode/cpp/0039._Combination_Sum.md)
- + [40. Combination Sum II](docs/leetcode/cpp/0040._Combination_Sum_II.md)
- + [041.First Missing Positive](docs/leetcode/cpp/0041._First_Missing_Positive.md)
- + [42. Trapping Rain Water](docs/leetcode/cpp/0042._Trapping_Rain_Water.md)
- + [43. Multiply Strings](docs/leetcode/cpp/0043._Multiply_Strings.md)
- + [44. Wildcard Matching](docs/leetcode/cpp/0044._Wildcard_Matching.md)
- + [045. Jump Game II](docs/leetcode/cpp/0045._Jump_Game_II.md)
- + [46. Permutations](docs/leetcode/cpp/0046._Permutations.md)
- + [47. Permutations II](docs/leetcode/cpp/0047._Permutations_II.md)
- + [49. Group Anagrams](docs/leetcode/cpp/0048._Rotate_Image.md)
- + [49. Group Anagrams](docs/leetcode/cpp/0049._Group_Anagrams.md)
- + [50. powx n](docs/leetcode/cpp/0050._powx_n.md)
- + [51. N-Queens](docs/leetcode/cpp/0051._N-Queens.md)
- + [52. N-Queens II](docs/leetcode/cpp/0052._N-Queens_II.md)
- + [053. Maximum Subarray](docs/leetcode/cpp/0053._Maximum_Subarray.md)
- + [54. Spiral Matrix](docs/leetcode/cpp/0054._Spiral_Matrix.md)
- + [55. Jump Game](docs/leetcode/cpp/0055._Jump_Game.md)
- + [56. Merge Intervals](docs/leetcode/cpp/0056._Merge_Intervals.md)
- + [57. Insert Interval](docs/leetcode/cpp/0057._Insert_Interval.md)
- + [058. Length of Last Word](docs/leetcode/cpp/0058._Length_of_Last_Word.md)
- + [59. Spiral Matrix II](docs/leetcode/cpp/0059._Spiral_Matrix_II.md)
- + [60. Permutation Sequence](docs/leetcode/cpp/0060._Permutation_Sequence.md)
- + [61. Rotate List](docs/leetcode/cpp/0061._Rotate_List.md)
- + [62. Unique Paths](docs/leetcode/cpp/0062._Unique_Paths.md)
- + [63. Unique Paths II](docs/leetcode/cpp/0063._Unique_Paths_II.md)
- + [64. Minimum Path Sum](docs/leetcode/cpp/0064._Minimum_Path_Sum.md)
- + [65. Valid Number](docs/leetcode/cpp/0065._Valid_Number.md)
- + [66. Plus One](docs/leetcode/cpp/0066._Plus_One.md)
- + [68. Text Justification](docs/leetcode/cpp/0068._Text_Justification.md)
- + [69. Sqrt(x)](docs/leetcode/cpp/0069._Sqr(x).md)
- + [72. Edit Distance](docs/leetcode/cpp/0072._Edit_Distance.md)
- + [75. Sort Colors](docs/leetcode/cpp/0075._Sort_Colors.md)
- + [76. Minimum Window Substring](docs/leetcode/cpp/0076._Minimum_Window_Substring.md)
- + [77. Combinations](docs/leetcode/cpp/0077._combinations.md)
- + [78. Subsets](docs/leetcode/cpp/0078._subsets.md)
- + [81. Search in Rotated Sorted Array II](docs/leetcode/cpp/0081._Search_in_Rotated_Sorted_Array_II.md)
- + [???????](docs/leetcode/cpp/0083._Remove_Duplicates_From_Sorted_Lists.md)
- + [84. Largest Rectangle in Histogram](docs/leetcode/cpp/0084._Largest_Rectangle_in_Histogram.md)
- + [85. Maximal Rectangle](docs/leetcode/cpp/0085._Maximal_Rectangle.md)
- + [87. Scramble String](docs/leetcode/cpp/0087._Scramble_String.md)
- + [88.Merge Sorted Array](docs/leetcode/cpp/0088._Merge_Sorted_Array.md)
- + [90. Subsets II](docs/leetcode/cpp/0090._Subsets_II.md)
- + [94. Binary Tree Inorder Traversal](docs/leetcode/cpp/0094._binary_tree_inorder_traversal.md)
- + [96. Unique Binary Search Trees](docs/leetcode/cpp/0096._Unique_Binary_Search_Trees.md)
- + [97. Interleaving String](docs/leetcode/cpp/0097._Interleaving_String.md)
- + [99. Recover Binary Search Tree](docs/leetcode/cpp/0099._Recover_Binary_Search_Tree.md)
- + [100. same tree](docs/leetcode/cpp/0100._same_tree.md)
- + [101. Symmetric Tree](docs/leetcode/cpp/0101._Symmetric_Tree.md)
- + [102. Binary Tree Level Order Traversal](docs/leetcode/cpp/0102._Binary_Tree_Level_Order_Traversal.md)
- + [104. Maximum Depth of Binary Tree](docs/leetcode/cpp/0104._Maximum_Depth_of_Binary_Tree.md)
- + [105. Construct Binary Tree from Preorder and Inorder Traversal](docs/leetcode/cpp/0105._Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.md)
- + [106. Construct Binary Tree from Inorder and Postorder Traversal](docs/leetcode/cpp/0106._Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.md)
- + [107.Binary Tree Level Order Traversal II](docs/leetcode/cpp/0107._Binary_Tree_Level_Order_Traversal_II.md)
- + [108. Convert Sorted Array to Binary Search Tree](docs/leetcode/cpp/0108._Convert_Sorted_Array_to_Binary_Search_Tree.md)
- + [109. Convert Sorted List to Binary Search Tree](docs/leetcode/cpp/0109._Convert_Sorted_List_to_Binary_Search_Tree.md)
- + [110.Balanced Binary Tree](docs/leetcode/cpp/0110._Balanced_Binary_Tree.md)
- + [111. Minimum Depth of Binary Tree](docs/leetcode/cpp/0111._Minimum_Depth_Of_Binary_Tree.md)
- + [112. Path Sum](docs/leetcode/cpp/0112._Path_Sum.md)
- + [114. Flatten Binary Tree to Linked List](docs/leetcode/cpp/0114._Flatten_Binary_Tree_to_Linked_List.md)
- + [115.Distinct Subsequences](docs/leetcode/cpp/0115._Distinct_Subsequences.md)
- + [118. Pascal's Triangle](docs/leetcode/cpp/0118._Pascals_Triangle.md)
- + [119. Pascal's Triangle II](docs/leetcode/cpp/0119._Pascals_Triangle-II.md)
- + [120. Triangle](docs/leetcode/cpp/0120._Triangle.md)
- + [121. Best Time to Buy and Sell Stock](docs/leetcode/cpp/0121._Best_Tim_to_Buy_and_Sell_Stock.md)
- + [122. Best Time to Buy and Sell Stock II](docs/leetcode/cpp/0122._Best_Time_to_Buy_and_Sell_Stock_II.md)
- + [123. Best Time to Buy and Sell Stock III](docs/leetcode/cpp/0123._Best_Time_to_Buy_and_Sell_Stock_III.md)
- + [124. Binary Tree Maximum Path Sum](docs/leetcode/cpp/0124._Binary_Tree_Maximum_Path_Sum.md)
- + [127. Word Ladder](docs/leetcode/cpp/0127._Word_Ladde.md)
- + [128. Longest Consecutive Sequence](docs/leetcode/cpp/0128._Longest_Consecutive_Sequence.md)
- + [129. Sum Root to Leaf Numbers](docs/leetcode/cpp/0129._Sum_Root_to_Leaf_Numbers.md)
- + [131. Palindrome Paritionaing](docs/leetcode/cpp/0131._Palindrome_Partitioning.md)
- + [136. Single Numbe](docs/leetcode/cpp/0136._Single_Numbe.md)
- + [137.Single Number II](docs/leetcode/cpp/0137._Single_Number_II.md)
- + [???????](docs/leetcode/cpp/0141._Linked_List_Cycle.md)
- + [142. linked list cycle II](docs/leetcode/cpp/0142._Linked_List_Cycle_II.md)
- + [144. Binary Tree Preorder Traversal](docs/leetcode/cpp/0144._Binary_Tree_Preorder_Traversal.md)
- + [145. Binary Tree Postorder Traversal](docs/leetcode/cpp/0145._Binary_Tree_Postorder_Traversal.md)
- + [147. Insertion Sort List](docs/leetcode/cpp/0147._Insert_on_Sort_List.md)
- + [148.Sort list](docs/leetcode/cpp/0148._Sort_list.md)
- + [151. Reverse Words in a String](docs/leetcode/cpp/0151._Reverse_Words_in_a_String.md)
- + [153. Find Minimum in Rotated Sorted Array](docs/leetcode/cpp/0153._Find_Minimum_in_Rotated_Sorted_Array.md)
- + [154. Find Minimum in Rotated Sorted Array II](docs/leetcode/cpp/0154._Find_Minimum_in_Rotated_Sorted_Array-II.md)
- + [160 intersection_of_Two_Linked_Lists](docs/leetcode/cpp/0160._Intersection_Of_Two_Linked_Lists.md)
- + [164. Maximum Gap](docs/leetcode/cpp/0164._Maximum_Gap.md)
- + [166. Fraction to Recurring Decimal](docs/leetcode/cpp/0166._Fraction_to_Recurring_Decimal.md)
- + [167. Two Sum II - Input array is sorted](docs/leetcode/cpp/0167._Two_Sum_II-Input_array_is_sorted.md)
- + [199. Binary Tree Right Side View](docs/leetcode/cpp/0199._Binary_Tree_Right_Side_View.md)
- + [216. Combination Sum III](docs/leetcode/cpp/0216._Combination_Sum_III.md)
- + [230. Kth Smallest Element in a BST](docs/leetcode/cpp/0230._Kth_Smallest_Element_in_a_BST.md)
- + [260. Single Number III](docs/leetcode/cpp/0260._Single_Number_III.md)
- + [287. Find the Duplicate Number](docs/leetcode/cpp/0287._Find_the_Duplicate_Number.md)
- + [326. Power_of_Three](docs/leetcode/cpp/0326._Power_Of_Three.md)
- + [328. Odd Even Linked List](docs/leetcode/cpp/0328._Odd_Even_Linked_List.md)
- + [329. Longest Increasing Path in a Matrix](docs/leetcode/cpp/0329._Longest_Increasing_Path_in_a_Matrix.md)
- + [338. Counting Bits ](docs/leetcode/cpp/0338._Counting_Bits.md)
- + [413. Arithmetic Slices](docs/leetcode/cpp/0413._Arithmetic_Slices.md)
- + [442. Find All Duplicates in an Array](docs/leetcode/cpp/0442._Find_All_Duplicates_in_an_Array.md)
- + [513. Find Bottom Left Tree Value](docs/leetcode/cpp/0513._Find_Bottom_Left_Tree_Value.md)
- + [515. Find Largest Value in Each Tree Row](docs/leetcode/cpp/0515._Find_Largest_Value_in_Each_Tree_Row.md)
- + [540. Single Element in a Sorted Array](docs/leetcode/cpp/0540._Single_Element_in_a_Sorted_Array.md)
- + [581. Shortest Unsorted Continuous Subarray](docs/leetcode/cpp/0581._Shortest_Unsorted_Continuous_Subarray.md)
- + [793. K Inverse Pairs Array](docs/leetcode/cpp/0629._K_Inverse_Pairs_Array.md)
- + [632. Smallest Range](docs/leetcode/cpp/0632._Smallest_Range.md)
- + [654. Maximum Binary Tree ](docs/leetcode/cpp/0654._maximum_binary_tree.md)
- + [668. Kth Smallest Number in Multiplication Table](docs/leetcode/cpp/0668._Kth_Smallest_Number_in_Multiplication_Table.md)
- + [701. Insert into a Binary Search Tree](docs/leetcode/cpp/0701._Insert_into_a_Binary_Search_Tree.md)
- + [715. Range Module](docs/leetcode/cpp/0715._Range_Module.md)
- + [793. Find K-th Smallest Pair Distance](docs/leetcode/cpp/0719._Find_K-th_Smallest_Pair_Distance.md)
- + [739. Daily Temperatures](docs/leetcode/cpp/0739._Daily_Temperatures.md)
- + [797. All Paths From Source to Target](docs/leetcode/cpp/0797._All_Paths_From_Source_To_Target.md)
- + [814. Binary Tree Pruning](docs/leetcode/cpp/0814._Binary_Tree_Pruning.md)
- + [841. Keys and Rooms](docs/leetcode/cpp/0841._Keys_and_Rooms.md)
- + [877. Stone Game](docs/leetcode/cpp/0877._Stone_Game.md)
- + [945. Minimum Increment to Make Array Unique](docs/leetcode/cpp/0945._Minimum_Increment_to_Make_Array_Unique.md)
- + [946. Validate Stack Sequences](docs/leetcode/cpp/0946._Validate_Stack_Sequences.md)
- + [947. Most Stones Removed with Same Row or Column](docs/leetcode/cpp/0947._Most_Stones_Removed_with_Same_Row_or_Column.md)
- + [948. Bag of Tokens](docs/leetcode/cpp/0948._Bag_of_Tokens.md)
- + [949. Largest Time for Given Digits](docs/leetcode/cpp/0949._Largest_Time_for_Given_Digits.md)
- + [950. Reveal Cards In Increasing Order](docs/leetcode/cpp/0950._Reveal_Cards_In_Increasing_Order.md)
- + [951. Flip Equivalent Binary Trees](docs/leetcode/cpp/0951._Flip_Equivalent_Binary_Trees.md)
- + [952. Largest Component Size by Common Factor](docs/leetcode/cpp/0952._Largest_Component_Size_by_Common_Factor.md)
-+ [Leetcode Java 题解](docs/leetcode/java/README.md)
- + [1. Two Sum](docs/leetcode/java/0001._Two_Sum.md)
- + [2. Add Two Numbers](docs/leetcode/java/0002._add_two_numbers.md)
- + [3. Longest Substring Without Repeating Characters](docs/leetcode/java/0003._Longest_Substring_Without_Repeating_Characters.md)
- + [4. Median of Two Sorted Arrays](docs/leetcode/java/0004._Median_of_Two_Sorted_Arrays.md)
- + [5. Longest Palindromic Substring](docs/leetcode/java/0005._Longest_Palindromic_Substring.md)
- + [6. ZigZag Conversion](docs/leetcode/java/0006._ZigZag_Conversion.md)
- + [7. Reverse Integer](docs/leetcode/java/0007._Reverse_Integer.md)
- + [23. Merge K Sorted Lists](docs/leetcode/java/0023._Merge_K_Sorted_Lists.md)
- + [141. Linked List Cycle](docs/leetcode/java/0141._linked_list_cycle.md)
- + [218. The Skyline Problem](docs/leetcode/java/0218._The_Skyline_Problem.md)
- + [238. Product of Array Except Self](docs/leetcode/java/0238._product_of_array_except_self.md)
- + [342. Power of Four](docs/leetcode/java/0342._Power_of_Four.md)
- + [403. Frog Jump](docs/leetcode/java/0403._Frog_Jump.md)
- + [757. Set Intersection Size At Least Two](docs/leetcode/java/0757._Set_Intersection_Size_At_Least_Two.md)
- + [768. Max Chunks To Make Sorted II](docs/leetcode/java/0768._Max_Chunks_To_Make_Sorted_II.md)
- + [780. Reaching Points](docs/leetcode/java/0780._Reaching_Points.md)
- + [793. Preimage Size of Factorial Zeroes Function](docs/leetcode/java/0793._Preimage_Size_of_Factorial_Zeroes_Function.md)
- + [827. Making A Large Island](docs/leetcode/java/0827._Making_A_Large_Island.md)
- + [828. Unique Letter String](docs/leetcode/java/0828._Unique_Letter_String.md)
- + [834. Sum of Distances in Tree](docs/leetcode/java/0834._Sum_of_Distances_in_Tree.md)
- + [843. Guess the Word](docs/leetcode/java/0843._Guess_the_Word.md)
- + [847. Shortest Path Visiting All Nodes](docs/leetcode/java/0847._Shortest_Path_Visiting_All_Nodes.md)
- + [850. Rectangle Area II](docs/leetcode/java/0850._Rectangle_Area_II.md)
- + [854. K-Similar Strings](docs/leetcode/java/0854._K-Similar_Strings.md)
- + [857. Minimum Cost to Hire K Workers](docs/leetcode/java/0857._Minimum_Cost_to_Hire_K_Workers.md)
- + [862. Shortest Subarray with Sum at Least K](docs/leetcode/java/0862._Shortest_Subarray_with_Sum_at_Least_K.md)
- + [864. Shortest Path to Get All Keys](docs/leetcode/java/0864._Shortest_Path_to_Get_All_Keys.md)
- + [871. Minimum Number of Refueling Stops](docs/leetcode/java/0871._Minimum_Number_of_Refueling_Stops.md)
- + [878. Nth Magical Number](docs/leetcode/java/0878._Nth_Magical_Number.md)
- + [879. Profitable Schemes](docs/leetcode/java/0879._Profitable_Schemes.md)
- + [899. Reachable Nodes In Subdivided Graph](docs/leetcode/java/0882._Reachable_Nodes_In_Subdivided_Graph.md)
- + [887. Super Egg Drop](docs/leetcode/java/0887._Super_Egg_Drop.md)
- + [891. Sum of Subsequence Widths](docs/leetcode/java/0891._Sum_of_Subsequence_Widths.md)
- + [895. Maximum Frequency Stack](docs/leetcode/java/0895._Maximum_Frequency_Stack.md)
- + [899. Orderly Queue](docs/leetcode/java/0899._Orderly_Queue.md)
- + [902. Numbers At Most N Given Digit Set](docs/leetcode/java/0902._Numbers_At_Most_N_Given_Digit_Set.md)
- + [903. Valid Permutations for DI Sequence](docs/leetcode/java/0903._Valid_Permutations_for_DI_Sequence.md)
- + [906. Super Palindromes](docs/leetcode/java/0906._Super_Palindromes.md)
- + [913. Cat and Mouse](docs/leetcode/java/0913._Cat_and_Mouse.md)
- + [920. Number of Music Playlists](docs/leetcode/java/0920._Number_of_Music_Playlists.md)
-+ [Leetcode JavaScript 题解](docs/leetcode/javascript/README.md)
- + [0001 Two Sum](docs/leetcode/javascript/0001._Two_Sum.md)
- + [0002 Add Two Numbers](docs/leetcode/javascript/0002._Add_Two_Numbers.md)
- + [0003 Longest Substring without Repeating Characters](docs/leetcode/javascript/0003._Longest_Substring_without_Repeating_Characters.md)
- + [0007 Reverse Integer](docs/leetcode/javascript/0007._Reverse_Integer.md)
- + [0008 String to Integer](docs/leetcode/javascript/0008._String_to_Integer.md)
- + [0009 Palindrome Number](docs/leetcode/javascript/0009._Palindrome_Number.md)
- + [0011 Container With Most Water](docs/leetcode/javascript/0011._Container_With_Most_Water.md)
- + [0012 Integer To Roman](docs/leetcode/javascript/0012._Integer_To_Roman.md)
- + [0013 Roman To Integer](docs/leetcode/javascript/0013._Roman_To_Integer.md)
- + [0014 Longest Common Prefix](docs/leetcode/javascript/0014._Longest_Common_Prefix.md)
- + [0015 Three Sum](docs/leetcode/javascript/0015._Three_Sum.md)
- + [0016 3 Sum Closest](docs/leetcode/javascript/0016._3_Sum_Closest.md)
- + [0017 Letter Combinations Of A Phone Number](docs/leetcode/javascript/0017._Letter_Combinations_Of_A_Phone_Number.md)
- + [0019 Remove Nth Node From End Of List](docs/leetcode/javascript/0019._Remove_Nth_Node_From_End_Of_List.md)
- + [0020 Valid Parentheses](docs/leetcode/javascript/0020._Valid_Parentheses.md)
- + [0021 Merge Two Sorted Lists](docs/leetcode/javascript/0021._Merge_Two_Sorted_Lists.md)
- + [0022 Generate Parentheses](docs/leetcode/javascript/0022._Generate_Parentheses.md)
- + [0024 Swap Nodes In Pairs](docs/leetcode/javascript/0024._Swap_Nodes_In_Pairs.md)
- + [0027 Remove Element](docs/leetcode/javascript/0027._Remove_Element.md)
- + [0031 Next Permutation](docs/leetcode/javascript/0031._Next_Permutation.md)
- + [0035 Search Insert Position](docs/leetcode/javascript/0035._Search_Insert_Position.md)
- + [0054 Spiral Matrix](docs/leetcode/javascript/0054._Spiral_Matrix.md)
- + [0055 Jump Game](docs/leetcode/javascript/0055._Jump_Game.md)
- + [0056 Merge Intervals](docs/leetcode/javascript/0056._Merge_Intervals.md)
- + [0058 Length of Last Word](docs/leetcode/javascript/0058._Length_of_Last_Word.md)
- + [0061 Rotate List](docs/leetcode/javascript/0061._Rotate_List.md)
- + [0062 Unique Paths](docs/leetcode/javascript/0062._Unique_Paths.md)
- + [0066 Plus One](docs/leetcode/javascript/0066._Plus_One.md)
- + [0067 Add Binary](docs/leetcode/javascript/0067._Add_Binary.md)
- + [0074 Search a 2D Matrix](docs/leetcode/javascript/0074._Search_a_2D_Matrix.md)
- + [0079 Search Word](docs/leetcode/javascript/0079._Search_Word.md)
- + [0083 Remove Duplicates From Sorted List](docs/leetcode/javascript/0083._Remove_Duplicates_From_Sorted_List.md)
- + [0094 Binary Tree Inorder Traversal](docs/leetcode/javascript/0094._Binary_Tree_Inorder_Traversal.md)
- + [0098 Validate Binary Search Tree](docs/leetcode/javascript/0098._Validate_Binary_Search_Tree.md)
- + [0100 Same Tree](docs/leetcode/javascript/0100._Same_Tree.md)
- + [0101 Symmetric Tree](docs/leetcode/javascript/0101._Symmetric_Tree.md)
- + [0104 Maximum Depth of Binary Tree](docs/leetcode/javascript/0104._Maximum_Depth_of_Binary_Tree.md)
- + [0106 Construct Binary Tree From Inorder And Postorder Traversal](docs/leetcode/javascript/0106._Construct_Binary_Tree_From_Inorder_And_Postorder_Traversal.md)
- + [0141 Linked List Cycle](docs/leetcode/javascript/0141._Linked_List_Cycle.md)
- + [0146 LRU Cache](docs/leetcode/javascript/0146._LRU_Cache.md)
- + [0167 Two Sum II - Input array is sorted](docs/leetcode/javascript/0167._Two_Sum_II_-_Input_array_is_sorted.md)
- + [0167 Two Sum II Input Array is Sorted](docs/leetcode/javascript/0167._Two_Sum_II_Input_Array_is_Sorted.md)
- + [0171 Excel Sheet Column Number](docs/leetcode/javascript/0171._Excel_Sheet_Column_Number.md)
- + [0179 Largest Number](docs/leetcode/javascript/0179._Largest_Number.md)
- + [0203 Remove Linked List Elements](docs/leetcode/javascript/0203._Remove_Linked_List_Elements.md)
- + [0206 Reverse-Linked-List](docs/leetcode/javascript/0206._Reverse-Linked-List.md)
- + [0209 Minimum Size Subarray Sum](docs/leetcode/javascript/0209._Minimum_Size_Subarray_Sum.md)
- + [0258 Add Digits](docs/leetcode/javascript/0258._Add_Digits.md)
- + [0347 Top K Frequent Elements](docs/leetcode/javascript/0347._Top_K_Frequent_Elements.md)
- + [0402 Remove K Digits](docs/leetcode/javascript/0402._Remove_K_Digits.md)
- + [0406 Queue Reconstruction By Height](docs/leetcode/javascript/0406._Queue_Reconstruction_By_Height.md)
- + [0485 Max Consecutive Ones](docs/leetcode/javascript/0485._Max_Consecutive_Ones.md)
- + [0539 Minimum Time Difference](docs/leetcode/javascript/0539._Minimum_Time_Difference.md)
- + [0581 Shortest Unsorted Continuous Subarray](docs/leetcode/javascript/0581._Shortest_Unsorted_Continuous_Subarray.md)
- + [0881 Boats to Save People](docs/leetcode/javascript/0881._Boats_to_Save_People.md)
- + [0997 Find The Town Judge](docs/leetcode/javascript/0997._Find_The_Town_Judge.md)
- + [1130 Minimum Cost Tree From Leaf Values](docs/leetcode/javascript/1130._Minimum_Cost_Tree_From_Leaf_Values.md)
-+ [Leetcode Python 题解](docs/leetcode/python/README.md)
- + [001 two sum](docs/leetcode/python/001._two_sum.md)
- + [002 add two numbers](docs/leetcode/python/002._add_two_numbers.md)
- + [003 longest substring without repeating characters](docs/leetcode/python/003._longest_substring_without_repeating_characters.md)
- + [004 median of two sorted arrays](docs/leetcode/python/004._median_of_two_sorted_arrays.md)
- + [005 longest palindromic substring](docs/leetcode/python/005._longest_palindromic_substring.md)
- + [006 ZigZag Conversion](docs/leetcode/python/006._ZigZag_Conversion.md)
- + [007 Reverse Integer](docs/leetcode/python/007._Reverse_Integer.md)
- + [008 string to integer (atoi)](docs/leetcode/python/008._string_to_integer_(atoi).md)
- + [009 Palindrome Number](docs/leetcode/python/009._Palindrome_Number.md)
- + [010 regular expression matching](docs/leetcode/python/010._regular_expression_matching.md)
- + [011 container with most water](docs/leetcode/python/011._container_with_most_water.md)
- + [012 Integer to Roman](docs/leetcode/python/012._Integer_to_Roman.md)
- + [013 Roman to Integer](docs/leetcode/python/013._Roman_to_Integer.md)
- + [014 longest common prefix](docs/leetcode/python/014._longest_common_prefix.md)
- + [015 3sum](docs/leetcode/python/015._3sum.md)
- + [016 3sum closest](docs/leetcode/python/016._3sum_closest.md)
- + [017 letter combinations of a phone number](docs/leetcode/python/017._letter_combinations_of_a_phone_number.md)
- + [018 4sum](docs/leetcode/python/018._4sum.md)
- + [019 remove nth node from end of list](docs/leetcode/python/019._remove_nth_node_from_end_of_list.md)
- + [020 valid parentheses](docs/leetcode/python/020._valid_parentheses.md)
- + [021 merge two sorted lists](docs/leetcode/python/021._merge_two_sorted_lists.md)
- + [022 generate parentheses](docs/leetcode/python/022._generate_parentheses.md)
- + [023 merge k sorted lists](docs/leetcode/python/023._merge_k_sorted_lists.md)
- + [024 swap nodes in pairs](docs/leetcode/python/024._swap_nodes_in_pairs.md)
- + [026 Remove Duplicates from Sorted Array](docs/leetcode/python/026._Remove_Duplicates_from_Sorted_Array.md)
- + [027 Remove Element](docs/leetcode/python/027._Remove_Element.md)
- + [028 implement strstr()](docs/leetcode/python/028._implement_strstr.md)
- + [030 Substring with Concatenation of All Words](docs/leetcode/python/030._Substring_with_Concatenation_of_All_Words.md)
- + [031 next permutation](docs/leetcode/python/031._next_permutation.md)
- + [032 longest valid parentheses](docs/leetcode/python/032._longest_valid_parentheses.md)
- + [033 search in rotated sorted array](docs/leetcode/python/033._search_in_rotated_sorted_array.md)
- + [034 Search for a Range](docs/leetcode/python/034._Search_for_a_Range.md)
- + [035 search insert position](docs/leetcode/python/035._search_insert_position.md)
- + [038 Count and Say](docs/leetcode/python/038._Count_and_Say.md)
- + [039 combination sum](docs/leetcode/python/039._combination_sum.md)
- + [040 combination sum ii](docs/leetcode/python/040._combination_sum_ii.md)
- + [041 First Missing Positive](docs/leetcode/python/041._First_Missing_Positive.md)
- + [042 trapping rain water](docs/leetcode/python/042._trapping_rain_water.md)
- + [043 multiply strings](docs/leetcode/python/043._multiply_strings.md)
- + [044 wildcard matching](docs/leetcode/python/044._wildcard_matching.md)
- + [045 Jump Game II](docs/leetcode/python/045._Jump_Game_II.md)
- + [046 permutations](docs/leetcode/python/046._permutations.md)
- + [047 permutations ii](docs/leetcode/python/047._permutations_ii.md)
- + [048 rotate image](docs/leetcode/python/048._rotate_image.md)
- + [049 group anagrams python](docs/leetcode/python/049._group_anagrams_python.md)
- + [050 pow(x, n)](docs/leetcode/python/050._pow(x,_n).md)
- + [051 n-queens](docs/leetcode/python/051._n-queens.md)
- + [052 n-queens ii](docs/leetcode/python/052._n-queens_ii.md)
- + [053 maximum subarray](docs/leetcode/python/053._maximum_subarray.md)
- + [054 spiral matrix](docs/leetcode/python/054._spiral_matrix.md)
- + [055 jump game](docs/leetcode/python/055._jump_game.md)
- + [056 Merge Intervals](docs/leetcode/python/056._Merge_Intervals.md)
- + [058 length of last word](docs/leetcode/python/058._length_of_last_word.md)
- + [059 spiral matrix ii](docs/leetcode/python/059._spiral_matrix_ii.md)
- + [060 permutation sequence](docs/leetcode/python/060._permutation_sequence.md)
- + [061 rotate list](docs/leetcode/python/061._rotate_list.md)
- + [062 unique paths](docs/leetcode/python/062._unique_paths.md)
- + [064 minimum path sum](docs/leetcode/python/064._minimum_path_sum.md)
- + [065 unique paths ii](docs/leetcode/python/065.unique_paths_ii.md)
- + [066 plus one](docs/leetcode/python/066._plus_one.md)
- + [067 add binary](docs/leetcode/python/067._add_binary.md)
- + [069 sqrt(x)](docs/leetcode/python/069._sqrt(x).md)
- + [070 Climbing Stairs](docs/leetcode/python/070._Climbing_Stairs.md)
- + [072 edit distance](docs/leetcode/python/072._edit_distance.md)
- + [073 Set Matrix Zeroes](docs/leetcode/python/073._Set_Matrix_Zeroes.md)
- + [074 search a 2d matrix](docs/leetcode/python/074._search_a_2d_matrix.md)
- + [075 sort colors](docs/leetcode/python/075._sort_colors.md)
- + [076 Minimum Window Substring](docs/leetcode/python/076._Minimum_Window_Substring.md)
- + [077 combinations](docs/leetcode/python/077._combinations.md)
- + [078 Subsets](docs/leetcode/python/078._Subsets.md)
- + [079 word search](docs/leetcode/python/079._word_search.md)
- + [082 remove duplicates from sorted list ii](docs/leetcode/python/082._remove_duplicates_from_sorted_list_ii.md)
- + [083 remove duplicates from sorted list](docs/leetcode/python/083._remove_duplicates_from_sorted_list.md)
- + [086 partition list](docs/leetcode/python/086._partition_list.md)
- + [088 merge sorted array](docs/leetcode/python/088._merge_sorted_array.md)
- + [089 gray code](docs/leetcode/python/089._gray_code.md)
- + [090 subsets ii](docs/leetcode/python/090._subsets_ii.md)
- + [091 decode ways](docs/leetcode/python/091._decode_ways.md)
- + [092 reverse linked list ii](docs/leetcode/python/092._reverse_linked_list_ii.md)
- + [093 restore ip addresses](docs/leetcode/python/093._restore_ip_addresses.md)
- + [094 binary tree inorder traversal](docs/leetcode/python/094._binary_tree_inorder_traversal.md)
- + [096 unique binary search trees](docs/leetcode/python/096._unique_binary_search_trees.md)
- + [098 validate binary search tree](docs/leetcode/python/098._validate_binary_search_tree.md)
- + [100 same tree](docs/leetcode/python/100._same_tree.md)
- + [101 symmetric tree](docs/leetcode/python/101._symmetric_tree.md)
- + [102 binary tree level order traversal](docs/leetcode/python/102._binary_tree_level_order_traversal.md)
- + [103 binary tree zigzag level order traversal](docs/leetcode/python/103._binary_tree_zigzag_level_order_traversal.md)
- + [104 maximum depth of binary tree](docs/leetcode/python/104._maximum_depth_of_binary_tree.md)
- + [105 construct binary tree from preorder and inorder traversal](docs/leetcode/python/105._construct_binary_tree_from_preorder_and_inorder_traversal.md)
- + [106 construct binary tree from inorder and postorder traversal](docs/leetcode/python/106._construct_binary_tree_from_inorder_and_postorder_traversal.md)
- + [107 binary tree level order traversal ii](docs/leetcode/python/107._binary_tree_level_order_traversal_ii.md)
- + [108 convert sorted array to binary search tree](docs/leetcode/python/108._convert_sorted_array_to_binary_search_tree.md)
- + [109 convert sorted list to binary search tree](docs/leetcode/python/109._convert_sorted_list_to_binary_search_tree.md)
- + [110 balanced binary tree](docs/leetcode/python/110._balanced_binary_tree.md)
- + [111 minimum depth of binary tree](docs/leetcode/python/111._minimum_depth_of_binary_tree.md)
- + [112 path sum](docs/leetcode/python/112._path_sum.md)
- + [113 path sum ii](docs/leetcode/python/113._path_sum_ii.md)
- + [114 flatten binary tree to linked list](docs/leetcode/python/114._flatten_binary_tree_to_linked_list.md)
- + [116 populating next right pointers in each node](docs/leetcode/python/116._populating_next_right_pointers_in_each_node.md)
- + [117 Populating Next Right Pointers in Each Node II](docs/leetcode/python/117._Populating_Next_Right_Pointers_in_Each_Node_II.md)
- + [118 pascal's triangle](docs/leetcode/python/118._pascal's_triangle.md)
- + [119 Pascal's Triangle II](docs/leetcode/python/119._Pascal's_Triangle_II.md)
- + [120 Triangle](docs/leetcode/python/120._Triangle.md)
- + [121 Best Time to Buy and Sell Stock](docs/leetcode/python/121._Best_Time_to_Buy_and_Sell_Stock.md)
- + [124 Binary Tree Maximum Path Sum](docs/leetcode/python/124._Binary_Tree_Maximum_Path_Sum.md)
- + [125 valid palindrome](docs/leetcode/python/125._valid_palindrome.md)
- + [126 Word Ladder II](docs/leetcode/python/126._Word_Ladder_II.md)
- + [127 word ladder](docs/leetcode/python/127._word_ladder.md)
- + [128 Longest Consecutive Sequence](docs/leetcode/python/128._Longest_Consecutive_Sequence.md)
- + [129 sum root to leaf numbers](docs/leetcode/python/129._sum_root_to_leaf_numbers.md)
- + [130 surrounded regions](docs/leetcode/python/130._surrounded_regions.md)
- + [131 palindrome partitioning](docs/leetcode/python/131._palindrome_partitioning.md)
- + [133 clone graph](docs/leetcode/python/133._clone_graph.md)
- + [136 single number](docs/leetcode/python/136._single_number.md)
- + [139 word break](docs/leetcode/python/139._word_break.md)
- + [140 word break ii](docs/leetcode/python/140._word_break_ii.md)
- + [141 linked list cycle](docs/leetcode/python/141._linked_list_cycle.md)
- + [142_Linked_List_Cycle_II md](docs/leetcode/python/142_Linked_List_Cycle_II.md)
- + [143 reorder list](docs/leetcode/python/143._reorder_list.md)
- + [144 binary tree preorder traversal](docs/leetcode/python/144._binary_tree_preorder_traversal.md)
- + [145 binary tree postorder traversal](docs/leetcode/python/145._binary_tree_postorder_traversal.md)
- + [147 insertion sort list](docs/leetcode/python/147._insertion_sort_list.md)
- + [148 sort list](docs/leetcode/python/148._sort_list.md)
- + [150 evaluate reverse polish notation](docs/leetcode/python/150._evaluate_reverse_polish_notation.md)
- + [151 reverse words in a string](docs/leetcode/python/151._reverse_words_in_a_string.md)
- + [152 maximum product subarray](docs/leetcode/python/152._maximum_product_subarray.md)
- + [153 find minimum in rotated sorted array](docs/leetcode/python/153._find_minimum_in_rotated_sorted_array.md)
- + [155 min stack](docs/leetcode/python/155._min_stack.md)
- + [157 Read N Characters Given Read4](docs/leetcode/python/157._Read_N_Characters_Given_Read4.md)
- + [158 Read N Characters Given Read4 II - Call multiple times](docs/leetcode/python/158._Read_N_Characters_Given_Read4_II_-_Call_multiple_times.md)
- + [159 Longest Substring with At Most Two Distinct Characters](docs/leetcode/python/159._Longest_Substring_with_At_Most_Two_Distinct_Characters.md)
- + [160 intersection of two linked lists](docs/leetcode/python/160._intersection_of_two_linked_lists.md)
- + [162 find peak element](docs/leetcode/python/162._find_peak_element.md)
- + [165 compare version numbers](docs/leetcode/python/165._compare_version_numbers.md)
- + [166 Fraction to Recurring Decimal](docs/leetcode/python/166._Fraction_to_Recurring_Decimal.md)
- + [167 two sum ii - input array is sorted](docs/leetcode/python/167._two_sum_ii_-_input_array_is_sorted.md)
- + [168 excel sheet column title](docs/leetcode/python/168._excel_sheet_column_title.md)
- + [169 majority element](docs/leetcode/python/169._majority_element.md)
- + [171 excel sheet column number](docs/leetcode/python/171._excel_sheet_column_number.md)
- + [173 binary search tree iterator](docs/leetcode/python/173._binary_search_tree_iterator.md)
- + [179 Largest Number](docs/leetcode/python/179._Largest_Number.md)
- + [182 duplicate emails](docs/leetcode/python/182._duplicate_emails.md)
- + [189 rotate array](docs/leetcode/python/189._rotate_array.md)
- + [191 number of 1 bits](docs/leetcode/python/191._number_of_1_bits.md)
- + [198 house robber](docs/leetcode/python/198._house_robber.md)
- + [199 binary tree right side view](docs/leetcode/python/199._binary_tree_right_side_view.md)
- + [200 number of islands](docs/leetcode/python/200._number_of_islands.md)
- + [203 remove linked list elements](docs/leetcode/python/203._remove_linked_list_elements.md)
- + [204 count primes](docs/leetcode/python/204._count_primes.md)
- + [205 isomorphic strings](docs/leetcode/python/205._isomorphic_strings.md)
- + [206 reverse linked list](docs/leetcode/python/206._reverse_linked_list.md)
- + [207 course schedule](docs/leetcode/python/207._course_schedule.md)
- + [208 implement trie (prefix tree)](docs/leetcode/python/208._implement_trie_(prefix_tree).md)
- + [210 course schedule ii](docs/leetcode/python/210._course_schedule_ii.md)
- + [211 Add and Search Word - Data structure design](docs/leetcode/python/211._Add_and_Search_Word_-_Data_structure_design.md)
- + [213 house robber ii](docs/leetcode/python/213._house_robber_ii.md)
- + [216 combination sum iii](docs/leetcode/python/216._combination_sum_iii.md)
- + [217 contains duplicate](docs/leetcode/python/217._contains_duplicate.md)
- + [218 The Skyline Problem](docs/leetcode/python/218._The_Skyline_Problem.md)
- + [219 contains duplicate ii](docs/leetcode/python/219._contains_duplicate_ii.md)
- + [221 maximal square](docs/leetcode/python/221._maximal_square.md)
- + [222 count complete tree nodes](docs/leetcode/python/222._count_complete_tree_nodes.md)
- + [223 rectangle area](docs/leetcode/python/223._rectangle_area.md)
- + [224 Basic Calculator](docs/leetcode/python/224._Basic_Calculator.md)
- + [225 implement stack using queues](docs/leetcode/python/225._implement_stack_using_queues.md)
- + [226 invert binary tree](docs/leetcode/python/226._invert_binary_tree.md)
- + [227 basic calculator ii](docs/leetcode/python/227._basic_calculator_ii.md)
- + [228 summary ranges](docs/leetcode/python/228._summary_ranges.md)
- + [229 majority element ii](docs/leetcode/python/229._majority_element_ii.md)
- + [230 kth smallest element in a bst](docs/leetcode/python/230._kth_smallest_element_in_a_bst.md)
- + [231 Power of Two](docs/leetcode/python/231._Power_of_Two.md)
- + [232 implement queue using stacks](docs/leetcode/python/232._implement_queue_using_stacks.md)
- + [234 palindrome linked list](docs/leetcode/python/234._palindrome_linked_list.md)
- + [235 lowest common ancestor of a binary search tree](docs/leetcode/python/235._lowest_common_ancestor_of_a_binary_search_tree.md)
- + [236 lowest common ancestor of a binary tree](docs/leetcode/python/236._lowest_common_ancestor_of_a_binary_tree.md)
- + [237 delete node in a linked list](docs/leetcode/python/237._delete_node_in_a_linked_list.md)
- + [238 product of array except self](docs/leetcode/python/238._product_of_array_except_self.md)
- + [240 search a 2d matrix ii](docs/leetcode/python/240._search_a_2d_matrix_ii.md)
- + [242 valid anagram](docs/leetcode/python/242._valid_anagram.md)
- + [249 Group Shifted Strings](docs/leetcode/python/249._Group_Shifted_Strings.md)
- + [252 Meeting Rooms](docs/leetcode/python/252._Meeting_Rooms.md)
- + [255 Verify Preorder Sequence in Binary Search Tree](docs/leetcode/python/255._Verify_Preorder_Sequence_in_Binary_Search_Tree.md)
- + [256 Paint House](docs/leetcode/python/256._Paint_House.md)
- + [257 binary tree paths](docs/leetcode/python/257._binary_tree_paths.md)
- + [258_Add_Digits md](docs/leetcode/python/258._Add_Digits.md)
- + [261 Graph Valid Tree](docs/leetcode/python/261._Graph_Valid_Tree.md)
- + [263 ugly number](docs/leetcode/python/263._ugly_number.md)
- + [264 ugly number ii](docs/leetcode/python/264._ugly_number_ii.md)
- + [265 Paint House II](docs/leetcode/python/265._Paint_House_II.md)
- + [266 Palindrome Permutation](docs/leetcode/python/266._Palindrome_Permutation.md)
- + [267 Palindrome Permutation II](docs/leetcode/python/267._Palindrome_Permutation_II.md)
- + [268 missing number](docs/leetcode/python/268._missing_number.md)
- + [270 Closest Binary Search Tree Value](docs/leetcode/python/270._Closest_Binary_Search_Tree_Value.md)
- + [276 Paint Fence](docs/leetcode/python/276._Paint_Fence.md)
- + [277 Find the Celebrity](docs/leetcode/python/277._Find_the_Celebrity.md)
- + [278 First Bad Version](docs/leetcode/python/278._First_Bad_Version.md)
- + [279 perfect squares](docs/leetcode/python/279._perfect_squares.md)
- + [280 Wiggle Sort](docs/leetcode/python/280._Wiggle_Sort.md)
- + [283 move zeroes](docs/leetcode/python/283._move_zeroes.md)
- + [285 inorder successor in bst](docs/leetcode/python/285._inorder_successor_in_bst.md)
- + [286 Walls and Gates](docs/leetcode/python/286._Walls_and_Gates.md)
- + [287 Find the Duplicate Number](docs/leetcode/python/287._Find_the_Duplicate_Number.md)
- + [289 game of life](docs/leetcode/python/289._game_of_life.md)
- + [290 word pattern](docs/leetcode/python/290._word_pattern.md)
- + [292 nim game](docs/leetcode/python/292._nim_game.md)
- + [293 Flip Game](docs/leetcode/python/293._Flip_Game.md)
- + [296 Best Meeting Point](docs/leetcode/python/296._Best_Meeting_Point.md)
- + [298 Binary Tree Longest Consecutive Sequence](docs/leetcode/python/298._Binary_Tree_Longest_Consecutive_Sequence.md)
- + [299 bulls and cows](docs/leetcode/python/299._bulls_and_cows.md)
- + [300 longest increasing subsequence](docs/leetcode/python/300._longest_increasing_subsequence.md)
- + [303 range sum query - immutable](docs/leetcode/python/303._range_sum_query_-_immutable.md)
- + [316 Remove Duplicate Letters](docs/leetcode/python/316._Remove_Duplicate_Letters.md)
- + [319 Bulb Switcher](docs/leetcode/python/319._Bulb_Switcher.md)
- + [322 Coin Change](docs/leetcode/python/322._Coin_Change.md)
- + [323 number of connected components in an undirected graph](docs/leetcode/python/323._number_of_connected_components_in_an_undirected_graph.md)
- + [324 Wiggle Sort II](docs/leetcode/python/324._Wiggle_Sort_II.md)
- + [326 power of three](docs/leetcode/python/326._power_of_three.md)
- + [328 odd even linked list](docs/leetcode/python/328._odd_even_linked_list.md)
- + [334 increasing triplet subsequence](docs/leetcode/python/334._increasing_triplet_subsequence.md)
- + [337 house robber iii](docs/leetcode/python/337._house_robber_iii.md)
- + [338 Counting Bits](docs/leetcode/python/338._Counting_Bits.md)
- + [339 Nested List Weight Sum](docs/leetcode/python/339._Nested_List_Weight_Sum.md)
- + [341 Flatten Nested List Iterator](docs/leetcode/python/341._Flatten_Nested_List_Iterator.md)
- + [342 Power of Four](docs/leetcode/python/342._Power_of_Four.md)
- + [344 reverse string](docs/leetcode/python/344._reverse_string.md)
- + [345 Reverse Vowels of a String](docs/leetcode/python/345._Reverse_Vowels_of_a_String.md)
- + [349 intersection of two arrays](docs/leetcode/python/349._intersection_of_two_arrays.md)
- + [350 intersection of two arrays ii](docs/leetcode/python/350._intersection_of_two_arrays_ii.md)
- + [353 Design Snake Game](docs/leetcode/python/353._Design_Snake_Game.md)
- + [361 Bomb Enemy](docs/leetcode/python/361._Bomb_Enemy.md)
- + [364 Nested List Weight Sum II](docs/leetcode/python/364._Nested_List_Weight_Sum_II.md)
- + [366 Find Leaves of Binary Tree](docs/leetcode/python/366._Find_Leaves_of_Binary_Tree.md)
- + [367 valid perfect square](docs/leetcode/python/367._valid_perfect_square.md)
- + [369 Plus One Linked List](docs/leetcode/python/369._Plus_One_Linked_List.md)
- + [371 sum of two integers](docs/leetcode/python/371._sum_of_two_integers.md)
- + [374 Guess Number Higher or Lower](docs/leetcode/python/374._Guess_Number_Higher_or_Lower.md)
- + [377 combination sum iv](docs/leetcode/python/377._combination_sum_iv.md)
- + [378 kth smallest element in a sorted matrix](docs/leetcode/python/378._kth_smallest_element_in_a_sorted_matrix.md)
- + [380 Insert Delete GetRandom O(1)](docs/leetcode/python/380._Insert_Delete_GetRandom_O(1).md)
- + [381 Insert Delete GetRandom O(1) - Duplicates allowed](docs/leetcode/python/381._Insert_Delete_GetRandom_O(1)_-_Duplicates_allowed.md)
- + [382 linked list random node](docs/leetcode/python/382._linked_list_random_node.md)
- + [383 ransom note](docs/leetcode/python/383._ransom_note.md)
- + [384 Shuffle an Array](docs/leetcode/python/384._Shuffle_an_Array.md)
- + [386 Lexicographical Numbers](docs/leetcode/python/386._Lexicographical_Numbers.md)
- + [387 first unique character in a string](docs/leetcode/python/387._first_unique_character_in_a_string.md)
- + [388 Longest Absolute File Path](docs/leetcode/python/388._Longest_Absolute_File_Path.md)
- + [389 find the difference](docs/leetcode/python/389._find_the_difference.md)
- + [392 is subsequence](docs/leetcode/python/392._is_subsequence.md)
- + [394 decode string](docs/leetcode/python/394._decode_string.md)
- + [400 Nth Digit](docs/leetcode/python/400._Nth_Digit.md)
- + [401 binary watch](docs/leetcode/python/401._binary_watch.md)
- + [404 sum of left leaves](docs/leetcode/python/404._sum_of_left_leaves.md)
- + [405 Convert a Number to Hexadecimal](docs/leetcode/python/405._Convert_a_Number_to_Hexadecimal.md)
- + [406 Queue Reconstruction by Height](docs/leetcode/python/406._Queue_Reconstruction_by_Height.md)
- + [412 fizz buzz](docs/leetcode/python/412._fizz_buzz.md)
- + [413 Arithmetic Slices](docs/leetcode/python/413._Arithmetic_Slices.md)
- + [414 third maximum number](docs/leetcode/python/414._third_maximum_number.md)
- + [415 add strings](docs/leetcode/python/415._add_strings.md)
- + [416 Partition Equal Subset Sum](docs/leetcode/python/416._Partition_Equal_Subset_Sum.md)
- + [421 Maximum XOR of Two Numbers in an Array](docs/leetcode/python/421._Maximum_XOR_of_Two_Numbers_in_an_Array.md)
- + [422 Valid Word Square](docs/leetcode/python/422._Valid_Word_Square.md)
- + [434 number of segments in a string](docs/leetcode/python/434._number_of_segments_in_a_string.md)
- + [435 Non-overlapping Intervals](docs/leetcode/python/435._Non-overlapping_Intervals.md)
- + [437 path sum iii](docs/leetcode/python/437._path_sum_iii.md)
- + [438 Find All Anagrams in a String](docs/leetcode/python/438._Find_All_Anagrams_in_a_String.md)
- + [439 Ternary Expression Parser](docs/leetcode/python/439._Ternary_Expression_Parser.md)
- + [441 arranging coins](docs/leetcode/python/441._arranging_coins.md)
- + [448 Find All Numbers Disappeared in an Array](docs/leetcode/python/448._Find_All_Numbers_Disappeared_in_an_Array.md)
- + [450 Delete Node in a BST](docs/leetcode/python/450._Delete_Node_in_a_BST.md)
- + [453 Minimum Moves to Equal Array Elements](docs/leetcode/python/453._Minimum_Moves_to_Equal_Array_Elements.md)
- + [459 Repeated Substring Pattern](docs/leetcode/python/459._Repeated_Substring_Pattern.md)
- + [461 Hamming Distance](docs/leetcode/python/461._Hamming_Distance.md)
- + [463 Island Perimeter](docs/leetcode/python/463._Island_Perimeter.md)
- + [467 Unique Substrings in Wraparound String](docs/leetcode/python/467._Unique_Substrings_in_Wraparound_String.md)
- + [469 Convex Polygon](docs/leetcode/python/469._Convex_Polygon.md)
- + [476 Number Complement](docs/leetcode/python/476._Number_Complement.md)
- + [477 Total Hamming Distance](docs/leetcode/python/477._Total_Hamming_Distance.md)
- + [485 Max Consecutive Ones](docs/leetcode/python/485._Max_Consecutive_Ones.md)
- + [494 Target Sum](docs/leetcode/python/494._Target_Sum.md)
- + [536 Construct Binary Tree from String](docs/leetcode/python/536._Construct_Binary_Tree_from_String.md)
- + [587 Erect the Fence](docs/leetcode/python/587._Erect_the_Fence.md)
- + [599 Minimum Index Sum of Two Lists](docs/leetcode/python/599._Minimum_Index_Sum_of_Two_Lists.md)
- + [606 Construct String from Binary Tree](docs/leetcode/python/606._Construct_String_from_Binary_Tree.md)
- + [611 Valid Triangle Number](docs/leetcode/python/611._Valid_Triangle_Number.md)
- + [646 Maximum Length of Pair Chain](docs/leetcode/python/646._Maximum_Length_of_Pair_Chain.md)
- + [647 Palindromic Substrings](docs/leetcode/python/647._Palindromic_Substrings.md)
- + [657 Judge Route Circle](docs/leetcode/python/657._Judge_Route_Circle.md)
- + [665 Non-decreasing Array](docs/leetcode/python/665._Non-decreasing_Array.md)
- + [672 Bulb Switcher II](docs/leetcode/python/672._Bulb_Switcher_II.md)
- + [681 Next Closest Time](docs/leetcode/python/681._Next_Closest_Time.md)
- + [682 Baseball Game](docs/leetcode/python/682._Baseball_Game.md)
- + [685 Redundant Connection II](docs/leetcode/python/685._Redundant_Connection_II.md)
- + [687 Longest Univalue Path](docs/leetcode/python/687._Longest_Univalue_Path.md)
- + [693 Binary Number with Alternating Bits](docs/leetcode/python/693._Binary_Number_with_Alternating_Bits.md)
- + [701 Insert into a Binary Search Tree](docs/leetcode/python/701._Insert_into_a_Binary_Search_Tree.md)
- + [707 Design Linked List](docs/leetcode/python/707._Design_Linked_List.md)
- + [740 delete and earn](docs/leetcode/python/740._delete_and_earn.md)
- + [760 Find Anagram Mappings](docs/leetcode/python/760._Find_Anagram_Mappings.md)
- + [774 Minimize Max Distance to Gas Station](docs/leetcode/python/774._Minimize_Max_Distance_to_Gas_Station.md)
- + [777 Swap Adjacent in LR String](docs/leetcode/python/777._Swap_Adjacent_in_LR_String.md)
- + [844 Backspace String Compare](docs/leetcode/python/844._Backspace_String_Compare.md)
-+ [剑指 Offer Java 题解](docs/jianzhioffer/java/README.md)
- + [找出数组中重复的数字](docs/jianzhioffer/java/03_01_DuplicationInArray.md)
- + [不修改数组找出重复的数字](docs/jianzhioffer/java/03_02_DuplicationInArrayNoEdit.md)
- + [二维数组中的查找](docs/jianzhioffer/java/04_FindInPartiallySortedMatrix.md)
- + [替换空格](docs/jianzhioffer/java/05_ReplaceSpaces.md)
- + [从尾到头打印链表](docs/jianzhioffer/java/06_PrintListInReversedOrder.md)
- + [重建二叉树](docs/jianzhioffer/java/07_ConstructBinaryTree.md)
- + [二叉树的下一个结点](docs/jianzhioffer/java/08_NextNodeInBinaryTrees.md)
- + [用两个栈实现队列](docs/jianzhioffer/java/09_01_QueueWithTwoStacks.md)
- + [用两个队列实现栈](docs/jianzhioffer/java/09_02_StackWithTwoQueues.md)
- + [斐波那契数列](docs/jianzhioffer/java/10_01_Fibonacci.md)
- + [跳台阶](docs/jianzhioffer/java/10_02_JumpFloor.md)
- + [变态跳台阶](docs/jianzhioffer/java/10_03_JumpFloorII.md)
- + [矩形覆盖](docs/jianzhioffer/java/10_04_RectCover.md)
- + [旋转数组的最小数字](docs/jianzhioffer/java/11_MinNumberInRotatedArray.md)
- + [矩阵中的路径](docs/jianzhioffer/java/12_StringPathInMatrix.md)
- + [机器人的移动范围](docs/jianzhioffer/java/13_RobotMove.md)
- + [剪绳子](docs/jianzhioffer/java/14_CuttingRope.md)
- + [二进制中 1 的个数](docs/jianzhioffer/java/15_NumberOf1InBinary.md)
- + [数值的整数次方](docs/jianzhioffer/java/16_Power.md)
- + [打印从 1 到最大的 n 位数](docs/jianzhioffer/java/17_Print1ToMaxOfNDigits.md)
- + [在O(1)时间内删除链表节点](docs/jianzhioffer/java/18_01_DeleteNodeInList.md)
- + [删除链表中重复的节点](docs/jianzhioffer/java/18_02_DeleteDuplicatedNode.md)
- + [正则表达式匹配](docs/jianzhioffer/java/19_RegularExpressionsMatching.md)
- + [表示数值的字符串](docs/jianzhioffer/java/20_NumericStrings.md)
- + [调整数组顺序使奇数位于偶数前面](docs/jianzhioffer/java/21_ReorderArray.md)
- + [链表中倒数第k个结点](docs/jianzhioffer/java/22_KthNodeFromEnd.md)
- + [链表中环的入口结点](docs/jianzhioffer/java/23_EntryNodeInListLoop.md)
- + [反转链表](docs/jianzhioffer/java/24_ReverseList.md)
- + [合并两个排序的链表](docs/jianzhioffer/java/25_MergeSortedLists.md)
- + [树的子结构](docs/jianzhioffer/java/26_SubstructureInTree.md)
- + [二叉树的镜像](docs/jianzhioffer/java/27_MirrorOfBinaryTree.md)
- + [对称的二叉树](docs/jianzhioffer/java/28_SymmetricalBinaryTree.md)
- + [顺时针打印矩阵](docs/jianzhioffer/java/29_PrintMatrix.md)
- + [包含min函数的栈](docs/jianzhioffer/java/30_MinInStack.md)
- + [栈的压入、弹出序列](docs/jianzhioffer/java/31_StackPushPopOrder.md)
- + [不分行从上到下打印二叉树](docs/jianzhioffer/java/32_01_PrintTreeFromTopToBottom.md)
- + [把二叉树打印成多行](docs/jianzhioffer/java/32_02_PrintTreesInLines.md)
- + [按之字形打印二叉树](docs/jianzhioffer/java/32_03_PrintTreesInZigzag.md)
- + [二叉搜索树的后序遍历序列](docs/jianzhioffer/java/33_SquenceOfBST.md)
- + [二叉树中和为某一值的路径](docs/jianzhioffer/java/34_PathInTree.md)
- + [复杂链表的复制](docs/jianzhioffer/java/35_CopyComplexList.md)
- + [二叉搜索树与双向链表](docs/jianzhioffer/java/36_ConvertBinarySearchTree.md)
- + [序列化二叉树](docs/jianzhioffer/java/37_SerializeBinaryTrees.md)
- + [字符串的排列](docs/jianzhioffer/java/38_StringPermutation.md)
- + [数组中出现次数超过一半的数字](docs/jianzhioffer/java/39_MoreThanHalfNumber.md)
- + [获取数组中最小的k个数](docs/jianzhioffer/java/40_KLeastNumbers.md)
- + [数据流中的中位数](docs/jianzhioffer/java/41_StreamMedian.md)
- + [连续子数组的最大和](docs/jianzhioffer/java/42_GreatestSumOfSubarrays.md)
- + [整数中1出现的次数](docs/jianzhioffer/java/43_NumberOf1.md)
- + [数字序列中某一位的数字](docs/jianzhioffer/java/44_DigitsInSequence.md)
- + [把数组排成最小的数](docs/jianzhioffer/java/45_SortArrayForMinNumber.md)
- + [把数字翻译成字符串](docs/jianzhioffer/java/46_TranslateNumbersToStrings.md)
- + [礼物的最大价值](docs/jianzhioffer/java/47_MaxValueOfGifts.md)
- + [最长不含重复字符的子字符串](docs/jianzhioffer/java/48_LongestSubstringWithoutDup.md)
- + [丑数](docs/jianzhioffer/java/49_UglyNumber.md)
- + [第一个只出现一次的字符](docs/jianzhioffer/java/50_01_FirstNotRepeatingChar.md)
- + [字符流中第一个不重复的字符](docs/jianzhioffer/java/50_02_FristCharacterInStream.md)
- + [两个链表的第一个公共结点](docs/jianzhioffer/java/52_FirstCommonNodesInLists.md)
- + [数字在排序数组中出现的次数](docs/jianzhioffer/java/53_01_NumberOfK.md)
- + [0到n-1中缺失的数字](docs/jianzhioffer/java/53_02_MissingNumber.md)
- + [数组中数值和下标相等的元素](docs/jianzhioffer/java/53_03_IntegerIdenticalToIndex.md)
- + [二叉搜索树的第k个结点](docs/jianzhioffer/java/54_KthNodeInBST.md)
- + [二叉树的深度](docs/jianzhioffer/java/55_01_TreeDepth.md)
- + [平衡二叉树](docs/jianzhioffer/java/55_02_BalancedBinaryTree.md)
- + [数组中只出现一次的两个数字](docs/jianzhioffer/java/56_01_NumbersAppearOnce.md)
- + [数组中唯一只出现一次的数字](docs/jianzhioffer/java/56_02_NumberAppearingOnce.md)
- + [和为S的两个数字](docs/jianzhioffer/java/57_01_TwoNumbersWithSum.md)
- + [和为S的连续正数序列](docs/jianzhioffer/java/57_02_ContinuousSquenceWithSum.md)
- + [翻转单词顺序](docs/jianzhioffer/java/58_01_ReverseWordsInSentence.md)
- + [左旋转字符串](docs/jianzhioffer/java/58_02_LeftRotateString.md)
- + [滑动窗口的最大值](docs/jianzhioffer/java/59_01_MaxInSlidingWindow.md)
- + [扑克牌的顺子](docs/jianzhioffer/java/61_ContinousCards.md)
diff --git a/asset/back-to-top.css b/asset/back-to-top.css
deleted file mode 100644
index bcb3d5a75..000000000
--- a/asset/back-to-top.css
+++ /dev/null
@@ -1,19 +0,0 @@
-#scroll-btn {
- position: fixed;
- right: 15px;
- bottom: 10px;
- width: 35px;
- height: 35px;
- background-repeat: no-repeat;
- background-size: cover;
- cursor: pointer;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- background-image: url(http://github.com/up.svg);
- background-position-y: -1px;
- display: none;
- border: 2px solid;
- border-radius: 4px;
-}
\ No newline at end of file
diff --git a/asset/back-to-top.js b/asset/back-to-top.js
deleted file mode 100644
index 3efad9be0..000000000
--- a/asset/back-to-top.js
+++ /dev/null
@@ -1,20 +0,0 @@
-document.addEventListener('DOMContentLoaded', function() {
- var scrollBtn = document.createElement('div')
- scrollBtn.id = 'scroll-btn'
- document.body.append(scrollBtn)
-
- window.addEventListener('scroll', function() {
- var offset = window.document.documentElement.scrollTop;
- scrollBtn.style.display = offset >= 500 ? "block" : "none";
- })
- scrollBtn.addEventListener('click', function(e) {
- e.stopPropagation();
- var step = window.scrollY / 15;
- var hdl = setInterval(function() {
- window.scrollTo(0, window.scrollY - step);
- if(window.scrollY <= 0) {
- clearInterval(hdl)
- }
- }, 15)
- })
-})
\ No newline at end of file
diff --git a/asset/dark-mode.css b/asset/dark-mode.css
deleted file mode 100644
index 4aa47afcb..000000000
--- a/asset/dark-mode.css
+++ /dev/null
@@ -1,23 +0,0 @@
-#dark-mode-btn {
- position: fixed;
- right: 15px;
- top: 100px;
- width: 35px;
- height: 35px;
- background-repeat: no-repeat;
- background-size: cover;
- cursor: pointer;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- transition: background-image .15s ease-in-out .15s;
-}
-
-.dark-logo {
- background-image: url('http://github.com/sun.svg');
-}
-
-.light-logo {
- background-image: url('http://github.com/moon.svg');
-}
\ No newline at end of file
diff --git a/asset/dark-mode.js b/asset/dark-mode.js
deleted file mode 100644
index 471dcf800..000000000
--- a/asset/dark-mode.js
+++ /dev/null
@@ -1,42 +0,0 @@
-document.addEventListener('DOMContentLoaded', function() {
- var style = document.querySelector('#invert')
- if (style == null) {
- style = document.createElement('style')
- style.id = 'invert'
- document.head.append(style)
- }
- var btn = document.querySelector('#dark-mode-btn')
- if (btn == null) {
- btn = document.createElement('div')
- btn.id = 'dark-mode-btn'
- btn.classList.add('light-logo')
- document.body.append(btn)
- }
-
- var enableDarkMode = function() {
- style.innerText = 'html,img,pre,#dark-mode-btn{filter:invert(100%)}'
- btn.classList.remove('light-logo')
- btn.classList.add('dark-logo')
- localStorage.darkLight = 'dark'
-
- }
- var disableDarkMode = function() {
- style.innerText = ''
- btn.classList.remove('dark-logo')
- btn.classList.add('light-logo')
- localStorage.darkLight = 'light'
- }
-
- btn.addEventListener('click', function(){
- var currMode = localStorage.darkLight || 'light'
- if (currMode == 'light')
- enableDarkMode()
- else
- disableDarkMode()
- })
-
- if (localStorage.darkLight == 'dark')
- enableDarkMode()
-
-})
-
diff --git a/asset/docsify-apachecn-footer.js b/asset/docsify-apachecn-footer.js
deleted file mode 100644
index 0723a6b41..000000000
--- a/asset/docsify-apachecn-footer.js
+++ /dev/null
@@ -1,34 +0,0 @@
-(function(){
- var cnzzId = window.$docsify.cnzzId
- var unRepo = window.$docsify.repo || ''
- var [un, repo] = unRepo.split('/')
- var footer = `
-
-
- `
- var plugin = function(hook) {
- hook.afterEach(function(html) {
- return html + footer
- })
- hook.doneEach(function() {
- (adsbygoogle = window.adsbygoogle || []).push({})
- })
- }
- var plugins = window.$docsify.plugins || []
- plugins.push(plugin)
- window.$docsify.plugins = plugins
-})()
\ No newline at end of file
diff --git a/asset/docsify-baidu-push.js b/asset/docsify-baidu-push.js
deleted file mode 100644
index 27b1f7423..000000000
--- a/asset/docsify-baidu-push.js
+++ /dev/null
@@ -1,13 +0,0 @@
-(function(){
- var plugin = function(hook) {
- hook.doneEach(function() {
- new Image().src =
- '//api.share.baidu.com/s.gif?r=' +
- encodeURIComponent(document.referrer) +
- "&l=" + encodeURIComponent(location.href)
- })
- }
- var plugins = window.$docsify.plugins || []
- plugins.push(plugin)
- window.$docsify.plugins = plugins
-})()
\ No newline at end of file
diff --git a/asset/docsify-baidu-stat.js b/asset/docsify-baidu-stat.js
deleted file mode 100644
index 811aa35fb..000000000
--- a/asset/docsify-baidu-stat.js
+++ /dev/null
@@ -1,13 +0,0 @@
-(function(){
- var plugin = function(hook) {
- hook.doneEach(function() {
- window._hmt = window._hmt || []
- var hm = document.createElement("script")
- hm.src = "https://hm.baidu.com/hm.js?" + window.$docsify.bdStatId
- document.querySelector("article").appendChild(hm)
- })
- }
- var plugins = window.$docsify.plugins || []
- plugins.push(plugin)
- window.$docsify.plugins = plugins
-})()
\ No newline at end of file
diff --git a/asset/docsify-clicker.js b/asset/docsify-clicker.js
deleted file mode 100644
index 1b2a5729e..000000000
--- a/asset/docsify-clicker.js
+++ /dev/null
@@ -1,197 +0,0 @@
-(function() {
- var ids = [
- '109577065', '108852955', '102682374', '100520874', '92400861', '90312982',
- '109963325', '109323014', '109301511', '108898970', '108590722', '108538676',
- '108503526', '108437109', '108402202', '108292691', '108291153', '108268498',
- '108030854', '107867070', '107847299', '107827334', '107825454', '107802131',
- '107775320', '107752974', '107735139', '107702571', '107598864', '107584507',
- '107568311', '107526159', '107452391', '107437455', '107430050', '107395781',
- '107325304', '107283210', '107107145', '107085440', '106995421', '106993460',
- '106972215', '106959775', '106766787', '106749609', '106745967', '106634313',
- '106451602', '106180097', '106095505', '106077010', '106008089', '106002346',
- '105653809', '105647855', '105130705', '104837872', '104706815', '104192620',
- '104074941', '104040537', '103962171', '103793502', '103783460', '103774572',
- '103547748', '103547703', '103547571', '103490757', '103413481', '103341935',
- '103330191', '103246597', '103235808', '103204403', '103075981', '103015105',
- '103014899', '103014785', '103014702', '103014540', '102993780', '102993754',
- '102993680', '102958443', '102913317', '102903382', '102874766', '102870470',
- '102864513', '102811179', '102761237', '102711565', '102645443', '102621845',
- '102596167', '102593333', '102585262', '102558427', '102537547', '102530610',
- '102527017', '102504698', '102489806', '102372981', '102258897', '102257303',
- '102056248', '101920097', '101648638', '101516708', '101350577', '101268149',
- '101128167', '101107328', '101053939', '101038866', '100977414', '100945061',
- '100932401', '100886407', '100797378', '100634918', '100588305', '100572447',
- '100192249', '100153559', '100099032', '100061455', '100035392', '100033450',
- '99671267', '99624846', '99172551', '98992150', '98989508', '98987516', '98938304',
- '98937682', '98725145', '98521688', '98450861', '98306787', '98203342', '98026348',
- '97680167', '97492426', '97108940', '96888872', '96568559', '96509100', '96508938',
- '96508611', '96508374', '96498314', '96476494', '96333593', '96101522', '95989273',
- '95960507', '95771870', '95770611', '95766810', '95727700', '95588929', '95218707',
- '95073151', '95054615', '95016540', '94868371', '94839549', '94719281', '94401578',
- '93931439', '93853494', '93198026', '92397889', '92063437', '91635930', '91433989',
- '91128193', '90915507', '90752423', '90738421', '90725712', '90725083', '90722238',
- '90647220', '90604415', '90544478', '90379769', '90288341', '90183695', '90144066',
- '90108283', '90021771', '89914471', '89876284', '89852050', '89839033', '89812373',
- '89789699', '89786189', '89752620', '89636380', '89632889', '89525811', '89480625',
- '89464088', '89464025', '89463984', '89463925', '89445280', '89441793', '89430432',
- '89429877', '89416176', '89412750', '89409618', '89409485', '89409365', '89409292',
- '89409222', '89399738', '89399674', '89399526', '89355336', '89330241', '89308077',
- '89222240', '89140953', '89139942', '89134398', '89069355', '89049266', '89035735',
- '89004259', '88925790', '88925049', '88915838', '88912706', '88911548', '88899438',
- '88878890', '88837519', '88832555', '88824257', '88777952', '88752158', '88659061',
- '88615256', '88551434', '88375675', '88322134', '88322085', '88321996', '88321978',
- '88321950', '88321931', '88321919', '88321899', '88321830', '88321756', '88321710',
- '88321661', '88321632', '88321566', '88321550', '88321506', '88321475', '88321440',
- '88321409', '88321362', '88321321', '88321293', '88321226', '88232699', '88094874',
- '88090899', '88090784', '88089091', '88048808', '87938224', '87913318', '87905933',
- '87897358', '87856753', '87856461', '87827666', '87822008', '87821456', '87739137',
- '87734022', '87643633', '87624617', '87602909', '87548744', '87548689', '87548624',
- '87548550', '87548461', '87463201', '87385913', '87344048', '87078109', '87074784',
- '87004367', '86997632', '86997466', '86997303', '86997116', '86996474', '86995899',
- '86892769', '86892654', '86892569', '86892457', '86892347', '86892239', '86892124',
- '86798671', '86777307', '86762845', '86760008', '86759962', '86759944', '86759930',
- '86759922', '86759646', '86759638', '86759633', '86759622', '86759611', '86759602',
- '86759596', '86759591', '86759580', '86759572', '86759567', '86759558', '86759545',
- '86759534', '86749811', '86741502', '86741074', '86741059', '86741020', '86740897',
- '86694754', '86670104', '86651882', '86651875', '86651866', '86651828', '86651790',
- '86651767', '86651756', '86651735', '86651720', '86651708', '86618534', '86618526',
- '86594785', '86590937', '86550497', '86550481', '86550472', '86550453', '86550438',
- '86550429', '86550407', '86550381', '86550359', '86536071', '86536035', '86536014',
- '86535988', '86535963', '86535953', '86535932', '86535902', '86472491', '86472298',
- '86472236', '86472191', '86472108', '86471967', '86471899', '86471822', '86439022',
- '86438972', '86438902', '86438887', '86438867', '86438836', '86438818', '85850119',
- '85850075', '85850021', '85849945', '85849893', '85849837', '85849790', '85849740',
- '85849661', '85849620', '85849550', '85606096', '85564441', '85547709', '85471981',
- '85471317', '85471136', '85471073', '85470629', '85470456', '85470169', '85469996',
- '85469877', '85469775', '85469651', '85469331', '85469033', '85345768', '85345742',
- '85337900', '85337879', '85337860', '85337833', '85337797', '85322822', '85322810',
- '85322791', '85322745', '85317667', '85265742', '85265696', '85265618', '85265350',
- '85098457', '85057670', '85009890', '84755581', '84637437', '84637431', '84637393',
- '84637374', '84637355', '84637338', '84637321', '84637305', '84637283', '84637259',
- '84629399', '84629314', '84629233', '84629124', '84629065', '84628997', '84628933',
- '84628838', '84628777', '84628690', '84591581', '84591553', '84591511', '84591484',
- '84591468', '84591416', '84591386', '84591350', '84591308', '84572155', '84572107',
- '84503228', '84500221', '84403516', '84403496', '84403473', '84403442', '84075703',
- '84029659', '83933480', '83933459', '83933435', '83903298', '83903274', '83903258',
- '83752369', '83345186', '83116487', '83116446', '83116402', '83116334', '83116213',
- '82944248', '82941023', '82938777', '82936611', '82932735', '82918102', '82911085',
- '82888399', '82884263', '82883507', '82880996', '82875334', '82864060', '82831039',
- '82823385', '82795277', '82790832', '82775718', '82752022', '82730437', '82718126',
- '82661646', '82588279', '82588267', '82588261', '82588192', '82347066', '82056138',
- '81978722', '81211571', '81104145', '81069048', '81006768', '80788365', '80767582',
- '80759172', '80759144', '80759129', '80736927', '80661288', '80616304', '80602366',
- '80584625', '80561364', '80549878', '80549875', '80541470', '80539726', '80531328',
- '80513257', '80469816', '80406810', '80356781', '80334130', '80333252', '80332666',
- '80332389', '80311244', '80301070', '80295974', '80292252', '80286963', '80279504',
- '80278369', '80274371', '80249825', '80247284', '80223054', '80219559', '80209778',
- '80200279', '80164236', '80160900', '80153046', '80149560', '80144670', '80061205',
- '80046520', '80025644', '80014721', '80005213', '80004664', '80001653', '79990178',
- '79989283', '79947873', '79946002', '79941517', '79938786', '79932755', '79921178',
- '79911339', '79897603', '79883931', '79872574', '79846509', '79832150', '79828161',
- '79828156', '79828149', '79828146', '79828140', '79828139', '79828135', '79828123',
- '79820772', '79776809', '79776801', '79776788', '79776782', '79776772', '79776767',
- '79776760', '79776753', '79776736', '79776705', '79676183', '79676171', '79676166',
- '79676160', '79658242', '79658137', '79658130', '79658123', '79658119', '79658112',
- '79658100', '79658092', '79658089', '79658069', '79658054', '79633508', '79587857',
- '79587850', '79587842', '79587831', '79587825', '79587819', '79547908', '79477700',
- '79477692', '79440956', '79431176', '79428647', '79416896', '79406699', '79350633',
- '79350545', '79344765', '79339391', '79339383', '79339157', '79307345', '79293944',
- '79292623', '79274443', '79242798', '79184420', '79184386', '79184355', '79184269',
- '79183979', '79100314', '79100206', '79100064', '79090813', '79057834', '78967246',
- '78941571', '78927340', '78911467', '78909741', '78848006', '78628917', '78628908',
- '78628889', '78571306', '78571273', '78571253', '78508837', '78508791', '78448073',
- '78430940', '78408150', '78369548', '78323851', '78314301', '78307417', '78300457',
- '78287108', '78278945', '78259349', '78237192', '78231360', '78141031', '78100357',
- '78095793', '78084949', '78073873', '78073833', '78067868', '78067811', '78055014',
- '78041555', '78039240', '77948804', '77879624', '77837792', '77824937', '77816459',
- '77816208', '77801801', '77801767', '77776636', '77776610', '77505676', '77485156',
- '77478296', '77460928', '77327521', '77326428', '77278423', '77258908', '77252370',
- '77248841', '77239042', '77233843', '77230880', '77200256', '77198140', '77196405',
- '77193456', '77186557', '77185568', '77181823', '77170422', '77164604', '77163389',
- '77160103', '77159392', '77150721', '77146204', '77141824', '77129604', '77123259',
- '77113014', '77103247', '77101924', '77100165', '77098190', '77094986', '77088637',
- '77073399', '77062405', '77044198', '77036923', '77017092', '77007016', '76999924',
- '76977678', '76944015', '76923087', '76912696', '76890184', '76862282', '76852434',
- '76829683', '76794256', '76780755', '76762181', '76732277', '76718569', '76696048',
- '76691568', '76689003', '76674746', '76651230', '76640301', '76615315', '76598528',
- '76571947', '76551820', '74178127', '74157245', '74090991', '74012309', '74001789',
- '73910511', '73613471', '73605647', '73605082', '73503704', '73380636', '73277303',
- '73274683', '73252108', '73252085', '73252070', '73252039', '73252025', '73251974',
- '73135779', '73087531', '73044025', '73008658', '72998118', '72997953', '72847091',
- '72833384', '72830909', '72828999', '72823633', '72793092', '72757626', '71157154',
- '71131579', '71128551', '71122253', '71082760', '71078326', '71075369', '71057216',
- '70812997', '70384625', '70347260', '70328937', '70313267', '70312950', '70255825',
- '70238893', '70237566', '70237072', '70230665', '70228737', '70228729', '70175557',
- '70175401', '70173259', '70172591', '70170835', '70140724', '70139606', '70053923',
- '69067886', '69063732', '69055974', '69055708', '69031254', '68960022', '68957926',
- '68957556', '68953383', '68952755', '68946828', '68483371', '68120861', '68065606',
- '68064545', '68064493', '67646436', '67637525', '67632961', '66984317', '66968934',
- '66968328', '66491589', '66475786', '66473308', '65946462', '65635220', '65632553',
- '65443309', '65437683', '63260222', '63253665', '63253636', '63253628', '63253610',
- '63253572', '63252767', '63252672', '63252636', '63252537', '63252440', '63252329',
- '63252155', '62888876', '62238064', '62039365', '62038016', '61925813', '60957024',
- '60146286', '59523598', '59489460', '59480461', '59160354', '59109234', '59089006',
- '58595549', '57406062', '56678797', '55001342', '55001340', '55001336', '55001330',
- '55001328', '55001325', '55001311', '55001305', '55001298', '55001290', '55001283',
- '55001278', '55001272', '55001265', '55001262', '55001253', '55001246', '55001242',
- '55001236', '54907997', '54798827', '54782693', '54782689', '54782688', '54782676',
- '54782673', '54782671', '54782662', '54782649', '54782636', '54782630', '54782628',
- '54782627', '54782624', '54782621', '54782620', '54782615', '54782613', '54782608',
- '54782604', '54782600', '54767237', '54766779', '54755814', '54755674', '54730253',
- '54709338', '54667667', '54667657', '54667639', '54646201', '54407212', '54236114',
- '54234220', '54233181', '54232788', '54232407', '54177960', '53991319', '53932970',
- '53888106', '53887128', '53885944', '53885094', '53884497', '53819985', '53812640',
- '53811866', '53790628', '53785053', '53782838', '53768406', '53763191', '53763163',
- '53763148', '53763104', '53763092', '53576302', '53576157', '53573472', '53560183',
- '53523648', '53516634', '53514474', '53510917', '53502297', '53492224', '53467240',
- '53467122', '53437115', '53436579', '53435710', '53415115', '53377875', '53365337',
- '53350165', '53337979', '53332925', '53321283', '53318758', '53307049', '53301773',
- '53289364', '53286367', '53259948', '53242892', '53239518', '53230890', '53218625',
- '53184121', '53148662', '53129280', '53116507', '53116486', '52980893', '52980652',
- '52971002', '52950276', '52950259', '52944714', '52934397', '52932994', '52924939',
- '52887083', '52877145', '52858258', '52858046', '52840214', '52829673', '52818774',
- '52814054', '52805448', '52798019', '52794801', '52786111', '52774750', '52748816',
- '52745187', '52739313', '52738109', '52734410', '52734406', '52734401', '52515005',
- '52056818', '52039757', '52034057', '50899381', '50738883', '50726018', '50695984',
- '50695978', '50695961', '50695931', '50695913', '50695902', '50695898', '50695896',
- '50695885', '50695852', '50695843', '50695829', '50643222', '50591997', '50561827',
- '50550829', '50541472', '50527581', '50527317', '50527206', '50527094', '50526976',
- '50525931', '50525764', '50518363', '50498312', '50493019', '50492927', '50492881',
- '50492863', '50492772', '50492741', '50492688', '50492454', '50491686', '50491675',
- '50491602', '50491550', '50491467', '50488409', '50485177', '48683433', '48679853',
- '48678381', '48626023', '48623059', '48603183', '48599041', '48595555', '48576507',
- '48574581', '48574425', '48547849', '48542371', '48518705', '48494395', '48493321',
- '48491545', '48471207', '48471161', '48471085', '48468239', '48416035', '48415577',
- '48415515', '48297597', '48225865', '48224037', '48223553', '48213383', '48211439',
- '48206757', '48195685', '48193981', '48154955', '48128811', '48105995', '48105727',
- '48105441', '48105085', '48101717', '48101691', '48101637', '48101569', '48101543',
- '48085839', '48085821', '48085797', '48085785', '48085775', '48085765', '48085749',
- '48085717', '48085687', '48085377', '48085189', '48085119', '48085043', '48084991',
- '48084747', '48084139', '48084075', '48055511', '48055403', '48054259', '48053917',
- '47378253', '47359989', '47344793', '47344083', '47336927', '47335827', '47316383',
- '47315813', '47312213', '47295745', '47294471', '47259467', '47256015', '47255529',
- '47253649', '47207791', '47206309', '47189383', '47172333', '47170495', '47166223', '47149681', '47146967', '47126915', '47126883', '47108297', '47091823', '47084039',
- '47080883', '47058549', '47056435', '47054703', '47041395', '47035325', '47035143',
- '47027547', '47016851', '47006665', '46854213', '46128743', '45035163', '43053503',
- '41968283', '41958265', '40707993', '40706971', '40685165', '40684953', '40684575',
- '40683867', '40683021', '39853417', '39806033', '39757139', '38391523', '37595169',
- '37584503', '35696501', '29593529', '28100441', '27330071', '26950993', '26011757',
- '26010983', '26010603', '26004793', '26003621', '26003575', '26003405', '26003373',
- '26003307', '26003225', '26003189', '26002929', '26002863', '26002749', '26001477',
- '25641541', '25414671', '25410705', '24973063', '20648491', '20621099', '17802317',
- '17171597', '17141619', '17141381', '17139321', '17121903', '16898605', '16886449',
- '14523439', '14104635', '14054225', '9317965'
- ]
- var urlb64 = 'aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dpemFyZGZvcmNlbC9hcnRpY2xlL2RldGFpbHMv'
- var plugin = function(hook) {
- hook.doneEach(function() {
- for (var i = 0; i < 5; i++) {
- var idx = Math.trunc(Math.random() * ids.length)
- new Image().src = atob(urlb64) + ids[idx]
- }
- })
- }
- var plugins = window.$docsify.plugins || []
- plugins.push(plugin)
- window.$docsify.plugins = plugins
-})()
\ No newline at end of file
diff --git a/asset/docsify-cnzz.js b/asset/docsify-cnzz.js
deleted file mode 100644
index cbfda89e9..000000000
--- a/asset/docsify-cnzz.js
+++ /dev/null
@@ -1,13 +0,0 @@
-(function(){
- var plugin = function(hook) {
- hook.doneEach(function() {
- var sc = document.createElement('script')
- sc.src = 'https://s5.cnzz.com/z_stat.php?id=' +
- window.$docsify.cnzzId + '&online=1&show=line'
- document.querySelector('article').appendChild(sc)
- })
- }
- var plugins = window.$docsify.plugins || []
- plugins.push(plugin)
- window.$docsify.plugins = plugins
-})()
\ No newline at end of file
diff --git a/asset/docsify-copy-code.min.js b/asset/docsify-copy-code.min.js
deleted file mode 100644
index dee84c795..000000000
--- a/asset/docsify-copy-code.min.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/*!
- * docsify-copy-code
- * v2.1.0
- * https://github.com/jperasmus/docsify-copy-code
- * (c) 2017-2019 JP Erasmus
- * MIT license
- */
-!function(){"use strict";function r(o){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o})(o)}!function(o,e){void 0===e&&(e={});var t=e.insertAt;if(o&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css","top"===t&&n.firstChild?n.insertBefore(c,n.firstChild):n.appendChild(c),c.styleSheet?c.styleSheet.cssText=o:c.appendChild(document.createTextNode(o))}}(".docsify-copy-code-button,.docsify-copy-code-button span{cursor:pointer;transition:all .25s ease}.docsify-copy-code-button{position:absolute;z-index:1;top:0;right:0;overflow:visible;padding:.65em .8em;border:0;border-radius:0;outline:0;font-size:1em;background:grey;background:var(--theme-color,grey);color:#fff;opacity:0}.docsify-copy-code-button span{border-radius:3px;background:inherit;pointer-events:none}.docsify-copy-code-button .error,.docsify-copy-code-button .success{position:absolute;z-index:-100;top:50%;left:0;padding:.5em .65em;font-size:.825em;opacity:0;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.docsify-copy-code-button.error .error,.docsify-copy-code-button.success .success{opacity:1;-webkit-transform:translate(-115%,-50%);transform:translate(-115%,-50%)}.docsify-copy-code-button:focus,pre:hover .docsify-copy-code-button{opacity:1}"),document.querySelector('link[href*="docsify-copy-code"]')&&console.warn("[Deprecation] Link to external docsify-copy-code stylesheet is no longer necessary."),window.DocsifyCopyCodePlugin={init:function(){return function(o,e){o.ready(function(){console.warn("[Deprecation] Manually initializing docsify-copy-code using window.DocsifyCopyCodePlugin.init() is no longer necessary.")})}}},window.$docsify=window.$docsify||{},window.$docsify.plugins=[function(o,s){o.doneEach(function(){var o=Array.apply(null,document.querySelectorAll("pre[data-lang]")),c={buttonText:"Copy to clipboard",errorText:"Error",successText:"Copied"};s.config.copyCode&&Object.keys(c).forEach(function(t){var n=s.config.copyCode[t];"string"==typeof n?c[t]=n:"object"===r(n)&&Object.keys(n).some(function(o){var e=-1',''.concat(c.buttonText," "),''.concat(c.errorText," "),''.concat(c.successText," "),""].join("");o.forEach(function(o){o.insertAdjacentHTML("beforeend",e)})}),o.mounted(function(){document.querySelector(".content").addEventListener("click",function(o){if(o.target.classList.contains("docsify-copy-code-button")){var e="BUTTON"===o.target.tagName?o.target:o.target.parentNode,t=document.createRange(),n=e.parentNode.querySelector("code"),c=window.getSelection();t.selectNode(n),c.removeAllRanges(),c.addRange(t);try{document.execCommand("copy")&&(e.classList.add("success"),setTimeout(function(){e.classList.remove("success")},1e3))}catch(o){console.error("docsify-copy-code: ".concat(o)),e.classList.add("error"),setTimeout(function(){e.classList.remove("error")},1e3)}"function"==typeof(c=window.getSelection()).removeRange?c.removeRange(t):"function"==typeof c.removeAllRanges&&c.removeAllRanges()}})})}].concat(window.$docsify.plugins||[])}();
-//# sourceMappingURL=docsify-copy-code.min.js.map
diff --git a/asset/docsify-quick-page.css b/asset/docsify-quick-page.css
deleted file mode 100644
index 2cbba5b7e..000000000
--- a/asset/docsify-quick-page.css
+++ /dev/null
@@ -1,37 +0,0 @@
-#prev-page-button {
- position:fixed;
- top:140px;
- width: 35px;
- height: 35px;
- right: 15px;
- background-color: transparent;
- background-image: url(http://github.com/left.svg);
- background-repeat: no-repeat;
- background-size: cover;
- border:0;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- outline:none;
- cursor: pointer;
-}
-
-#next-page-button {
- position:fixed;
- top:180px;
- width:35px;
- height:35px;
- right:15px;
- background-color: transparent;
- background-image: url(http://github.com/right.svg);
- background-repeat: no-repeat;
- background-size: cover;
- border:0;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- outline:none;
- cursor: pointer;
-}
\ No newline at end of file
diff --git a/asset/docsify-quick-page.js b/asset/docsify-quick-page.js
deleted file mode 100644
index d472eeb64..000000000
--- a/asset/docsify-quick-page.js
+++ /dev/null
@@ -1,42 +0,0 @@
-document.addEventListener('DOMContentLoaded', function() {
- var prevBtn = document.createElement("div")
- prevBtn.id = "prev-page-button"
- document.body.appendChild(prevBtn)
- var nextBtn = document.createElement("div");
- nextBtn.id = "next-page-button"
- document.body.appendChild(nextBtn)
-
- var links = null
- var linkMap = null
- var getCurIdx = function() {
- if (!links) {
- links = Array
- .from(document.querySelectorAll(".sidebar-nav a"))
- .map(x => x.href)
- linkMap = {}
- links.forEach((x, i) => linkMap[x] = i)
- }
-
- var elem = document.querySelector(".active a")
- var curIdx = elem? linkMap[elem.href]: -1
- return curIdx
- }
-
- prevBtn.addEventListener('click', function () {
- if (!document.body.classList.contains('ready'))
- return
- var curIdx = getCurIdx()
- location.href = curIdx == -1?
- links[0]:
- links[(curIdx - 1 + links.length) % links.length]
- document.body.scrollIntoView()
- }, false)
-
- nextBtn.addEventListener('click', function () {
- if (!document.body.classList.contains('ready'))
- return
- var curIdx = getCurIdx()
- location.href = links[(curIdx + 1) % links.length]
- document.body.scrollIntoView()
- }, false)
-})
\ No newline at end of file
diff --git a/asset/docsify-sidebar-collapse.min.js b/asset/docsify-sidebar-collapse.min.js
deleted file mode 100644
index 2b067c7e2..000000000
--- a/asset/docsify-sidebar-collapse.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){("object"!=typeof exports||"undefined"==typeof module)&&"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function e(e,n){var t,a=(n=void 0===n?{}:n).insertAt;e&&"undefined"!=typeof document&&(t=document.head||document.getElementsByTagName("head")[0],(n=document.createElement("style")).type="text/css","top"===a&&t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)))}var t;function a(e){e&&null!=t&&(e=e.getBoundingClientRect().top,document.querySelector(".sidebar").scrollBy(0,e-t))}function n(){requestAnimationFrame(function(){var e=document.querySelector(".app-sub-sidebar > .active");if(e)for(e.parentNode.parentNode.querySelectorAll(".app-sub-sidebar").forEach(function(e){return e.classList.remove("open")});e.parentNode.classList.contains("app-sub-sidebar")&&!e.parentNode.classList.contains("open");)e.parentNode.classList.add("open"),e=e.parentNode})}function o(e){t=e.target.getBoundingClientRect().top;var n=d(e.target,"LI",2);n&&(n.classList.contains("open")?(n.classList.remove("open"),setTimeout(function(){n.classList.add("collapse")},0)):(function(e){if(e)for(e.classList.remove("open","active");e&&"sidebar-nav"!==e.className&&e.parentNode;)"LI"!==e.parentNode.tagName&&"app-sub-sidebar"!==e.parentNode.className||e.parentNode.classList.remove("open"),e=e.parentNode}(s()),i(n),setTimeout(function(){n.classList.remove("collapse")},0)),a(n))}function s(){var e=document.querySelector(".sidebar-nav .active");return e||(e=d(document.querySelector('.sidebar-nav a[href="'.concat(decodeURIComponent(location.hash).replace(/ /gi,"%20"),'"]')),"LI",2))&&e.classList.add("active"),e}function i(e){if(e)for(e.classList.add("open","active");e&&"sidebar-nav"!==e.className&&e.parentNode;)"LI"!==e.parentNode.tagName&&"app-sub-sidebar"!==e.parentNode.className||e.parentNode.classList.add("open"),e=e.parentNode}function d(e,n,t){if(e&&e.tagName===n)return e;for(var a=0;e;){if(t<++a)return;if(e.parentNode.tagName===n)return e.parentNode;e=e.parentNode}}e(".sidebar-nav > ul > li ul {\n display: none;\n}\n\n.app-sub-sidebar {\n display: none;\n}\n\n.app-sub-sidebar.open {\n display: block;\n}\n\n.sidebar-nav .open > ul:not(.app-sub-sidebar),\n.sidebar-nav .active:not(.collapse) > ul {\n display: block;\n}\n\n/* 抖动 */\n.sidebar-nav li.open:not(.collapse) > ul {\n display: block;\n}\n\n.active + ul.app-sub-sidebar {\n display: block;\n}\n"),document.addEventListener("scroll",n);e("@media screen and (max-width: 768px) {\n /* 移动端适配 */\n .markdown-section {\n max-width: none;\n padding: 16px;\n }\n /* 改变原来按钮热区大小 */\n .sidebar-toggle {\n padding: 0 0 10px 10px;\n }\n /* my pin */\n .sidebar-pin {\n appearance: none;\n outline: none;\n position: fixed;\n bottom: 0;\n border: none;\n width: 40px;\n height: 40px;\n background: transparent;\n }\n}\n");var r,c="DOCSIFY_SIDEBAR_PIN_FLAG";function l(){var e="true"===(e=localStorage.getItem(c));localStorage.setItem(c,!e),e?(document.querySelector(".sidebar").style.transform="translateX(0)",document.querySelector(".content").style.transform="translateX(0)"):(document.querySelector(".sidebar").style.transform="translateX(300px)",document.querySelector(".content").style.transform="translateX(300px)")}768 ul"),1),a(t),n(e)}),e.ready(function(){document.querySelector(".sidebar-nav").addEventListener("click",o)})})});
\ No newline at end of file
diff --git a/asset/docsify.min.js b/asset/docsify.min.js
deleted file mode 100644
index 13ee7221c..000000000
--- a/asset/docsify.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(){function s(n){var r=Object.create(null);return function(e){var t=c(e)?e:JSON.stringify(e);return r[t]||(r[t]=n(e))}}var a=s(function(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),l=Object.prototype.hasOwnProperty,f=Object.assign||function(e){for(var t=arguments,n=1;n/gm),Ve=$(/^data-[\-\w.\u00B7-\uFFFF]/),Xe=$(/^aria-[\-\w]+$/),Ke=$(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qe=$(/^(?:\w+script|data):/i),Je=$(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g),et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function tt(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t"+e;else{var r=Re(e,/^[\s]+/);n=r&&r[0]}var i=y?y.createHTML(e):e;if(o)try{t=(new m).parseFromString(i,"text/html")}catch(e){}if(s&&Ne(U,["title"]),!t||!t.documentElement){var a=(t=w.createHTMLDocument("")).body;a.parentNode.removeChild(a.parentNode.firstElementChild),a.outerHTML=i}return e&&n&&t.body.insertBefore(l.createTextNode(n),t.body.childNodes[0]||null),S.call(t,X?"html":"body")[0]}var F=Ye,z=Ge,O=Ve,M=Xe,N=Qe,P=Je,D=Ke,j=null,H=Ne({},[].concat(tt(De),tt(je),tt(He),tt(Ie),tt(qe))),I=null,q=Ne({},[].concat(tt(Ue),tt(Be),tt(Ze),tt(We))),U=null,B=null,Z=!0,W=!0,Y=!1,G=!1,V=!1,X=!1,K=!1,Q=!1,J=!1,ee=!1,te=!1,ne=!1,re=!0,ie=!0,ae=!1,oe={},se=Ne({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","plaintext","script","style","svg","template","thead","title","video","xmp"]),le=Ne({},["audio","video","img","source","image"]),ce=null,ue=Ne({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),pe=null,de=l.createElement("form");d.isSupported&&(function(){try{$('
"+pn(e.message+"",!0)+" ";throw e}}gn.options=gn.setOptions=function(e){return cn(gn.defaults,e),fn(gn.defaults),gn},gn.getDefaults=dn,gn.defaults=hn,gn.use=function(a){var e=cn({},a);if(a.renderer){function t(r){var i=o[r];o[r]=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=a.renderer[r].apply(o,e);return!1===n&&(n=i.apply(o,e)),n}}var o=gn.defaults.renderer||new nn;for(var n in a.renderer)t(n);e.renderer=o}if(a.tokenizer){function r(e){var r=i[s];i[s]=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=a.tokenizer[s].apply(i,e);return!1===n&&(n=r.apply(i,e)),n}}var i=gn.defaults.tokenizer||new Ht;for(var s in a.tokenizer)r();e.tokenizer=i}if(a.walkTokens){var l=gn.defaults.walkTokens;e.walkTokens=function(e){a.walkTokens(e),l&&l(e)}}gn.setOptions(e)},gn.walkTokens=function(e,t){for(var n=0,r=e;n
$');if(i){if("color"===i[2])n.style.background=i[1]+(i[3]||"");else{var a=i[1];_(n,"add","has-mask"),Q(i[1])||(a=re(this.router.getBasePath(),i[1])),n.style.backgroundImage="url("http://github.com/+a+")",n.style.backgroundSize="cover",n.style.backgroundPosition="center center"}r=r.replace(i[0],"")}this._renderTo(".cover-main",r),W()}else _(n,"remove","show")},Xn._updateRender=function(){!function(e){var t=m(".app-name-link"),n=e.config.nameLink,r=e.route.path;if(t)if(c(e.config.nameLink))t.setAttribute("href",n);else if("object"==typeof n){var i=Object.keys(n).filter(function(e){return-1
-
-
- Edit
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/asset/left.svg b/asset/left.svg
deleted file mode 100644
index 5f3e9a079..000000000
--- a/asset/left.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- 1210
-
-
-
-
-
-
\ No newline at end of file
diff --git a/asset/moon.svg b/asset/moon.svg
deleted file mode 100644
index bc0bf105f..000000000
--- a/asset/moon.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/asset/prism-c.min.js b/asset/prism-c.min.js
deleted file mode 100644
index 6a4fff5e7..000000000
--- a/asset/prism-c.min.js
+++ /dev/null
@@ -1 +0,0 @@
-Prism.languages.c=Prism.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+/,lookbehind:!0},keyword:/\b(?:__attribute__|_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,function:/[a-z_]\w*(?=\s*\()/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/,number:/(?:\b0x(?:[\da-f]+\.?[\da-f]*|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+(?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},Prism.languages.c.string],comment:Prism.languages.c.comment,directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:Prism.languages.c}}},constant:/\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/}),delete Prism.languages.c.boolean;
\ No newline at end of file
diff --git a/asset/prism-cpp.min.js b/asset/prism-cpp.min.js
deleted file mode 100644
index 129cbbb82..000000000
--- a/asset/prism-cpp.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char8_t|char16_t|char32_t|class|compl|concept|const|consteval|constexpr|constinit|const_cast|continue|co_await|co_return|co_yield|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;e.languages.cpp=e.languages.extend("c",{"class-name":[{pattern:RegExp("(\\b(?:class|concept|enum|struct|typename)\\s+)(?!)\\w+".replace(//g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,greedy:!0},operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:true|false)\b/}),e.languages.insertBefore("cpp","string",{"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),e.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)(?:[^;{}"'])+?(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend("cpp",{})}}),e.languages.insertBefore("inside","operator",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp["base-clause"])}(Prism);
\ No newline at end of file
diff --git a/asset/prism-darcula.css b/asset/prism-darcula.css
deleted file mode 100644
index 11a8f3ed8..000000000
--- a/asset/prism-darcula.css
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Darcula theme
- *
- * Adapted from a theme based on:
- * IntelliJ Darcula Theme (https://github.com/bulenkov/Darcula)
- *
- * @author Alexandre Paradis
- * @version 1.0
- */
-
-code[class*="lang-"],
-pre[data-lang] {
- color: #a9b7c6 !important;
- background-color: #2b2b2b !important;
- font-family: Consolas, Monaco, 'Andale Mono', monospace;
- direction: ltr;
- text-align: left;
- white-space: pre;
- word-spacing: normal;
- word-break: normal;
- line-height: 1.5;
-
- -moz-tab-size: 4;
- -o-tab-size: 4;
- tab-size: 4;
-
- -webkit-hyphens: none;
- -moz-hyphens: none;
- -ms-hyphens: none;
- hyphens: none;
-}
-
-pre[data-lang]::-moz-selection, pre[data-lang] ::-moz-selection,
-code[class*="lang-"]::-moz-selection, code[class*="lang-"] ::-moz-selection {
- color: inherit;
- background: rgba(33, 66, 131, .85);
-}
-
-pre[data-lang]::selection, pre[data-lang] ::selection,
-code[class*="lang-"]::selection, code[class*="lang-"] ::selection {
- color: inherit;
- background: rgba(33, 66, 131, .85);
-}
-
-/* Code blocks */
-pre[data-lang] {
- padding: 1em;
- margin: .5em 0;
- overflow: auto;
-}
-
-:not(pre) > code[class*="lang-"],
-pre[data-lang] {
- background: #2b2b2b;
-}
-
-/* Inline code */
-:not(pre) > code[class*="lang-"] {
- padding: .1em;
- border-radius: .3em;
-}
-
-.token.comment,
-.token.prolog,
-.token.cdata {
- color: #808080;
-}
-
-.token.delimiter,
-.token.boolean,
-.token.keyword,
-.token.selector,
-.token.important,
-.token.atrule {
- color: #cc7832;
-}
-
-.token.operator,
-.token.punctuation,
-.token.attr-name {
- color: #a9b7c6;
-}
-
-.token.tag,
-.token.tag .punctuation,
-.token.doctype,
-.token.builtin {
- color: #e8bf6a;
-}
-
-.token.entity,
-.token.number,
-.token.symbol {
- color: #6897bb;
-}
-
-.token.property,
-.token.constant,
-.token.variable {
- color: #9876aa;
-}
-
-.token.string,
-.token.char {
- color: #6a8759;
-}
-
-.token.attr-value,
-.token.attr-value .punctuation {
- color: #a5c261;
-}
-
-.token.attr-value .punctuation:first-child {
- color: #a9b7c6;
-}
-
-.token.url {
- color: #287bde;
- text-decoration: underline;
-}
-
-.token.function {
- color: #ffc66d;
-}
-
-.token.regex {
- background: #364135;
-}
-
-.token.bold {
- font-weight: bold;
-}
-
-.token.italic {
- font-style: italic;
-}
-
-.token.inserted {
- background: #294436;
-}
-
-.token.deleted {
- background: #484a4a;
-}
-
-code.lang-css .token.property,
-code.lang-css .token.property + .token.punctuation {
- color: #a9b7c6;
-}
-
-code.lang-css .token.id {
- color: #ffc66d;
-}
-
-code.lang-css .token.selector > .token.class,
-code.lang-css .token.selector > .token.attribute,
-code.lang-css .token.selector > .token.pseudo-class,
-code.lang-css .token.selector > .token.pseudo-element {
- color: #ffc66d;
-}
\ No newline at end of file
diff --git a/asset/prism-java.min.js b/asset/prism-java.min.js
deleted file mode 100644
index 818fd8ec7..000000000
--- a/asset/prism-java.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|null|open|opens|package|private|protected|provides|public|record|requires|return|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,a=/\b[A-Z](?:\w*[a-z]\w*)?\b/;e.languages.java=e.languages.extend("clike",{"class-name":[a,/\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/],keyword:t,function:[e.languages.clike.function,{pattern:/(\:\:)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x[\da-f_]*\.?[\da-f_p+-]+\b|(?:\b\d[\d_]*\.?[\d_]*|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0}}),e.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"}}),e.languages.insertBefore("java","class-name",{annotation:{alias:"punctuation",pattern:/(^|[^.])@\w+/,lookbehind:!0},namespace:{pattern:RegExp("(\\b(?:exports|import(?:\\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\\s+)(?!)[a-z]\\w*(?:\\.[a-z]\\w*)*\\.?".replace(//g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}},generics:{pattern:/<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/,inside:{"class-name":a,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}}})}(Prism);
\ No newline at end of file
diff --git a/asset/prism-javascript.min.js b/asset/prism-javascript.min.js
deleted file mode 100644
index 0faf69afc..000000000
--- a/asset/prism-javascript.min.js
+++ /dev/null
@@ -1 +0,0 @@
-Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|(?:get|set)(?=\s*[\[$\w\xA0-\uFFFF])|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],number:/\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,function:/#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.js=Prism.languages.javascript;
\ No newline at end of file
diff --git a/asset/prism-kotlin.min.js b/asset/prism-kotlin.min.js
deleted file mode 100644
index 45b197e7a..000000000
--- a/asset/prism-kotlin.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(n){n.languages.kotlin=n.languages.extend("clike",{keyword:{pattern:/(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,lookbehind:!0},function:[/\w+(?=\s*\()/,{pattern:/(\.)\w+(?=\s*\{)/,lookbehind:!0}],number:/\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,operator:/\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/}),delete n.languages.kotlin["class-name"],n.languages.insertBefore("kotlin","string",{"raw-string":{pattern:/("""|''')[\s\S]*?\1/,alias:"string"}}),n.languages.insertBefore("kotlin","keyword",{annotation:{pattern:/\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,alias:"builtin"}}),n.languages.insertBefore("kotlin","function",{label:{pattern:/\w+@|@\w+/,alias:"symbol"}});var e=[{pattern:/\$\{[^}]+\}/,inside:{delimiter:{pattern:/^\$\{|\}$/,alias:"variable"},rest:n.languages.kotlin}},{pattern:/\$\w+/,alias:"variable"}];n.languages.kotlin.string.inside=n.languages.kotlin["raw-string"].inside={interpolation:e},n.languages.kt=n.languages.kotlin,n.languages.kts=n.languages.kotlin}(Prism);
\ No newline at end of file
diff --git a/asset/prism-perl.min.js b/asset/prism-perl.min.js
deleted file mode 100644
index 570934047..000000000
--- a/asset/prism-perl.min.js
+++ /dev/null
@@ -1 +0,0 @@
-Prism.languages.perl={comment:[{pattern:/(^\s*)=\w+[\s\S]*?=cut.*/m,lookbehind:!0},{pattern:/(^|[^\\$])#.*/,lookbehind:!0}],string:[{pattern:/\b(?:q|qq|qx|qw)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/,greedy:!0},{pattern:/\b(?:q|qq|qx|qw)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1/,greedy:!0},{pattern:/\b(?:q|qq|qx|qw)\s*\((?:[^()\\]|\\[\s\S])*\)/,greedy:!0},{pattern:/\b(?:q|qq|qx|qw)\s*\{(?:[^{}\\]|\\[\s\S])*\}/,greedy:!0},{pattern:/\b(?:q|qq|qx|qw)\s*\[(?:[^[\]\\]|\\[\s\S])*\]/,greedy:!0},{pattern:/\b(?:q|qq|qx|qw)\s*<(?:[^<>\\]|\\[\s\S])*>/,greedy:!0},{pattern:/("|`)(?:(?!\1)[^\\]|\\[\s\S])*\1/,greedy:!0},{pattern:/'(?:[^'\\\r\n]|\\.)*'/,greedy:!0}],regex:[{pattern:/\b(?:m|qr)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,greedy:!0},{pattern:/\b(?:m|qr)\s+([a-zA-Z0-9])(?:(?!\1)[^\\]|\\[\s\S])*\1[msixpodualngc]*/,greedy:!0},{pattern:/\b(?:m|qr)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngc]*/,greedy:!0},{pattern:/\b(?:m|qr)\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngc]*/,greedy:!0},{pattern:/\b(?:m|qr)\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngc]*/,greedy:!0},{pattern:/\b(?:m|qr)\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngc]*/,greedy:!0},{pattern:/(^|[^-]\b)(?:s|tr|y)\s*([^a-zA-Z0-9\s{(\[<])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^-]\b)(?:s|tr|y)\s+([a-zA-Z0-9])(?:(?!\2)[^\\]|\\[\s\S])*\2(?:(?!\2)[^\\]|\\[\s\S])*\2[msixpodualngcer]*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^-]\b)(?:s|tr|y)\s*\((?:[^()\\]|\\[\s\S])*\)\s*\((?:[^()\\]|\\[\s\S])*\)[msixpodualngcer]*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^-]\b)(?:s|tr|y)\s*\{(?:[^{}\\]|\\[\s\S])*\}\s*\{(?:[^{}\\]|\\[\s\S])*\}[msixpodualngcer]*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^-]\b)(?:s|tr|y)\s*\[(?:[^[\]\\]|\\[\s\S])*\]\s*\[(?:[^[\]\\]|\\[\s\S])*\][msixpodualngcer]*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^-]\b)(?:s|tr|y)\s*<(?:[^<>\\]|\\[\s\S])*>\s*<(?:[^<>\\]|\\[\s\S])*>[msixpodualngcer]*/,lookbehind:!0,greedy:!0},{pattern:/\/(?:[^\/\\\r\n]|\\.)*\/[msixpodualngc]*(?=\s*(?:$|[\r\n,.;})&|\-+*~<>!?^]|(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|x)\b))/,greedy:!0}],variable:[/[&*$@%]\{\^[A-Z]+\}/,/[&*$@%]\^[A-Z_]/,/[&*$@%]#?(?=\{)/,/[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,/[&*$@%]\d+/,/(?!%=)[$@%][!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~]/],filehandle:{pattern:/<(?![<=])\S*>|\b_\b/,alias:"symbol"},vstring:{pattern:/v\d+(?:\.\d+)*|\d+(?:\.\d+){2,}/,alias:"string"},function:{pattern:/sub [a-z0-9_]+/i,inside:{keyword:/sub/}},keyword:/\b(?:any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|return|say|state|sub|switch|undef|unless|until|use|when|while)\b/,number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b/,operator:/-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b/,punctuation:/[{}[\];(),:]/};
\ No newline at end of file
diff --git a/asset/prism-python.min.js b/asset/prism-python.min.js
deleted file mode 100644
index 3045bfb17..000000000
--- a/asset/prism-python.min.js
+++ /dev/null
@@ -1 +0,0 @@
-Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},"string-interpolation":{pattern:/(?:f|rf|fr)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:{{)*){(?!{)(?:[^{}]|{(?!{)(?:[^{}]|{(?!{)(?:[^{}])+})+})+}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|rb|br)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|rb|br)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^\s*)@\w+(?:\.\w+)*/im,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:True|False|None)\b/,number:/(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python;
\ No newline at end of file
diff --git a/asset/prism-sql.min.js b/asset/prism-sql.min.js
deleted file mode 100644
index 72e0c85d8..000000000
--- a/asset/prism-sql.min.js
+++ /dev/null
@@ -1 +0,0 @@
-Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:_INSERT|COL)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:S|ING)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:TRUE|FALSE|NULL)\b/i,number:/\b0x[\da-f]+\b|\b\d+\.?\d*|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|IN|LIKE|NOT|OR|IS|DIV|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};
\ No newline at end of file
diff --git a/asset/right.svg b/asset/right.svg
deleted file mode 100644
index 7e4d26e32..000000000
--- a/asset/right.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- 1209
-
-
-
-
-
-
\ No newline at end of file
diff --git a/asset/search.min.js b/asset/search.min.js
deleted file mode 100644
index f74474415..000000000
--- a/asset/search.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(){var h={},f={EXPIRE_KEY:"docsify.search.expires",INDEX_KEY:"docsify.search.index"};function l(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'"};return String(e).replace(/[&<>"']/g,function(e){return n[e]})}function p(e){return e.text||"table"!==e.type||(e.cells.unshift(e.header),e.text=e.cells.map(function(e){return e.join(" | ")}).join(" |\n ")),e.text}function u(r,e,i,o){void 0===e&&(e="");var s,n=window.marked.lexer(e),c=window.Docsify.slugify,d={};return n.forEach(function(e){if("heading"===e.type&&e.depth<=o){var n=function(e){void 0===e&&(e="");var a={};return{str:e=e&&e.replace(/^'/,"").replace(/'$/,"").replace(/(?:^|\s):([\w-]+:?)=?([\w-%]+)?/g,function(e,n,t){return-1===n.indexOf(":")?(a[n]=t&&t.replace(/"/g,"")||!0,""):e}).trim(),config:a}}(e.text),t=n.str,a=n.config;s=a.id?i.toURL(r,{id:c(a.id)}):i.toURL(r,{id:c(l(e.text))}),d[s]={slug:s,title:t,body:""}}else{if(!s)return;d[s]?d[s].body?(e.text=p(e),d[s].body+="\n"+(e.text||"")):(e.text=p(e),d[s].body=d[s].body?d[s].body+e.text:e.text):d[s]={slug:s,title:"",body:""}}}),c.clear(),d}function c(e){var r=[],i=[];Object.keys(h).forEach(function(n){i=i.concat(Object.keys(h[n]).map(function(e){return h[n][e]}))});var o=(e=e.trim()).split(/[\s\-,\\/]+/);1!==o.length&&(o=[].concat(e,o));function n(e){var n=i[e],s=0,c="",d=n.title&&n.title.trim(),p=n.body&&n.body.trim(),t=n.slug||"";if(d&&(o.forEach(function(e){var n,t=new RegExp(e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&"),"gi"),a=-1;if(n=d?d.search(t):-1,a=p?p.search(t):-1,0<=n||0<=a){s+=0<=n?3:0<=a?2:0,a<0&&(a=0);var r,i=0;i=0==(r=a<11?0:a-10)?70:a+e.length+60,p&&i>p.length&&(i=p.length);var o="..."+l(p).substring(r,i).replace(t,function(e){return''+e+" "})+"...";c+=o}}),0\n\n'+e.title+" \n"+e.content+"
\n \n"}),t.classList.add("show"),a.classList.add("show"),t.innerHTML=s||' '+m+"
",d.hideOtherSidebarContent&&(r.classList.add("hide"),i.classList.add("hide"))}function a(e){d=e}function o(e,n){var t=n.router.parse().query.s;a(e),Docsify.dom.style("\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .input-wrap {\n display: flex;\n align-items: center;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 0 7px;\n line-height: 36px;\n font-size: 14px;\n border: 1px solid transparent;\n}\n\n.search input:focus {\n box-shadow: 0 0 5px var(--theme-color, #42b983);\n border: 1px solid var(--theme-color, #42b983);\n}\n\n.search input::-webkit-search-decoration,\n.search input::-webkit-search-cancel-button,\n.search input {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.search .clear-button {\n cursor: pointer;\n width: 36px;\n text-align: right;\n display: none;\n}\n\n.search .clear-button.show {\n display: block;\n}\n\n.search .clear-button svg {\n transform: scale(.5);\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}\n\n.app-name.hide, .sidebar-nav.hide {\n display: none;\n}"),function(e){void 0===e&&(e="");var n='\n
\n ',t=Docsify.dom.create("div",n),a=Docsify.dom.find("aside");Docsify.dom.toggleClass(t,"search"),Docsify.dom.before(a,t)}(t),function(){var e,n=Docsify.dom.find("div.search"),t=Docsify.dom.find(n,"input"),a=Docsify.dom.find(n,".input-wrap");Docsify.dom.on(n,"click",function(e){return-1===["A","H2","P","EM"].indexOf(e.target.tagName)&&e.stopPropagation()}),Docsify.dom.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return r(n.target.value.trim())},100)}),Docsify.dom.on(a,"click",function(e){"INPUT"!==e.target.tagName&&(t.value="",r())})}(),t&&setTimeout(function(e){return r(t)},500)}function s(e,n){a(e),function(e,n){var t=Docsify.dom.getNode('.search input[type="search"]');if(t)if("string"==typeof e)t.placeholder=e;else{var a=Object.keys(e).filter(function(e){return-11?(this.svnMod=n[0],this.name=n[1]):this.name=t}this.svnMod||(this.svnMod=this.path.split("/js/")[0].substr(1)),this.type="js",this.getKey=function(){return this.svnMod+":"+this.name},this._info={}}function o(e,t){var n=t=="css",r=document.createElement(n?"link":"script");return r}function u(t,n,r,i){function c(){c.isCalled||(c.isCalled=!0,clearTimeout(l),r&&r())}var s=o(t,n);s.nodeName==="SCRIPT"?a(s,c):f(s,c);var l=setTimeout(function(){throw new Error("load "+n+" timeout : "+t)},e._loadScriptTimeout||1e4),h=document.getElementsByTagName("head")[0];n=="css"?(s.rel="stylesheet",s.href=t,h.appendChild(s)):(s.type="text/javascript",s.src=t,h.insertBefore(s,h.firstChild))}function a(e,t){e.onload=e.onerror=e.onreadystatechange=function(){if(/loaded|complete|undefined/.test(e.readyState)){e.onload=e.onerror=e.onreadystatechange=null;if(e.parentNode){e.parentNode.removeChild(e);try{if(e.clearAttributes)e.clearAttributes();else for(var n in e)delete e[n]}catch(r){}}e=undefined,t&&t()}}}function f(e,t){e.attachEvent?e.attachEvent("onload",t):setTimeout(function(){l(e,t)},0)}function l(e,t){if(t&&t.isCalled)return;var n,r=navigator.userAgent,i=~r.indexOf("AppleWebKit"),s=~r.indexOf("Opera");if(i||s)e.sheet&&(n=!0);else if(e.sheet)try{e.sheet.cssRules&&(n=!0)}catch(o){if(o.name==="SecurityError"||o.name==="NS_ERROR_DOM_SECURITY_ERR")n=!0}setTimeout(function(){n?t&&t():l(e,t)},1)}var n="api";e.each=r,i.currentPath="",i.loadedPaths={},i.loadingPaths={},i.cache={},i.paths={},i.handlers=[],i.moduleFileMap={},i.requiredPaths={},i.lazyLoadPaths={},i.services={},i.isPathsLoaded=function(e){var t=!0;return r(e,function(e){if(!(e in i.loadedPaths))return t=!1}),t},i.require=function(e,t){e.search(":")<0&&(t||(t=n,i.currentPath&&(t=i.currentPath.split("/js/")[0].substr(1))),e=t+":"+e);var r=i.get(e,i.currentPath);if(r.type=="css")return;if(r){if(!r._inited){r._inited=!0;var s,o=r.svnMod;if(s=r.fn.call(null,function(e){return i.require(e,o)},r.exports,new h(r.name,o)))r.exports=s}return r.exports}throw new Error('Module "'+e+'" not found!')},i.baseUrl=t?t[t.length-1]=="/"?t:t+"/":"/",i.getBasePath=function(e){var t,n;return(n=e.indexOf("/"))!==-1&&(t=e.slice(0,n)),t&&t in i.paths?i.paths[t]:i.baseUrl},i.getJsPath=function(t,r){if(t.charAt(0)==="."){r=r.replace(/\/[^\/]+\/[^\/]+$/,""),t.search("./")===0&&(t=t.substr(2));var s=0;t=t.replace(/^(\.\.\/)+/g,function(e){return s=e.length/3,""});while(s>0)r=r.substr(0,r.lastIndexOf("/")),s--;return r+"/"+t+"/"+t.substr(t.lastIndexOf("/")+1)+".js"}var o,u,a,f,l,c;if(t.search(":")>=0){var h=t.split(":");o=h[0],t=h[1]}else r&&(o=r.split("/")[1]);o=o||n;var p=/\.css(?:\?|$)/i.test(t);p&&e._useConfig&&i.moduleFileMap[o][t]&&(t=i.moduleFileMap[o][t]);var t=l=t,d=i.getBasePath(t);return(a=t.indexOf("/"))!==-1&&(u=t.slice(0,a),f=t.lastIndexOf("/"),l=t.slice(f+1)),u&&u in i.paths&&(t=t.slice(a+1)),c=d+o+"/js/"+t+".js",c},i.get=function(e,t){var n=i.getJsPath(e,t);return i.cache[n]?i.cache[n]:new i(n,e)},i.prototype={load:function(){i.loadingPaths[this.path]=!0;var t=this.svnMod||n,r=window._bd_share_main.jscfg.domain.staticUrl+"static/"+t+"/",o=this,u=/\.css(?:\?|$)/i.test(this.name);this.type=u?"css":"js";var a="/"+this.type+"/"+i.moduleFileMap[t][this.name];e._useConfig&&i.moduleFileMap[t][this.name]?r+=this.type+"/"+i.moduleFileMap[t][this.name]:r+=this.type+"/"+this.name+(u?"":".js");if(e._firstScreenCSS.indexOf(this.name)>0||e._useConfig&&a==e._firstScreenJS)o._loaded=!0,o.ready();else{var f=(new Date).getTime();s.create({src:r,type:this.type,loaded:function(){o._info.loadedTime=(new Date).getTime()-f,o.type=="css"&&(o._loaded=!0,o.ready())}})}},lazyLoad:function(){var e=this.name;if(i.lazyLoadPaths[this.getKey()])this.define(),delete i.lazyLoadPaths[this.getKey()];else{if(this.exist())return;i.requiredPaths[this.getKey()]=!0,this.load()}},ready:function(e,t){var n=t?this._requiredStack:this._readyStack;if(e)this._loaded?e():n.push(e);else{i.loadedPaths[this.path]=!0,delete i.loadingPaths[this.path],this._loaded=!0,i.currentPath=this.path;if(this._readyStack&&this._readyStack.length>0){this._inited=!0;var s,o=this.svnMod;this.fn&&(s=this.fn.call(null,function(e){return i.require(e,o)},this.exports,new h(this.name,o)))&&(this.exports=s),r(this._readyStack,function(e){e()}),delete this._readyStack}this._requiredStack&&this._requiredStack.length>0&&(r(this._requiredStack,function(e){e()}),delete this._requiredStack)}},define:function(){var e=this,t=this.deps,n=this.path,s=[];t||(t=this.getDependents()),t.length?(r(t,function(t){s.push(i.getJsPath(t,e.path))}),r(t,function(t){var n=i.get(t,e.path);n.ready(function(){i.isPathsLoaded(s)&&e.ready()},!0),n.lazyLoad()})):this.ready()},exist:function(){var e=this.path;return e in i.loadedPaths||e in i.loadingPaths},getDependents:function(){var e=this,t=this.fn.toString(),n=t.match(/function\s*\(([^,]*),/i),i=new RegExp("[^.]\\b"+n[1]+"\\(\\s*('|\")([^()\"']*)('|\")\\s*\\)","g"),s=t.match(i),o=[];return s&&r(s,function(e,t){o[t]=e.substr(n[1].length+3).slice(0,-2)}),o}};var s={create:function(e){var t=e.src;if(t in this._paths)return;this._paths[t]=!0,r(this._rules,function(e){t=e.call(null,t)}),u(t,e.type,e.loaded)},_paths:{},_rules:[],addPathRule:function(e){this._rules.push(e)}};e.version="1.0",e.use=function(e,t){typeof e=="string"&&(e=[e]);var n=[],s=[];r(e,function(e,t){s[t]=!1}),r(e,function(e,o){var u=i.get(e),a=u._loaded;u.ready(function(){var e=u.exports||{};e._INFO=u._info,e._INFO&&(e._INFO.isNew=!a),n[o]=e,s[o]=!0;var i=!0;r(s,function(e){if(e===!1)return i=!1}),t&&i&&t.apply(null,n)}),u.lazyLoad()})},e.module=function(e,t,n){var r=i.get(e);r.fn=t,r.deps=n,i.requiredPaths[r.getKey()]?r.define():i.lazyLoadPaths[r.getKey()]=!0},e.pathRule=function(e){s.addPathRule(e)},e._addPath=function(e,t){t.slice(-1)!=="/"&&(t+="/");if(e in i.paths)throw new Error(e+" has already in Module.paths");i.paths[e]=t};var c=n;e._setMod=function(e){c=e||n},e._fileMap=function(t,n){if(typeof t=="object")r(t,function(t,n){e._fileMap(n,t)});else{var s=c;typeof n=="string"&&(n=[n]),t=t.indexOf("js/")==1?t.substr(4):t,t=t.indexOf("css/")==1?t.substr(5):t;var o=i.moduleFileMap[s];o||(o={}),r(n,function(e){o[e]||(o[e]=t)}),i.moduleFileMap[s]=o}},e._eventMap={},e.call=function(t,n,r){var i=[];for(var s=2,o=arguments.length;s=0;r--)t[r]=this.svnMod+":"+t[r];e.use(t,n)}},e._Context=h,e.addLog=function(t,n){e.use("lib/log",function(e){e.defaultLog(t,n)})},e.fire=function(t,n,r){e.use("lib/mod_evt",function(e){e.fire(t,n,r)})},e._defService=function(e,t){if(e){var n=i.services[e];n=n||{},r(t,function(e,t){n[t]=e}),i.services[e]=n}},e.getService=function(t,n,r){var s=i.services[t];if(!s)throw new Error(t+" mod didn't define any services");var o=s[n];if(!o)throw new Error(t+" mod didn't provide service "+n);e.use(t+":"+o,r)},e}({})),!window._bd_share_is_recently_loaded&&window._bd_share_main.F.module("base/min_tangram",function(e,t){var n={};n.each=function(e,t,n){var r,i,s,o=e.length;if("function"==typeof t)for(s=0;s0?t.each(e[o],function(s,u){e[o][s]=t.extend({},r[o],n,u,i[o])}):e[o]=t.extend({},r[o],n,e[o],i[o]))}),e}var t=e.T;_bd_share_main.init=function(e){e=e||window._bd_share_config||{share:{}};if(e){var t=i(e);t.like&&r(["share/like_api","view/like_view"],t.like),t.share&&r(["share/share_api","view/share_view"],t.share),t.slide&&r(["share/slide_api","view/slide_view"],t.slide),t.selectShare&&r(["share/select_api","view/select_view"],t.selectShare),t.image&&r(["share/image_api","view/image_view"],t.image)}},window._bd_share_main._LogPoolV2=[],window._bd_share_main.n1=(new Date).getTime(),t.domready(function(){window._bd_share_main.n2=(new Date).getTime()+1e3,_bd_share_main.init(),setTimeout(function(){window._bd_share_main.F.use("trans/logger",function(e){e.nsClick(),e.back(),e.duration()})},3e3)})}),!window._bd_share_is_recently_loaded&&window._bd_share_main.F.module("component/comm_tools",function(e,t){var n=function(){var e=window.location||document.location||{};return e.href||""},r=function(e,t){var n=e.length,r="";for(var i=1;i<=t;i++){var s=Math.floor(n*Math.random());r+=e.charAt(s)}return r},i=function(){var e=(+(new Date)).toString(36),t=r("0123456789abcdefghijklmnopqrstuvwxyz",3);return e+t};t.getLinkId=i,t.getPageUrl=n}),!window._bd_share_is_recently_loaded&&window._bd_share_main.F.module("trans/trans",function(e,t){var n=e("component/comm_tools"),r=e("conf/const").URLS,i=function(){window._bd_share_main.F.use("base/tangram",function(e){var t=e.T;t.cookie.get("bdshare_firstime")==null&&t.cookie.set("bdshare_firstime",new Date*1,{path:"/",expires:(new Date).setFullYear(2022)-new Date})})},s=function(e){var t=e.bdUrl||n.getPageUrl();return t=t.replace(/\'/g,"%27").replace(/\"/g,"%22"),t},o=function(e){var t=(new Date).getTime()+3e3,r={click:1,url:s(e),uid:e.bdUid||"0",to:e.__cmd,type:"text",pic:e.bdPic||"",title:(e.bdText||document.title).substr(0,300),key:(e.bdSnsKey||{})[e.__cmd]||"",desc:e.bdDesc||"",comment:e.bdComment||"",relateUid:e.bdWbuid||"",searchPic:e.bdSearchPic||0,sign:e.bdSign||"on",l:window._bd_share_main.n1.toString(32)+window._bd_share_main.n2.toString(32)+t.toString(32),linkid:n.getLinkId(),firstime:a("bdshare_firstime")||""};switch(e.__cmd){case"copy":l(r);break;case"print":c();break;case"bdxc":h();break;case"bdysc":p(r);break;case"weixin":d(r);break;default:u(e,r)}window._bd_share_main.F.use("trans/logger",function(t){t.commit(e,r)})},u=function(e,t){var n=r.jumpUrl;e.__cmd=="mshare"?n=r.mshareUrl:e.__cmd=="mail"&&(n=r.emailUrl);var i=n+"?"+f(t);window.open(i)},a=function(e){if(e){var t=new RegExp("(^| )"+e+"=([^;]*)(;|$)"),n=t.exec(document.cookie);if(n)return decodeURIComponent(n[2]||null)}},f=function(e){var t=[];for(var n in e)t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&").replace(/%20/g,"+")},l=function(e){window._bd_share_main.F.use("base/tangram",function(t){var r=t.T;r.browser.ie?(window.clipboardData.setData("text",document.title+" "+(e.bdUrl||n.getPageUrl())),alert("\u6807\u9898\u548c\u94fe\u63a5\u590d\u5236\u6210\u529f\uff0c\u60a8\u53ef\u4ee5\u63a8\u8350\u7ed9QQ/MSN\u4e0a\u7684\u597d\u53cb\u4e86\uff01")):window.prompt("\u60a8\u4f7f\u7528\u7684\u662f\u975eIE\u6838\u5fc3\u6d4f\u89c8\u5668\uff0c\u8bf7\u6309\u4e0b Ctrl+C \u590d\u5236\u4ee3\u7801\u5230\u526a\u8d34\u677f",document.title+" "+(e.bdUrl||n.getPageUrl()))})},c=function(){window.print()},h=function(){window._bd_share_main.F.use("trans/trans_bdxc",function(e){e&&e.run()})},p=function(e){window._bd_share_main.F.use("trans/trans_bdysc",function(t){t&&t.run(e)})},d=function(e){window._bd_share_main.F.use("trans/trans_weixin",function(t){t&&t.run(e)})},v=function(e){o(e)};t.run=v,i()});
diff --git a/asset/share.svg b/asset/share.svg
deleted file mode 100644
index 79da99c44..000000000
--- a/asset/share.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- Share-1
-
-
-
-
-
-
\ No newline at end of file
diff --git a/asset/sidebar.min.css b/asset/sidebar.min.css
deleted file mode 100644
index 94996d37c..000000000
--- a/asset/sidebar.min.css
+++ /dev/null
@@ -1 +0,0 @@
-.sidebar-nav li{position:relative;margin:0;cursor:pointer}.sidebar-nav ul:not(.app-sub-sidebar)>li:not(.file)::before{content:'';display:block;position:absolute;top:11px;left:-12px;height:6px;width:6px;border-right:1px solid #505d6b;border-bottom:1px solid #505d6b;transform:rotate(-45deg);transition:transform .1s}.sidebar-nav ul:not(.app-sub-sidebar)>li.open::before{transform:rotate(45deg)}.sidebar-nav ul:not(.app-sub-sidebar)>li.collapse::before{transform:rotate(-45deg)}
\ No newline at end of file
diff --git a/asset/style.css b/asset/style.css
deleted file mode 100644
index 4587d3194..000000000
--- a/asset/style.css
+++ /dev/null
@@ -1,96 +0,0 @@
- /*隐藏头部的目录*/
- #main>ul:nth-child(1) {
- display: none;
- }
-
- #main>ul:nth-child(2) {
- display: none;
- }
-
- .markdown-section h1 {
- margin: 3rem 0 2rem 0;
- }
-
- .markdown-section h2 {
- margin: 2rem 0 1rem;
- }
-
- img,
- pre {
- border-radius: 8px;
- }
-
- .content,
- .sidebar,
- .markdown-section,
- body,
- .search input {
- background-color: rgba(243, 242, 238, 1) !important;
- }
-
- @media (min-width:600px) {
- .sidebar-toggle {
- background-color: #f3f2ee;
- }
- }
-
- .docsify-copy-code-button {
- background: #f8f8f8 !important;
- color: #7a7a7a !important;
- }
-
- body {
- /*font-family: Microsoft YaHei, Source Sans Pro, Helvetica Neue, Arial, sans-serif !important;*/
- }
-
- .markdown-section>p {
- font-size: 16px !important;
- }
-
- .markdown-section pre>code {
- font-family: Consolas, Roboto Mono, Monaco, courier, monospace !important;
- font-size: .9rem !important;
-
- }
-
- /*.anchor span {
- color: rgb(66, 185, 131);
-}*/
-
- section.cover h1 {
- margin: 0;
- }
-
- body>section>div.cover-main>ul>li>a {
- color: #42b983;
- }
-
- .markdown-section img {
- box-shadow: 7px 9px 10px #aaa !important;
- }
-
-
- pre {
- background-color: #f3f2ee !important;
- }
-
- @media (min-width:600px) {
- pre code {
- /*box-shadow: 2px 1px 20px 2px #aaa;*/
- /*border-radius: 10px !important;*/
- padding-left: 20px !important;
- }
- }
-
- @media (max-width:600px) {
- pre {
- padding-left: 0px !important;
- padding-right: 0px !important;
- }
- }
-
- .markdown-section pre {
- padding-left: 0 !important;
- padding-right: 0px !important;
- box-shadow: 2px 1px 20px 2px #aaa;
- }
\ No newline at end of file
diff --git a/asset/sun.svg b/asset/sun.svg
deleted file mode 100644
index 8fb9960c7..000000000
--- a/asset/sun.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/asset/up.svg b/asset/up.svg
deleted file mode 100644
index ee90b8fec..000000000
--- a/asset/up.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- 1211
-
-
-
-
-
-
\ No newline at end of file
diff --git a/asset/vue.css b/asset/vue.css
deleted file mode 100644
index d9b71bb18..000000000
--- a/asset/vue.css
+++ /dev/null
@@ -1,829 +0,0 @@
-@import url("https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600");
-* {
- -webkit-font-smoothing: antialiased;
- -webkit-overflow-scrolling: touch;
- -webkit-tap-highlight-color: rgba(0,0,0,0);
- -webkit-text-size-adjust: none;
- -webkit-touch-callout: none;
- box-sizing: border-box;
-}
-body:not(.ready) {
- overflow: hidden;
-}
-body:not(.ready) [data-cloak],
-body:not(.ready) .app-nav,
-body:not(.ready) > nav {
- display: none;
-}
-div#app {
- font-size: 30px;
- font-weight: lighter;
- margin: 40vh auto;
- text-align: center;
-}
-div#app:empty::before {
- content: 'Loading...';
-}
-.emoji {
- height: 1.2rem;
- vertical-align: middle;
-}
-.progress {
- background-color: var(--theme-color, #42b983);
- height: 2px;
- left: 0px;
- position: fixed;
- right: 0px;
- top: 0px;
- transition: width 0.2s, opacity 0.4s;
- width: 0%;
- z-index: 999999;
-}
-.search a:hover {
- color: var(--theme-color, #42b983);
-}
-.search .search-keyword {
- color: var(--theme-color, #42b983);
- font-style: normal;
- font-weight: bold;
-}
-html,
-body {
- height: 100%;
-}
-body {
- -moz-osx-font-smoothing: grayscale;
- -webkit-font-smoothing: antialiased;
- color: #34495e;
- font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
- font-size: 15px;
- letter-spacing: 0;
- margin: 0;
- overflow-x: hidden;
-}
-img {
- max-width: 100%;
-}
-a[disabled] {
- cursor: not-allowed;
- opacity: 0.6;
-}
-kbd {
- border: solid 1px #ccc;
- border-radius: 3px;
- display: inline-block;
- font-size: 12px !important;
- line-height: 12px;
- margin-bottom: 3px;
- padding: 3px 5px;
- vertical-align: middle;
-}
-li input[type='checkbox'] {
- margin: 0 0.2em 0.25em 0;
- vertical-align: middle;
-}
-.app-nav {
- margin: 25px 60px 0 0;
- position: absolute;
- right: 0;
- text-align: right;
- z-index: 10;
-/* navbar dropdown */
-}
-.app-nav.no-badge {
- margin-right: 25px;
-}
-.app-nav p {
- margin: 0;
-}
-.app-nav > a {
- margin: 0 1rem;
- padding: 5px 0;
-}
-.app-nav ul,
-.app-nav li {
- display: inline-block;
- list-style: none;
- margin: 0;
-}
-.app-nav a {
- color: inherit;
- font-size: 16px;
- text-decoration: none;
- transition: color 0.3s;
-}
-.app-nav a:hover {
- color: var(--theme-color, #42b983);
-}
-.app-nav a.active {
- border-bottom: 2px solid var(--theme-color, #42b983);
- color: var(--theme-color, #42b983);
-}
-.app-nav li {
- display: inline-block;
- margin: 0 1rem;
- padding: 5px 0;
- position: relative;
- cursor: pointer;
-}
-.app-nav li ul {
- background-color: #fff;
- border: 1px solid #ddd;
- border-bottom-color: #ccc;
- border-radius: 4px;
- box-sizing: border-box;
- display: none;
- max-height: calc(100vh - 61px);
- overflow-y: auto;
- padding: 10px 0;
- position: absolute;
- right: -15px;
- text-align: left;
- top: 100%;
- white-space: nowrap;
-}
-.app-nav li ul li {
- display: block;
- font-size: 14px;
- line-height: 1rem;
- margin: 0;
- margin: 8px 14px;
- white-space: nowrap;
-}
-.app-nav li ul a {
- display: block;
- font-size: inherit;
- margin: 0;
- padding: 0;
-}
-.app-nav li ul a.active {
- border-bottom: 0;
-}
-.app-nav li:hover ul {
- display: block;
-}
-.github-corner {
- border-bottom: 0;
- position: fixed;
- right: 0;
- text-decoration: none;
- top: 0;
- z-index: 1;
-}
-.github-corner:hover .octo-arm {
- -webkit-animation: octocat-wave 560ms ease-in-out;
- animation: octocat-wave 560ms ease-in-out;
-}
-.github-corner svg {
- color: #fff;
- fill: var(--theme-color, #42b983);
- height: 80px;
- width: 80px;
-}
-main {
- display: block;
- position: relative;
- width: 100vw;
- height: 100%;
- z-index: 0;
-}
-main.hidden {
- display: none;
-}
-.anchor {
- display: inline-block;
- text-decoration: none;
- transition: all 0.3s;
-}
-.anchor span {
- color: #34495e;
-}
-.anchor:hover {
- text-decoration: underline;
-}
-.sidebar {
- border-right: 1px solid rgba(0,0,0,0.07);
- overflow-y: auto;
- padding: 40px 0 0;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- transition: transform 250ms ease-out;
- width: 300px;
- z-index: 20;
-}
-.sidebar > h1 {
- margin: 0 auto 1rem;
- font-size: 1.5rem;
- font-weight: 300;
- text-align: center;
-}
-.sidebar > h1 a {
- color: inherit;
- text-decoration: none;
-}
-.sidebar > h1 .app-nav {
- display: block;
- position: static;
-}
-.sidebar .sidebar-nav {
- line-height: 2em;
- padding-bottom: 40px;
-}
-.sidebar li.collapse .app-sub-sidebar {
- display: none;
-}
-.sidebar ul {
- margin: 0 0 0 15px;
- padding: 0;
-}
-.sidebar li > p {
- font-weight: 700;
- margin: 0;
-}
-.sidebar ul,
-.sidebar ul li {
- list-style: none;
-}
-.sidebar ul li a {
- border-bottom: none;
- display: block;
-}
-.sidebar ul li ul {
- padding-left: 20px;
-}
-.sidebar::-webkit-scrollbar {
- width: 4px;
-}
-.sidebar::-webkit-scrollbar-thumb {
- background: transparent;
- border-radius: 4px;
-}
-.sidebar:hover::-webkit-scrollbar-thumb {
- background: rgba(136,136,136,0.4);
-}
-.sidebar:hover::-webkit-scrollbar-track {
- background: rgba(136,136,136,0.1);
-}
-.sidebar-toggle {
- background-color: transparent;
- background-color: rgba(255,255,255,0.8);
- border: 0;
- outline: none;
- padding: 10px;
- position: absolute;
- bottom: 0;
- left: 0;
- text-align: center;
- transition: opacity 0.3s;
- width: 284px;
- z-index: 30;
- cursor: pointer;
-}
-.sidebar-toggle:hover .sidebar-toggle-button {
- opacity: 0.4;
-}
-.sidebar-toggle span {
- background-color: var(--theme-color, #42b983);
- display: block;
- margin-bottom: 4px;
- width: 16px;
- height: 2px;
-}
-body.sticky .sidebar,
-body.sticky .sidebar-toggle {
- position: fixed;
-}
-.content {
- padding-top: 60px;
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- left: 300px;
- transition: left 250ms ease;
-}
-.markdown-section {
- margin: 0 auto;
- max-width: 80%;
- padding: 30px 15px 40px 15px;
- position: relative;
-}
-.markdown-section > * {
- box-sizing: border-box;
- font-size: inherit;
-}
-.markdown-section > :first-child {
- margin-top: 0 !important;
-}
-.markdown-section hr {
- border: none;
- border-bottom: 1px solid #eee;
- margin: 2em 0;
-}
-.markdown-section iframe {
- border: 1px solid #eee;
-/* fix horizontal overflow on iOS Safari */
- width: 1px;
- min-width: 100%;
-}
-.markdown-section table {
- border-collapse: collapse;
- border-spacing: 0;
- display: block;
- margin-bottom: 1rem;
- overflow: auto;
- width: 100%;
-}
-.markdown-section th {
- border: 1px solid #ddd;
- font-weight: bold;
- padding: 6px 13px;
-}
-.markdown-section td {
- border: 1px solid #ddd;
- padding: 6px 13px;
-}
-.markdown-section tr {
- border-top: 1px solid #ccc;
-}
-.markdown-section tr:nth-child(2n) {
- background-color: #f8f8f8;
-}
-.markdown-section p.tip {
- background-color: #f8f8f8;
- border-bottom-right-radius: 2px;
- border-left: 4px solid #f66;
- border-top-right-radius: 2px;
- margin: 2em 0;
- padding: 12px 24px 12px 30px;
- position: relative;
-}
-.markdown-section p.tip:before {
- background-color: #f66;
- border-radius: 100%;
- color: #fff;
- content: '!';
- font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
- font-size: 14px;
- font-weight: bold;
- left: -12px;
- line-height: 20px;
- position: absolute;
- height: 20px;
- width: 20px;
- text-align: center;
- top: 14px;
-}
-.markdown-section p.tip code {
- background-color: #efefef;
-}
-.markdown-section p.tip em {
- color: #34495e;
-}
-.markdown-section p.warn {
- background: rgba(66,185,131,0.1);
- border-radius: 2px;
- padding: 1rem;
-}
-.markdown-section ul.task-list > li {
- list-style-type: none;
-}
-body.close .sidebar {
- transform: translateX(-300px);
-}
-body.close .sidebar-toggle {
- width: auto;
-}
-body.close .content {
- left: 0;
-}
-@media print {
- .github-corner,
- .sidebar-toggle,
- .sidebar,
- .app-nav {
- display: none;
- }
-}
-@media screen and (max-width: 768px) {
- .github-corner,
- .sidebar-toggle,
- .sidebar {
- position: fixed;
- }
- .app-nav {
- margin-top: 16px;
- }
- .app-nav li ul {
- top: 30px;
- }
- main {
- height: auto;
- overflow-x: hidden;
- }
- .sidebar {
- left: -300px;
- transition: transform 250ms ease-out;
- }
- .content {
- left: 0;
- max-width: 100vw;
- position: static;
- padding-top: 20px;
- transition: transform 250ms ease;
- }
- .app-nav,
- .github-corner {
- transition: transform 250ms ease-out;
- }
- .sidebar-toggle {
- background-color: transparent;
- width: auto;
- padding: 30px 30px 10px 10px;
- }
- body.close .sidebar {
- transform: translateX(300px);
- }
- body.close .sidebar-toggle {
- background-color: rgba(255,255,255,0.8);
- transition: 1s background-color;
- width: 284px;
- padding: 10px;
- }
- body.close .content {
- transform: translateX(300px);
- }
- body.close .app-nav,
- body.close .github-corner {
- display: none;
- }
- .github-corner:hover .octo-arm {
- -webkit-animation: none;
- animation: none;
- }
- .github-corner .octo-arm {
- -webkit-animation: octocat-wave 560ms ease-in-out;
- animation: octocat-wave 560ms ease-in-out;
- }
-}
-@-webkit-keyframes octocat-wave {
- 0%, 100% {
- transform: rotate(0);
- }
- 20%, 60% {
- transform: rotate(-25deg);
- }
- 40%, 80% {
- transform: rotate(10deg);
- }
-}
-@keyframes octocat-wave {
- 0%, 100% {
- transform: rotate(0);
- }
- 20%, 60% {
- transform: rotate(-25deg);
- }
- 40%, 80% {
- transform: rotate(10deg);
- }
-}
-section.cover {
- align-items: center;
- background-position: center center;
- background-repeat: no-repeat;
- background-size: cover;
- height: 100vh;
- width: 100vw;
- display: none;
-}
-section.cover.show {
- display: flex;
-}
-section.cover.has-mask .mask {
- background-color: #fff;
- opacity: 0.8;
- position: absolute;
- top: 0;
- height: 100%;
- width: 100%;
-}
-section.cover .cover-main {
- flex: 1;
- margin: -20px 16px 0;
- text-align: center;
- position: relative;
-}
-section.cover a {
- color: inherit;
- text-decoration: none;
-}
-section.cover a:hover {
- text-decoration: none;
-}
-section.cover p {
- line-height: 1.5rem;
- margin: 1em 0;
-}
-section.cover h1 {
- color: inherit;
- font-size: 2.5rem;
- font-weight: 300;
- margin: 0.625rem 0 2.5rem;
- position: relative;
- text-align: center;
-}
-section.cover h1 a {
- display: block;
-}
-section.cover h1 small {
- bottom: -0.4375rem;
- font-size: 1rem;
- position: absolute;
-}
-section.cover blockquote {
- font-size: 1.5rem;
- text-align: center;
-}
-section.cover ul {
- line-height: 1.8;
- list-style-type: none;
- margin: 1em auto;
- max-width: 500px;
- padding: 0;
-}
-section.cover .cover-main > p:last-child a {
- border-color: var(--theme-color, #42b983);
- border-radius: 2rem;
- border-style: solid;
- border-width: 1px;
- box-sizing: border-box;
- color: var(--theme-color, #42b983);
- display: inline-block;
- font-size: 1.05rem;
- letter-spacing: 0.1rem;
- margin: 0.5rem 1rem;
- padding: 0.75em 2rem;
- text-decoration: none;
- transition: all 0.15s ease;
-}
-section.cover .cover-main > p:last-child a:last-child {
- background-color: var(--theme-color, #42b983);
- color: #fff;
-}
-section.cover .cover-main > p:last-child a:last-child:hover {
- color: inherit;
- opacity: 0.8;
-}
-section.cover .cover-main > p:last-child a:hover {
- color: inherit;
-}
-section.cover blockquote > p > a {
- border-bottom: 2px solid var(--theme-color, #42b983);
- transition: color 0.3s;
-}
-section.cover blockquote > p > a:hover {
- color: var(--theme-color, #42b983);
-}
-body {
- background-color: #fff;
-}
-/* sidebar */
-.sidebar {
- background-color: #fff;
- color: #364149;
-}
-.sidebar li {
- margin: 6px 0 6px 0;
-}
-.sidebar ul li a {
- color: #505d6b;
- font-size: 14px;
- font-weight: normal;
- overflow: hidden;
- text-decoration: none;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.sidebar ul li a:hover {
- text-decoration: underline;
-}
-.sidebar ul li ul {
- padding: 0;
-}
-.sidebar ul li.active > a {
- border-right: 2px solid;
- color: var(--theme-color, #42b983);
- font-weight: 600;
-}
-.app-sub-sidebar li::before {
- content: '-';
- padding-right: 4px;
- float: left;
-}
-/* markdown content found on pages */
-.markdown-section h1,
-.markdown-section h2,
-.markdown-section h3,
-.markdown-section h4,
-.markdown-section strong {
- color: #2c3e50;
- font-weight: 600;
-}
-.markdown-section a {
- color: var(--theme-color, #42b983);
- font-weight: 600;
-}
-.markdown-section h1 {
- font-size: 2rem;
- margin: 0 0 1rem;
-}
-.markdown-section h2 {
- font-size: 1.75rem;
- margin: 45px 0 0.8rem;
-}
-.markdown-section h3 {
- font-size: 1.5rem;
- margin: 40px 0 0.6rem;
-}
-.markdown-section h4 {
- font-size: 1.25rem;
-}
-.markdown-section h5 {
- font-size: 1rem;
-}
-.markdown-section h6 {
- color: #777;
- font-size: 1rem;
-}
-.markdown-section figure,
-.markdown-section p {
- margin: 1.2em 0;
-}
-.markdown-section p,
-.markdown-section ul,
-.markdown-section ol {
- line-height: 1.6rem;
- word-spacing: 0.05rem;
-}
-.markdown-section ul,
-.markdown-section ol {
- padding-left: 1.5rem;
-}
-.markdown-section blockquote {
- border-left: 4px solid var(--theme-color, #42b983);
- color: #858585;
- margin: 2em 0;
- padding-left: 20px;
-}
-.markdown-section blockquote p {
- font-weight: 600;
- margin-left: 0;
-}
-.markdown-section iframe {
- margin: 1em 0;
-}
-.markdown-section em {
- color: #7f8c8d;
-}
-.markdown-section code {
- background-color: #f8f8f8;
- border-radius: 2px;
- color: #e96900;
- font-family: 'Roboto Mono', Monaco, courier, monospace;
- font-size: 0.8rem;
- margin: 0 2px;
- padding: 3px 5px;
- white-space: pre-wrap;
-}
-.markdown-section pre {
- -moz-osx-font-smoothing: initial;
- -webkit-font-smoothing: initial;
- background-color: #f8f8f8;
- font-family: 'Roboto Mono', Monaco, courier, monospace;
- line-height: 1.5rem;
- margin: 1.2em 0;
- overflow: auto;
- padding: 0 1.4rem;
- position: relative;
- word-wrap: normal;
-}
-/* code highlight */
-.token.comment,
-.token.prolog,
-.token.doctype,
-.token.cdata {
- color: #8e908c;
-}
-.token.namespace {
- opacity: 0.7;
-}
-.token.boolean,
-.token.number {
- color: #c76b29;
-}
-.token.punctuation {
- color: #525252;
-}
-.token.property {
- color: #c08b30;
-}
-.token.tag {
- color: #2973b7;
-}
-.token.string {
- color: var(--theme-color, #42b983);
-}
-.token.selector {
- color: #6679cc;
-}
-.token.attr-name {
- color: #2973b7;
-}
-.token.entity,
-.token.url,
-.language-css .token.string,
-.style .token.string {
- color: #22a2c9;
-}
-.token.attr-value,
-.token.control,
-.token.directive,
-.token.unit {
- color: var(--theme-color, #42b983);
-}
-.token.keyword,
-.token.function {
- color: #e96900;
-}
-.token.statement,
-.token.regex,
-.token.atrule {
- color: #22a2c9;
-}
-.token.placeholder,
-.token.variable {
- color: #3d8fd1;
-}
-.token.deleted {
- text-decoration: line-through;
-}
-.token.inserted {
- border-bottom: 1px dotted #202746;
- text-decoration: none;
-}
-.token.italic {
- font-style: italic;
-}
-.token.important,
-.token.bold {
- font-weight: bold;
-}
-.token.important {
- color: #c94922;
-}
-.token.entity {
- cursor: help;
-}
-.markdown-section pre > code {
- -moz-osx-font-smoothing: initial;
- -webkit-font-smoothing: initial;
- background-color: #f8f8f8;
- border-radius: 2px;
- color: #525252;
- display: block;
- font-family: 'Roboto Mono', Monaco, courier, monospace;
- font-size: 0.8rem;
- line-height: inherit;
- margin: 0 2px;
- max-width: inherit;
- overflow: inherit;
- padding: 2.2em 5px;
- white-space: inherit;
-}
-.markdown-section code::after,
-.markdown-section code::before {
- letter-spacing: 0.05rem;
-}
-code .token {
- -moz-osx-font-smoothing: initial;
- -webkit-font-smoothing: initial;
- min-height: 1.5rem;
- position: relative;
- left: auto;
-}
-pre::after {
- color: #ccc;
- content: attr(data-lang);
- font-size: 0.6rem;
- font-weight: 600;
- height: 15px;
- line-height: 15px;
- padding: 5px 10px 0;
- position: absolute;
- right: 0;
- text-align: right;
- top: 0;
-}
diff --git a/.nojekyll b/docs/Algorithm_Templates/Cipher/README.md
similarity index 100%
rename from .nojekyll
rename to docs/Algorithm_Templates/Cipher/README.md
diff --git a/docs/Algorithm_Templates/Compression/README.md b/docs/Algorithm_Templates/Compression/README.md
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/docs/Algorithm_Templates/Compression/README.md
@@ -0,0 +1 @@
+
diff --git a/docs/Algorithm_Templates/Conversion/README.md b/docs/Algorithm_Templates/Conversion/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/Algorithm_Templates/Data_Structure/Graph/README.md b/docs/Algorithm_Templates/Data_Structure/Graph/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/Graph/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/HashMap/README.md b/docs/Algorithm_Templates/Data_Structure/HashMap/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/HashMap/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/HashTable/README.md b/docs/Algorithm_Templates/Data_Structure/HashTable/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/HashTable/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/Heqp/README.md b/docs/Algorithm_Templates/Data_Structure/Heqp/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/Heqp/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/LinkedList/README.md b/docs/Algorithm_Templates/Data_Structure/LinkedList/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/LinkedList/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/Matrix/README.md b/docs/Algorithm_Templates/Data_Structure/Matrix/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/Matrix/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/Queue/README.md b/docs/Algorithm_Templates/Data_Structure/Queue/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/Queue/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/README.md b/docs/Algorithm_Templates/Data_Structure/README.md
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/README.md
@@ -0,0 +1 @@
+
diff --git a/docs/Algorithm_Templates/Data_Structure/Stack/README.md b/docs/Algorithm_Templates/Data_Structure/Stack/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/Stack/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Data_Structure/Tree/README.md b/docs/Algorithm_Templates/Data_Structure/Tree/README.md
new file mode 100644
index 000000000..fe9c7bbf3
--- /dev/null
+++ b/docs/Algorithm_Templates/Data_Structure/Tree/README.md
@@ -0,0 +1,15 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](/opt/git/LeetCode/docs/Algorithm\ Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](/opt/git/LeetCode/docs/src/py2.x/SortingAlgorithm/MergeSort.py) |
+| 基数排序 |  | |
diff --git a/docs/Algorithm_Templates/Dynamic_Programming/README.md b/docs/Algorithm_Templates/Dynamic_Programming/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/Algorithm_Templates/Hash/README.md b/docs/Algorithm_Templates/Hash/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/Algorithm_Templates/README.md b/docs/Algorithm_Templates/README.md
new file mode 100644
index 000000000..8e0b4dd33
--- /dev/null
+++ b/docs/Algorithm_Templates/README.md
@@ -0,0 +1,16 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/MergeSort.py) |
+| 基数排序 |  | [RadixSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/RadixSort.py) |
+
diff --git a/docs/Algorithm_Templates/Search/README.md b/docs/Algorithm_Templates/Search/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/Algorithm_Templates/Sort/BubbleSort.py b/docs/Algorithm_Templates/Sort/BubbleSort.py
new file mode 100644
index 000000000..6e2f23940
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/BubbleSort.py
@@ -0,0 +1,19 @@
+# coding:utf-8
+
+
+# 冒泡排序
+def bubble_sort(l):
+ length = len(l)
+ # 外层循环 length遍,内层循环少一遍
+ while length:
+ for j in range(length - 1):
+ # 找出最大值,然后交换位置到最后
+ if l[j] > l[length - 1]:
+ l[j], l[length - 1] = l[length - 1], l[j]
+ length -= 1
+
+
+if __name__ == "__main__":
+ l = [5, 1, 9, 3, 2, 7]
+ bubble_sort(l)
+ print l
diff --git a/docs/Algorithm_Templates/Sort/InsertSort.py b/docs/Algorithm_Templates/Sort/InsertSort.py
new file mode 100644
index 000000000..09b935114
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/InsertSort.py
@@ -0,0 +1,24 @@
+# coding:utf8
+"""
+插入排序和冒泡排序的区别在于:
+
+插入排序的前提是:左边是有序的数列
+而冒泡排序:相邻的值进行交换,一共进行n次交换
+"""
+
+
+def insert_sort(l):
+ # 循环 除第一个数字组成的有序数组 以外的数字
+ for i in range(1, len(l)):
+ # 每一个数字,依次和有序数组进行比较
+ print l[:i]
+ for j in range(len(l[:i])):
+ if l[i] < l[j]:
+ l[i], l[j] = l[j], l[i]
+
+
+if __name__ == "__main__":
+ l = [5, 1, 9, 3, 2, 7]
+ print l
+ insert_sort(l)
+ print("result: " + str(l))
diff --git a/docs/Algorithm_Templates/Sort/MergeSort.py b/docs/Algorithm_Templates/Sort/MergeSort.py
new file mode 100644
index 000000000..1ad19e86d
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/MergeSort.py
@@ -0,0 +1,35 @@
+# coding: utf-8
+
+
+def MergeSort(lists):
+ if len(lists) <= 1:
+ return lists
+ num = int(len(lists) / 2)
+ # 从中间,进行数据的拆分, 递归的返回数据进行迭代排序
+ left = MergeSort(lists[:num])
+ right = MergeSort(lists[num:])
+ print left
+ print "*" * 20
+ print right
+ print "_" * 20
+ return Merge(left, right)
+
+
+def Merge(left, right):
+ r, l = 0, 0
+ result = []
+ while l < len(left) and r < len(right):
+ if left[l] < right[r]:
+ result.append(left[l])
+ l += 1
+ else:
+ result.append(right[r])
+ r += 1
+ result += right[r:]
+ result += left[l:]
+ print 'result:', result
+ return result
+
+
+if __name__ == "__main__":
+ print MergeSort([1, 2, 3, 4, 5, 6, 7, 90, 21, 23, 45])
diff --git a/docs/Algorithm_Templates/Sort/QuickSort.py b/docs/Algorithm_Templates/Sort/QuickSort.py
new file mode 100644
index 000000000..acf81118a
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/QuickSort.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+# coding:utf8
+
+
+def quick_sort(l, start, end):
+ i = start
+ j = end
+ # 结束排序
+ if i >= j:
+ return
+ # 保存首个数值
+ key = l[i]
+ # 一次排序,i和j的值不断的靠拢,然后最终停止,结束一次排序
+ while i < j:
+ # 和最右边的比较,如果>=key,然后j-1,慢慢的和前一个值比较;如果值key,那么就交换位置
+ while i < j and key >= l[i]:
+ print key, l[i], '*' * 30
+ i += 1
+ l[j] = l[i]
+ l[i] = key
+ # 左边排序
+ quick_sort(l, start, j-1)
+ # 右边排序
+ quick_sort(l, i+1, end)
+
+
+if __name__ == "__main__":
+ l = [5, 1, 9, 3, 2, 7]
+ quick_sort(l, 0, len(l) - 1)
+ print l
diff --git a/docs/Algorithm_Templates/Sort/README.md b/docs/Algorithm_Templates/Sort/README.md
new file mode 100644
index 000000000..8e0b4dd33
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/README.md
@@ -0,0 +1,16 @@
+# Some algorithm templates for better understanding!
+
+## 八大排序算法
+
+
+
+| 名称 | 动图 | 代码 |
+| --- | --- | --- |
+| 冒泡排序 |  | [BubbleSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/BubbleSort.py) |
+| 插入排序 |  | [InsertSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/InsertSort.py) |
+| 选择排序 |  | [SelectionSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/SelectionSort.py) |
+| 快速排序 |  | [QuickSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/QuickSort.py) |
+| 希尔排序 |  | [ShellSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/ShellSort.py) |
+| 归并排序 |  | [MergeSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/MergeSort.py) |
+| 基数排序 |  | [RadixSort.py](https://github.com/apachecn/LeetCode/blob/master/docs/Algorithm_Templates/Sort/RadixSort.py) |
+
diff --git a/docs/Algorithm_Templates/Sort/RadixSort.py b/docs/Algorithm_Templates/Sort/RadixSort.py
new file mode 100644
index 000000000..e5fc2aba3
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/RadixSort.py
@@ -0,0 +1,46 @@
+#************************基数排序****************************
+#确定排序的次数
+#排序的顺序跟序列中最大数的位数相关
+def radix_sort_nums(L):
+ maxNum = L[0]
+#寻找序列中的最大数
+ for x in L:
+ if maxNum < x:
+ maxNum = x
+#确定序列中的最大元素的位数
+ times = 0
+ while (maxNum > 0):
+ maxNum = int((maxNum/10))
+ times += 1
+ return times
+#找到num从低到高第pos位的数据
+def get_num_pos(num, pos):
+ return (int((num/(10**(pos-1))))) % 10
+#基数排序
+def radix_sort(L):
+ count = 10 * [None] #存放各个桶的数据统计个数
+ bucket = len(L) * [None] #暂时存放排序结果
+#从低位到高位依次执行循环
+ for pos in range(1, radix_sort_nums(L)+1):
+ #置空各个桶的数据统计
+ for x in range(0, 10):
+ count[x] = 0
+ #统计当前该位(个位,十位,百位....)的元素数目
+ for x in range(0, len(L)):
+ #统计各个桶将要装进去的元素个数
+ j = get_num_pos(int(L[x]), pos)
+ count[j] += 1
+ #count[i]表示第i个桶的右边界索引
+ for x in range(1,10):
+ count[x] += count[x-1]
+ #将数据依次装入桶中
+ for x in range(len(L)-1, -1, -1):
+ #求出元素第K位的数字
+ j = get_num_pos(L[x], pos)
+ #放入对应的桶中,count[j]-1是第j个桶的右边界索引
+ bucket[count[j]-1] = L[x]
+ #对应桶的装入数据索引-1
+ count[j] -= 1
+ # 将已分配好的桶中数据再倒出来,此时已是对应当前位数有序的表
+ for x in range(0, len(L)):
+ L[x] = bucket[x]
diff --git a/docs/Algorithm_Templates/Sort/SelectionSort.py b/docs/Algorithm_Templates/Sort/SelectionSort.py
new file mode 100644
index 000000000..98ef64f72
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/SelectionSort.py
@@ -0,0 +1,28 @@
+# coding:utf8
+"""
+选择排序和冒泡排序的区别在于:
+
+选择排序的前提是:找到最大值的位置,最后才进行1次交换
+而冒泡排序:相邻的值进行交换,一共进行n次交换
+"""
+
+
+def selection_sort(l):
+ length = len(l) - 1
+
+ while length:
+ index = length
+ # 第一个数字,和后面每一个数字进行对比,找出最大值,放到最后!!
+ for j in range(length):
+ if l[j] > l[index]:
+ index = j
+ l[length], l[index] = l[index], l[length]
+ print len(l) - length, l
+ length -= 1
+
+
+if __name__ == "__main__":
+ l = [5, 1, 9, 3, 2, 7]
+ print l
+ selection_sort(l)
+ print("result: " + str(l))
\ No newline at end of file
diff --git a/docs/Algorithm_Templates/Sort/ShellSort.py b/docs/Algorithm_Templates/Sort/ShellSort.py
new file mode 100644
index 000000000..9f591a84b
--- /dev/null
+++ b/docs/Algorithm_Templates/Sort/ShellSort.py
@@ -0,0 +1,25 @@
+# coding: utf8
+
+def insert_sort(l, start, increment):
+ for i in range(start+increment, len(l), increment):
+ for j in range(start, len(l[:i]), increment):
+ if l[i] < l[j]:
+ l[i], l[j] = l[j], l[i]
+ print increment, '--',l
+ return l
+
+def shell_sort(l, increment):
+ # 依次进行分层
+ while increment:
+ # 每一层,都进行n次插入排序
+ for i in range(0, increment):
+ insert_sort(l, i, increment)
+ increment -= 1
+ return l
+
+if __name__ == "__main__":
+ l = [5, 2, 9, 8, 1, 10, 3, 4, 7]
+ increment = len(l)/3+1 if len(l)%3 else len(l)/3
+ print "开始", l
+ l = shell_sort(l, increment)
+ print "结束", l
\ No newline at end of file
diff --git a/docs/Algorithm_Templates/Traversals/README.md b/docs/Algorithm_Templates/Traversals/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/Leetcode_Solutions/001._two_sum.md b/docs/Leetcode_Solutions/001._two_sum.md
new file mode 100644
index 000000000..120db871d
--- /dev/null
+++ b/docs/Leetcode_Solutions/001._two_sum.md
@@ -0,0 +1,43 @@
+### 1. Two Sum
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+思路
+
+可以用O(n^2) loop
+
+但是也可以牺牲空间换取时间,异常聪明的AC解法
+
+```
+ 2 7 11 15
+ 不存在 存在之中
+lookup {2:0} [0,1]
+```
+
+一但字典内有了这个 `target - 当前数字`,找到它的index和当前index一起返回。
+
+
+```python
+class Solution(object):
+ def twoSum(self, nums, target):
+ """
+ :type nums: List[int]
+ :type target: int
+ :rtype: List[int]
+ """
+ lookup = {}
+ for i, num in enumerate(nums):
+ if target - num in lookup:
+ return [lookup[target - num],i]
+ lookup[num] = i
+ return []
+```
+
+
diff --git a/docs/Leetcode_Solutions/002._add_two_numbers.md b/docs/Leetcode_Solutions/002._add_two_numbers.md
new file mode 100644
index 000000000..7ead7c7c4
--- /dev/null
+++ b/docs/Leetcode_Solutions/002._add_two_numbers.md
@@ -0,0 +1,37 @@
+### 2. Add Two Numbers
+
+题目:
+
+
+
+难度 : Medium
+
+
+跟plus One, add Binary 玩的同一种花样
+
+
+```python
+class Solution(object):
+ def addTwoNumbers(self, l1, l2):
+ """
+ :type l1: ListNode
+ :type l2: ListNode
+ :rtype: ListNode
+ """
+ #easiest case
+ if l1 == None:
+ return l2
+ if l2 == None:
+ return l1
+
+ if l1.val + l2.val < 10:
+ l3 = ListNode(l1.val + l2.val)
+ l3.next = self.addTwoNumbers(l1.next, l2.next)
+
+ elif l1.val + l2.val >= 10:
+ l3 = ListNode(l1.val + l2.val - 10)
+ tmp = ListNode(1)
+ tmp.next = None
+ l3.next = self.addTwoNumbers(l1.next, self.addTwoNumbers(l2.next ,tmp))
+ return l3
+```
diff --git a/docs/leetcode/python/003._longest_substring_without_repeating_characters.md b/docs/Leetcode_Solutions/003._longest_substring_without_repeating_characters.md
similarity index 96%
rename from docs/leetcode/python/003._longest_substring_without_repeating_characters.md
rename to docs/Leetcode_Solutions/003._longest_substring_without_repeating_characters.md
index ea5d372f5..8b8ef18eb 100644
--- a/docs/leetcode/python/003._longest_substring_without_repeating_characters.md
+++ b/docs/Leetcode_Solutions/003._longest_substring_without_repeating_characters.md
@@ -81,4 +81,4 @@ Author: Keqi Huang
If you like it, please spread your support
-
+
diff --git a/docs/leetcode/python/004._median_of_two_sorted_arrays.md b/docs/Leetcode_Solutions/004._median_of_two_sorted_arrays.md
similarity index 97%
rename from docs/leetcode/python/004._median_of_two_sorted_arrays.md
rename to docs/Leetcode_Solutions/004._median_of_two_sorted_arrays.md
index 655bc4f9c..8ad14bbb6 100644
--- a/docs/leetcode/python/004._median_of_two_sorted_arrays.md
+++ b/docs/Leetcode_Solutions/004._median_of_two_sorted_arrays.md
@@ -1,260 +1,260 @@
-### 4. Median of Two Sorted Arrays
-
-题目:
-
-
-
-难度:
-
-Hard
-
-
-一看到的时候,觉得跟CLRS书上的一道习题类似
-求X[1....n] Y[1....n] 的 median
-
-习题 9.3-8
-
-
-Let X[1..n] and Y [1..n] be two arrays, each containing n numbers already in sorted order. Give an O(lg n)-time algorithn to find the median of all 2n elements in arrays X and Y .
-
-
-> The median can be obtained recursively as follows. Pick the median of the sorted array A. This is just O(1) time as median is the n/2th element in the sorted array. Now compare the median of A, call is a∗ with median of B, b∗. We have two cases.
-
-- a∗ < b∗ : In this case, the elements in B[n/2 ···n] are also greater than a . So the median cannot lie in either A[1 · · · n/2 ] or B[n/2 · · · n]. So we can just throw these away and recursively
-
-- a∗ > b∗ : In this case, we can still throw away B[1··· n/2] and also A[ n/ · · · n] and solve a smaller subproblem recursively.
-
-
-In either case, our subproblem size reduces by a factor of half and we spend only constant time to compare the medians of A and B. So the recurrence relation would be T (n) = T (n/2) + O(1) which has a solution T (n) = O(log n).
-
-
-divide and conquer
-
-- 如果X[n/2] == Y[n/2],则找到,return
-- 如果X[n/2] < Y[n/2],找X[n/2+1….n]和Y[1,2…n/2]之间
-- 否则找X[1..n/2]和Y[n/2…n]
-
-
-
-
-但是实际上不同,这里需要考虑的问题更多:
-
-- 两个数组长度不一样
-- 并不是只找一个median,如果median有两个,需要算平均
-
-思路
-
-把它转化成经典的findKth问题
-
-参考:
-
-
-首先转成求A和B数组中第k小的数的问题, 然后用k/2在A和B中分别找。
-
-
-比如k = 6, 分别看A和B中的第3个数, 已知 A1 < A2 < A3 < A4 < A5... 和 B1 < B2 < B3 < B4 < B5..., 如果A3 <= B3, 那么第6小的数肯定不会是A1, A2, A3, 因为最多有两个数小于A1, 三个数小于A2, 四个数小于A3。 关键点是从 k/2 开始来找。
-
-
-
-B3至少大于5个数, 所以第6小的数有可能是B1 (A1 < A2 < A3 < A4 < A5 < B1), 有可能是B2 (A1 < A2 < A3 < B1 < A4 < B2), 有可能是B3 (A1 < A2 < A3 < B1 < B2 < B3)。那就可以排除掉A1, A2, A3, 转成求A4, A5, ... B1, B2, B3, ...这些数中第3小的数的问题, k就被减半了。每次都假设A的元素个数少, pa = min(k/2, lenA)的结果可能导致k == 1或A空, 这两种情况都是终止条件。
-
-
-发问,为什么要从k/2开始寻找,依旧k = 6, 我可以比较A1 和 B5的关系么,可以这样做,但是明显的问题出现在如果A1 > B5,那么这个第6小的数应该存在于B6和A1中。
-
-如果A1 < B5,这个时间可能性就很多了,比如A1 < A2 < A3 < A4 < B1 < B2,各种可能,无法排除元素,所以还是要从k/2开始寻找。
-
-这个跟习题算法的区别是每次扔的东西明显少一些,但是k也在不断变小。下面的代码的时间复杂度是O(lg(m+n))
-
-
-```python
-class Solution(object):
- def findMedianSortedArrays(self, nums1, nums2):
- """
- :type nums1: List[int]
- :type nums2: List[int]
- :rtype: float
- """
- n = len(nums1) + len(nums2)
- if n % 2 == 1:
- return self.findKth(nums1, nums2, n / 2 + 1)
- else:
- smaller = self.findKth(nums1, nums2, n / 2)
- bigger = self.findKth(nums1, nums2, n / 2 + 1)
- return (smaller + bigger) / 2.0
-
-
- def findKth(self, A, B, k):
- if len(A) == 0:
- return B[k-1]
- if len(B) == 0:
- return A[k-1]
- if k == 1 :
- return min(A[0],B[0])
-
-
- a = A[ k / 2 - 1 ] if len(A) >= k / 2 else None
- b = B[ k / 2 - 1 ] if len(B) >= k / 2 else None
-
- if b is None or (a is not None and a < b):
- return self.findKth(A[k/2:], B, k - k/2)
- return self.findKth(A, B[k/2:],k - k/2) #这里要注意:因为 k/2 不一定 等于 (k - k/2),
-
-
-```
-```python
-#python3里面要用向下取整函数才可以AC,否则报错,TypeError: list indices must be integers or slices, not float
-
-from math import floor
-class Solution:
- def findMedianSortedArrays(self, nums1, nums2):
- """
- :type nums1: List[int]
- :type nums2: List[int]
- :rtype: float
- """
- n = len(nums1) + len(nums2)
- if n % 2 == 1:
- return self.findKth(nums1, nums2, floor(n/2)+1)
- else:
- smaller = self.findKth(nums1, nums2, floor(n/2))
- bigger = self.findKth(nums1, nums2, floor(n/2)+1)
- return (smaller + bigger) / 2.0
- def findKth(self, A, B, k):
-
- if len(A) == 0:
- return B[k-1]
- if len(B) == 0:
- return A[k-1]
- if k == 1:
- return min(A[0], B[0])
- a = A[floor(k/2)-1] if len(A) >= k/2 else None
- b = B[floor(k/2)-1] if len(B) >= k/2 else None
- if b is None or (a is not None and a < b):
- return self.findKth(A[floor(k/2):], B, k - floor(k/2))
- else:
- return self.findKth(A, B[floor(k/2):], k - floor(k/2))
-```
-
-这个findKth的算法单独抽出来也是题目。
-### 寻找最小的k个数
-
-题目描述
-
-输入n个整数,输出其中最小的k个。
-分析与解法
-
-## 解法一
-
-要求一个序列中最小的k个数,按照惯有的思维方式,则是先对这个序列从小到大排序,然后输出前面的最小的k个数。
-至于选取什么的排序方法,我想你可能会第一时间想到快速排序(我们知道,快速排序平均所费时间为n*logn),然后再遍历序列中前k个元素输出即可。因此,总的时间复杂度:```O(n * log n)+O(k)=O(n * log n)```。
-## 解法二
-
-咱们再进一步想想,题目没有要求最小的```k```个数有序,也没要求最后```n-k```个数有序。既然如此,就没有必要对所有元素进行排序。这时,咱们想到了用选择或交换排序,即:
-1. 遍历```n```个数,把最先遍历到的k个数存入到大小为```k```的数组中,假设它们即是最小的```k```个数;
-2. 对这```k```个数,利用选择或交换排序找到这k个元素中的最大值```kmax```(找最大值需要遍历这```k```个数,时间复杂度为```O(k))```;
-3. 继续遍历剩余```n-k```个数。假设每一次遍历到的新的元素的值为```x```,把```x```与```kmax```比较:如果```x``` < ```kmax``` ,用```x```替换```kmax```,并回到第二步重新找出k个元素的数组中最大元素kmax‘;如果```x >= kmax```,则继续遍历不更新数组。
-每次遍历,更新或不更新数组的所用的时间为```O(k)```或```O(0)```。故整趟下来,时间复杂度为```n*O(k)=O(n*k)```。
-## 解法三
-
-更好的办法是维护容量为k的最大堆,原理跟解法二的方法相似:
-1. 用容量为```k```的最大堆存储最先遍历到的```k```个数,同样假设它们即是最小的```k```个数;
-2. 堆中元素是有序的,令```k1 pivot ){ }
- if( i < j )
- swap( &a[ i ], &a[ j ] );
- else
- break;
- }
- //重置枢纽元
- swap( &a[ i ], &a[ right - 1 ] );
-
- if( k <= i )
- QuickSelect( a, k, left, i - 1 );
- else if( k > i + 1 )
- QuickSelect( a, k, i + 1, right );
- }
- else
- InsertSort( a + left, right - left + 1 );
-}
-```
-这个快速选择SELECT算法,类似快速排序的划分方法。N个数存储在数组S中,再从数组中选取“中位数的中位数”作为枢纽元X,把数组划分为Sa和Sb俩部分,Sa<=X<=Sb,如果要查找的k个元素小于Sa的元素个数,则返回Sa中较小的k个元素,否则返回Sa中所有元素+Sb中小的k-|Sa|个元素,这种解法在平均情况下能做到O(n)的复杂度。
-更进一步,《算法导论》第9章第9.3节介绍了一个最坏情况下亦为O(n)时间的SELECT算法,有兴趣的读者可以参看。
-
-给定两个已经排序好的数组,求第k大的,算法有O(m+n).类似merge sort的原理。否则利用的就是之上提到的,利用已经有序的原理,然后每次丢。
-
-之所以这里还有一个丢弃条件是b is None 丢A的一部分,是因为B的数组长度是有限的,这个时候很明显丢A的k/2是不影响的,因为无论B[-1]是如何大或者小,因为整个B的长度没有达到k/2小,所以丢掉的这部分最大的A[k/2-1]也不可能是第k个,因为即使整个B都比A[k/2-1]小,拼起来也不能使A[k/2-1]第k大,所以可以放心丢弃。
-
-
-这里是两个sorted list/array findKth,想到了类似的题目,如果给一个n个linked list,findKth,能想到的办法也只能是用heap吧,类似merge k sorted lists.
-
-
-再写一个O(m+n)类似merge sort的也可以AC的代码
-
-```python
-class Solution(object):
- def findMedianSortedArrays(self, nums1, nums2):
- """
- :type nums1: List[int]
- :type nums2: List[int]
- :rtype: float
- """
- def findKth(A, pa, B, pb, k):
- res = 0
- m = 0
- while pa < len(A) and pb < len(B) and m < k:
- if A[pa] < B[pb]:
- res = A[pa]
- m += 1
- pa += 1
- else:
- res = B[pb]
- m += 1
- pb += 1
-
- while pa < len(A) and m < k:
- res = A[pa]
- pa += 1
- m += 1
-
-
- while pb < len(B) and m < k:
- res = B[pb]
- pb += 1
- m += 1
- return res
-
- n = len(nums1) + len(nums2)
- if n % 2 == 1:
- return findKth(nums1,0, nums2,0, n / 2 + 1)
- else:
- smaller = findKth(nums1,0, nums2,0, n / 2)
- bigger = findKth(nums1,0, nums2,0, n / 2 + 1)
- return (smaller + bigger) / 2.0
-
-```
+### 4. Median of Two Sorted Arrays
+
+题目:
+
+
+
+难度:
+
+Hard
+
+
+一看到的时候,觉得跟CLRS书上的一道习题类似
+求X[1....n] Y[1....n] 的 median
+
+习题 9.3-8
+
+
+Let X[1..n] and Y [1..n] be two arrays, each containing n numbers already in sorted order. Give an O(lg n)-time algorithn to find the median of all 2n elements in arrays X and Y .
+
+
+> The median can be obtained recursively as follows. Pick the median of the sorted array A. This is just O(1) time as median is the n/2th element in the sorted array. Now compare the median of A, call is a∗ with median of B, b∗. We have two cases.
+
+- a∗ < b∗ : In this case, the elements in B[n/2 ···n] are also greater than a . So the median cannot lie in either A[1 · · · n/2 ] or B[n/2 · · · n]. So we can just throw these away and recursively
+
+- a∗ > b∗ : In this case, we can still throw away B[1··· n/2] and also A[ n/ · · · n] and solve a smaller subproblem recursively.
+
+
+In either case, our subproblem size reduces by a factor of half and we spend only constant time to compare the medians of A and B. So the recurrence relation would be T (n) = T (n/2) + O(1) which has a solution T (n) = O(log n).
+
+
+divide and conquer
+
+- 如果X[n/2] == Y[n/2],则找到,return
+- 如果X[n/2] < Y[n/2],找X[n/2+1….n]和Y[1,2…n/2]之间
+- 否则找X[1..n/2]和Y[n/2…n]
+
+
+
+
+但是实际上不同,这里需要考虑的问题更多:
+
+- 两个数组长度不一样
+- 并不是只找一个median,如果median有两个,需要算平均
+
+思路
+
+把它转化成经典的findKth问题
+
+参考:
+
+
+首先转成求A和B数组中第k小的数的问题, 然后用k/2在A和B中分别找。
+
+
+比如k = 6, 分别看A和B中的第3个数, 已知 A1 < A2 < A3 < A4 < A5... 和 B1 < B2 < B3 < B4 < B5..., 如果A3 <= B3, 那么第6小的数肯定不会是A1, A2, A3, 因为最多有两个数小于A1, 三个数小于A2, 四个数小于A3。 关键点是从 k/2 开始来找。
+
+
+
+B3至少大于5个数, 所以第6小的数有可能是B1 (A1 < A2 < A3 < A4 < A5 < B1), 有可能是B2 (A1 < A2 < A3 < B1 < A4 < B2), 有可能是B3 (A1 < A2 < A3 < B1 < B2 < B3)。那就可以排除掉A1, A2, A3, 转成求A4, A5, ... B1, B2, B3, ...这些数中第3小的数的问题, k就被减半了。每次都假设A的元素个数少, pa = min(k/2, lenA)的结果可能导致k == 1或A空, 这两种情况都是终止条件。
+
+
+发问,为什么要从k/2开始寻找,依旧k = 6, 我可以比较A1 和 B5的关系么,可以这样做,但是明显的问题出现在如果A1 > B5,那么这个第6小的数应该存在于B6和A1中。
+
+如果A1 < B5,这个时间可能性就很多了,比如A1 < A2 < A3 < A4 < B1 < B2,各种可能,无法排除元素,所以还是要从k/2开始寻找。
+
+这个跟习题算法的区别是每次扔的东西明显少一些,但是k也在不断变小。下面的代码的时间复杂度是O(lg(m+n))
+
+
+```python
+class Solution(object):
+ def findMedianSortedArrays(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: float
+ """
+ n = len(nums1) + len(nums2)
+ if n % 2 == 1:
+ return self.findKth(nums1, nums2, n / 2 + 1)
+ else:
+ smaller = self.findKth(nums1, nums2, n / 2)
+ bigger = self.findKth(nums1, nums2, n / 2 + 1)
+ return (smaller + bigger) / 2.0
+
+
+ def findKth(self, A, B, k):
+ if len(A) == 0:
+ return B[k-1]
+ if len(B) == 0:
+ return A[k-1]
+ if k == 1 :
+ return min(A[0],B[0])
+
+
+ a = A[ k / 2 - 1 ] if len(A) >= k / 2 else None
+ b = B[ k / 2 - 1 ] if len(B) >= k / 2 else None
+
+ if b is None or (a is not None and a < b):
+ return self.findKth(A[k/2:], B, k - k/2)
+ return self.findKth(A, B[k/2:],k - k/2) #这里要注意:因为 k/2 不一定 等于 (k - k/2),
+
+
+```
+```python
+#python3里面要用向下取整函数才可以AC,否则报错,TypeError: list indices must be integers or slices, not float
+
+from math import floor
+class Solution:
+ def findMedianSortedArrays(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: float
+ """
+ n = len(nums1) + len(nums2)
+ if n % 2 == 1:
+ return self.findKth(nums1, nums2, floor(n/2)+1)
+ else:
+ smaller = self.findKth(nums1, nums2, floor(n/2))
+ bigger = self.findKth(nums1, nums2, floor(n/2)+1)
+ return (smaller + bigger) / 2.0
+ def findKth(self, A, B, k):
+
+ if len(A) == 0:
+ return B[k-1]
+ if len(B) == 0:
+ return A[k-1]
+ if k == 1:
+ return min(A[0], B[0])
+ a = A[floor(k/2)-1] if len(A) >= k/2 else None
+ b = B[floor(k/2)-1] if len(B) >= k/2 else None
+ if b is None or (a is not None and a < b):
+ return self.findKth(A[floor(k/2):], B, k - floor(k/2))
+ else:
+ return self.findKth(A, B[floor(k/2):], k - floor(k/2))
+```
+
+这个findKth的算法单独抽出来也是题目。
+### 寻找最小的k个数
+
+题目描述
+
+输入n个整数,输出其中最小的k个。
+分析与解法
+
+## 解法一
+
+要求一个序列中最小的k个数,按照惯有的思维方式,则是先对这个序列从小到大排序,然后输出前面的最小的k个数。
+至于选取什么的排序方法,我想你可能会第一时间想到快速排序(我们知道,快速排序平均所费时间为n*logn),然后再遍历序列中前k个元素输出即可。因此,总的时间复杂度:```O(n * log n)+O(k)=O(n * log n)```。
+## 解法二
+
+咱们再进一步想想,题目没有要求最小的```k```个数有序,也没要求最后```n-k```个数有序。既然如此,就没有必要对所有元素进行排序。这时,咱们想到了用选择或交换排序,即:
+1. 遍历```n```个数,把最先遍历到的k个数存入到大小为```k```的数组中,假设它们即是最小的```k```个数;
+2. 对这```k```个数,利用选择或交换排序找到这k个元素中的最大值```kmax```(找最大值需要遍历这```k```个数,时间复杂度为```O(k))```;
+3. 继续遍历剩余```n-k```个数。假设每一次遍历到的新的元素的值为```x```,把```x```与```kmax```比较:如果```x``` < ```kmax``` ,用```x```替换```kmax```,并回到第二步重新找出k个元素的数组中最大元素kmax‘;如果```x >= kmax```,则继续遍历不更新数组。
+每次遍历,更新或不更新数组的所用的时间为```O(k)```或```O(0)```。故整趟下来,时间复杂度为```n*O(k)=O(n*k)```。
+## 解法三
+
+更好的办法是维护容量为k的最大堆,原理跟解法二的方法相似:
+1. 用容量为```k```的最大堆存储最先遍历到的```k```个数,同样假设它们即是最小的```k```个数;
+2. 堆中元素是有序的,令```k1 pivot ){ }
+ if( i < j )
+ swap( &a[ i ], &a[ j ] );
+ else
+ break;
+ }
+ //重置枢纽元
+ swap( &a[ i ], &a[ right - 1 ] );
+
+ if( k <= i )
+ QuickSelect( a, k, left, i - 1 );
+ else if( k > i + 1 )
+ QuickSelect( a, k, i + 1, right );
+ }
+ else
+ InsertSort( a + left, right - left + 1 );
+}
+```
+这个快速选择SELECT算法,类似快速排序的划分方法。N个数存储在数组S中,再从数组中选取“中位数的中位数”作为枢纽元X,把数组划分为Sa和Sb俩部分,Sa<=X<=Sb,如果要查找的k个元素小于Sa的元素个数,则返回Sa中较小的k个元素,否则返回Sa中所有元素+Sb中小的k-|Sa|个元素,这种解法在平均情况下能做到O(n)的复杂度。
+更进一步,《算法导论》第9章第9.3节介绍了一个最坏情况下亦为O(n)时间的SELECT算法,有兴趣的读者可以参看。
+
+给定两个已经排序好的数组,求第k大的,算法有O(m+n).类似merge sort的原理。否则利用的就是之上提到的,利用已经有序的原理,然后每次丢。
+
+之所以这里还有一个丢弃条件是b is None 丢A的一部分,是因为B的数组长度是有限的,这个时候很明显丢A的k/2是不影响的,因为无论B[-1]是如何大或者小,因为整个B的长度没有达到k/2小,所以丢掉的这部分最大的A[k/2-1]也不可能是第k个,因为即使整个B都比A[k/2-1]小,拼起来也不能使A[k/2-1]第k大,所以可以放心丢弃。
+
+
+这里是两个sorted list/array findKth,想到了类似的题目,如果给一个n个linked list,findKth,能想到的办法也只能是用heap吧,类似merge k sorted lists.
+
+
+再写一个O(m+n)类似merge sort的也可以AC的代码
+
+```python
+class Solution(object):
+ def findMedianSortedArrays(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: float
+ """
+ def findKth(A, pa, B, pb, k):
+ res = 0
+ m = 0
+ while pa < len(A) and pb < len(B) and m < k:
+ if A[pa] < B[pb]:
+ res = A[pa]
+ m += 1
+ pa += 1
+ else:
+ res = B[pb]
+ m += 1
+ pb += 1
+
+ while pa < len(A) and m < k:
+ res = A[pa]
+ pa += 1
+ m += 1
+
+
+ while pb < len(B) and m < k:
+ res = B[pb]
+ pb += 1
+ m += 1
+ return res
+
+ n = len(nums1) + len(nums2)
+ if n % 2 == 1:
+ return findKth(nums1,0, nums2,0, n / 2 + 1)
+ else:
+ smaller = findKth(nums1,0, nums2,0, n / 2)
+ bigger = findKth(nums1,0, nums2,0, n / 2 + 1)
+ return (smaller + bigger) / 2.0
+
+```
diff --git a/docs/leetcode/python/005._longest_palindromic_substring.md b/docs/Leetcode_Solutions/005._longest_palindromic_substring.md
similarity index 97%
rename from docs/leetcode/python/005._longest_palindromic_substring.md
rename to docs/Leetcode_Solutions/005._longest_palindromic_substring.md
index f6eb8ef16..14fd335f3 100644
--- a/docs/leetcode/python/005._longest_palindromic_substring.md
+++ b/docs/Leetcode_Solutions/005._longest_palindromic_substring.md
@@ -183,10 +183,10 @@ Manacher算法增加两个辅助变量id和mx,其中id表示最大回文子串
下面,令j = 2*id - i,也就是说j是i关于id的对称点。
- 当 mx - i > P[j] 的时候,以S[j]为中心的回文子串包含在以S[id]为中心的回文子串中,由于i和j对称,以S[i]为中心的回文子串必然包含在以S[id]为中心的回文子串中,所以必有P[i] = P[j];
-
+
- 当 P[j] >= mx - i 的时候,以S[j]为中心的回文子串不一定完全包含于以S[id]为中心的回文子串中,但是基于对称性可知,下图中两个绿框所包围的部分是相同的,也就是说以S[i]为中心的回文子串,其向右至少会扩张到mx的位置,也就是说 P[i] >= mx - i。至于mx之后的部分是否对称,再具体匹配。
-
+
所以P[i] >= Min(P[2 * id - i], mx - i),因为以j为中心的绘回文子串的左边界可能会比mx关于id的对称点要大,此时只能证明P[i]=P[2 * id - i]
- 此外,对于 mx <= i 的情况,因为无法对 P[i]做更多的假设,只能让P[i] = 1,然后再去匹配。
@@ -196,7 +196,7 @@ Manacher算法增加两个辅助变量id和mx,其中id表示最大回文子串
简单地用一个小例子来解释:原字符串为'qacbcaw',一眼就可以看出来最大回文子串是'acbca',
下面是我做的图,累shi了!
-
+
diff --git a/docs/leetcode/python/006._ZigZag_Conversion.md b/docs/Leetcode_Solutions/006._ZigZag_Conversion.md
similarity index 56%
rename from docs/leetcode/python/006._ZigZag_Conversion.md
rename to docs/Leetcode_Solutions/006._ZigZag_Conversion.md
index 6f1f9139e..cc7bcbe33 100644
--- a/docs/leetcode/python/006._ZigZag_Conversion.md
+++ b/docs/Leetcode_Solutions/006._ZigZag_Conversion.md
@@ -1,44 +1,15 @@
-# 6. ZigZag Conversion
-**难度: 中等 **
+### 6. ZigZag Conversion
-## 刷题内容
+题目:
+
-> 原题连接
-* https://leetcode.com/problems/zigzag-conversion/
+难度:
-> 内容描述
+Medium
-```
-The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
-
-P A H N
-A P L S I I G
-Y I R
-And then read line by line: "PAHNAPLSIIGYIR"
-
-Write the code that will take a string and make this conversion given a number of rows:
-
-string convert(string s, int numRows);
-Example 1:
-
-Input: s = "PAYPALISHIRING", numRows = 3
-Output: "PAHNAPLSIIGYIR"
-Example 2:
-
-Input: s = "PAYPALISHIRING", numRows = 4
-Output: "PINALSIGYAHRPI"
-Explanation:
-P I N
-A L S I G
-Y A H R
-P I
-```
-
-## 解题方案
-
-> 思路 1
+思路
参考大神[pharrellyhy](https://leetcode.com/problems/zigzag-conversion/discuss/3404/Python-O(n)-Solution-in-96ms-(99.43)?page=2)的思路,
纵向思维考虑,```index```从```0```开始,我们要一直***自增***直到```numRows-1```,此后又一直***自减***到```0```,重复执行。
@@ -62,17 +33,19 @@ class Solution(object):
"""
if numRows == 1 or numRows >= len(s):
return s
- res = [''] * numRows
- idx, step = 0, 1
-
+
+ L = [''] * numRows
+ index, step = 0, 1
+
for x in s:
- res[idx] += x
- if idx == 0: ## 第一行,一直向下走
+ L[index] += x
+ if index == 0:
step = 1
- elif idx == numRows - 1: ## 最后一行了,向上走
+ elif index == numRows -1:
step = -1
- idx += step
- return ''.join(res)
+ index += step
+
+ return ''.join(L)
```
假设用我上面给的例子,并且在```L[index] += x```这一行后面打印出index, step, L的值, 输出结果如下:
```
diff --git a/docs/Leetcode_Solutions/007._Reverse_Integer.md b/docs/Leetcode_Solutions/007._Reverse_Integer.md
new file mode 100644
index 000000000..f4120c1ea
--- /dev/null
+++ b/docs/Leetcode_Solutions/007._Reverse_Integer.md
@@ -0,0 +1,65 @@
+### 7. Reverse Integer
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+思路
+
+翻转数字问题需要注意的就是溢出问题,为什么会存在溢出问题呢,我们知道int型的数值范围是 -2147483648~2147483647(负的2的31次方~2的31次方-1), 那么如果我们要翻转 1000000009 这个在范围内的数得到 9000000001,而翻转后的数就超过了范围。
+
+#### 解法1:
+如果输入的是负数,就递归调用原函数,参数变成-x即可
+
+
+```python
+class Solution(object):
+ def reverse(self, x):
+ """
+ :type x: int
+ :rtype: int
+ """
+ if x < 0:
+ return -self.reverse(-x)
+ res = 0
+ while x:
+ res = res * 10 + x % 10
+ x /= 10
+ return res if res <= 0x7fffffff else 0
+```
+#### 解法2:
+按照参数正负号先将其转成字符串,然后再反转,根据是否溢出决定输出0还是反转结果
+```python
+class Solution(object):
+ def reverse(self, x):
+ """
+ :type x: int
+ :rtype: int
+ """
+ x = -int(str(x)[::-1][:-1]) if x < 0 else int(str(x)[::-1]) # [:-1]相当于把负号去掉
+ x = 0 if abs(x) > 0x7FFFFFFF else x
+ return x
+```
+#### 解法3(StefanPochmann大神):
+看这个解法前先看[backticks](https://docs.python.org/2.7/reference/expressions.html#string-conversions)
+
+
+cmp函数在python3.x中用不了了,import operator用gt或者lt吧,或者回归if/else condition爸爸的怀抱吧!
+```python
+class Solution(object):
+ def reverse(self, x):
+ """
+ :type x: int
+ :rtype: int
+ """
+ s = cmp(x, 0)
+ r = int(`s * x`[::-1])
+ return s * r * (r < 2 ** 31)
+```
+
+
diff --git a/docs/leetcode/python/008._string_to_integer_(atoi).md b/docs/Leetcode_Solutions/008._string_to_integer_(atoi).md
similarity index 100%
rename from docs/leetcode/python/008._string_to_integer_(atoi).md
rename to docs/Leetcode_Solutions/008._string_to_integer_(atoi).md
diff --git a/docs/Leetcode_Solutions/009._Palindrome_Number.md b/docs/Leetcode_Solutions/009._Palindrome_Number.md
new file mode 100644
index 000000000..8e14084f7
--- /dev/null
+++ b/docs/Leetcode_Solutions/009._Palindrome_Number.md
@@ -0,0 +1,31 @@
+### 9. Palindrome Number
+
+题目:
+
+
+难度:
+Medium
+
+
+- 首先负数肯定不是palindrome
+- 其次如果一个数字是一个正数,并且能被我0整除那它肯定也不是palindrome
+
+这样降低了复杂度
+
+```python
+class Solution(object):
+ def isPalindrome(self, x):
+ """
+ :type x: int
+ :rtype: bool
+ """
+ if x < 0 or (x != 0 and x % 10 == 0):
+ return False
+ rev, y = 0, x
+ while x > 0:
+ rev = rev * 10 + x % 10
+ x /= 10
+ return y == rev
+
+```
+
diff --git a/docs/leetcode/python/010._regular_expression_matching.md b/docs/Leetcode_Solutions/010._regular_expression_matching.md
similarity index 100%
rename from docs/leetcode/python/010._regular_expression_matching.md
rename to docs/Leetcode_Solutions/010._regular_expression_matching.md
diff --git a/docs/leetcode/python/011._container_with_most_water.md b/docs/Leetcode_Solutions/011._container_with_most_water.md
similarity index 100%
rename from docs/leetcode/python/011._container_with_most_water.md
rename to docs/Leetcode_Solutions/011._container_with_most_water.md
diff --git a/docs/leetcode/python/012._Integer_to_Roman.md b/docs/Leetcode_Solutions/012._Integer_to_Roman.md
similarity index 100%
rename from docs/leetcode/python/012._Integer_to_Roman.md
rename to docs/Leetcode_Solutions/012._Integer_to_Roman.md
diff --git a/docs/leetcode/python/013._Roman_to_Integer.md b/docs/Leetcode_Solutions/013._Roman_to_Integer.md
similarity index 100%
rename from docs/leetcode/python/013._Roman_to_Integer.md
rename to docs/Leetcode_Solutions/013._Roman_to_Integer.md
diff --git a/docs/leetcode/python/014._longest_common_prefix.md b/docs/Leetcode_Solutions/014._longest_common_prefix.md
similarity index 100%
rename from docs/leetcode/python/014._longest_common_prefix.md
rename to docs/Leetcode_Solutions/014._longest_common_prefix.md
diff --git a/docs/leetcode/python/015._3sum.md b/docs/Leetcode_Solutions/015._3sum.md
similarity index 96%
rename from docs/leetcode/python/015._3sum.md
rename to docs/Leetcode_Solutions/015._3sum.md
index 26a95fe2f..9f962f9e2 100644
--- a/docs/leetcode/python/015._3sum.md
+++ b/docs/Leetcode_Solutions/015._3sum.md
@@ -1,106 +1,106 @@
-### 15. 3Sum
-
-题目:
-
-
-
-难度:
-
-Medium
-
-
-第一想法,先把nums排序,用三个loop,无法AC
-
-```
-class Solution(object):
- def threeSum(self, nums):
- """
- :type nums: List[int]
- :rtype: List[List[int]]
- """
- n = len(nums)
- res = []
- nums.sort()
- for i in range(n):
- for j in range(i,n):
- for k in range(j,n):
- if nums[i] + nums[j] + nums[k] == 0 and j != i and k != j and k != i:
- curRes = [nums[i],nums[j],nums[k]]
- if curRes not in res:
- res.append(curRes)
-
- return res
-```
-
-
-然后查了一下2sum,用2sum的花样,因为要排除重复以及输出是按照从小到大的输出:但是还是超时
-
-
-```
-class Solution(object): # 此法也超时
- def threeSum(self, nums):
- """
- :type nums: List[int]
- :rtype: List[List[int]]
- """
- def twoSum(nums, target):
- """
- :type nums: List[int]
- :type target: int
- :rtype: List[int]
- """
- lookup = {}
- for num in nums:
- if target - num in lookup:
- if (-target ,target - num, num) not in res:
- res.append((-target ,target - num, num))
- lookup[num] = target - num
-
- n = len(nums)
- nums.sort()
- res = []
- for i in range(n):
- twoSum(nums[i+1:], 0-nums[i])
- return [list(i) for i in res]
-```
-
-
-谷歌看别人的代码,思路非常清晰的,运行起来比直接调用 Two Sum快.
-
-清晰的思路:
-
-- 排序
-- 固定左边,如果左边重复,继续
-- 左右弄边界,去重,针对不同的左右边界情况处理
-
-
-```python
-class Solution(object):
- def threeSum(self, nums):
- """
- :type nums: List[int]
- :rtype: List[List[int]]
- """
- n, res = len(nums), []
- nums.sort()
- for i in range(n):
- if i > 0 and nums[i] == nums[i-1]: # 因为i=0这个元素会直接往下执行
- continue
- l, r = i+1, n-1
- while l < r:
- tmp = nums[i] + nums[l] + nums[r]
- if tmp == 0:
- res.append([nums[i], nums[l], nums[r]])
- l += 1
- r -= 1
- while l < r and nums[l] == nums[l-1]:
- l += 1
- while l < r and nums[r] == nums[r+1]:
- r -= 1
- elif tmp > 0:
- r -= 1
- else:
- l += 1
- return res
-```
-
+### 15. 3Sum
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+第一想法,先把nums排序,用三个loop,无法AC
+
+```
+class Solution(object):
+ def threeSum(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ n = len(nums)
+ res = []
+ nums.sort()
+ for i in range(n):
+ for j in range(i,n):
+ for k in range(j,n):
+ if nums[i] + nums[j] + nums[k] == 0 and j != i and k != j and k != i:
+ curRes = [nums[i],nums[j],nums[k]]
+ if curRes not in res:
+ res.append(curRes)
+
+ return res
+```
+
+
+然后查了一下2sum,用2sum的花样,因为要排除重复以及输出是按照从小到大的输出:但是还是超时
+
+
+```
+class Solution(object): # 此法也超时
+ def threeSum(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ def twoSum(nums, target):
+ """
+ :type nums: List[int]
+ :type target: int
+ :rtype: List[int]
+ """
+ lookup = {}
+ for num in nums:
+ if target - num in lookup:
+ if (-target ,target - num, num) not in res:
+ res.append((-target ,target - num, num))
+ lookup[num] = target - num
+
+ n = len(nums)
+ nums.sort()
+ res = []
+ for i in range(n):
+ twoSum(nums[i+1:], 0-nums[i])
+ return [list(i) for i in res]
+```
+
+
+谷歌看别人的代码,思路非常清晰的,运行起来比直接调用 Two Sum快.
+
+清晰的思路:
+
+- 排序
+- 固定左边,如果左边重复,继续
+- 左右弄边界,去重,针对不同的左右边界情况处理
+
+
+```python
+class Solution(object):
+ def threeSum(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ n, res = len(nums), []
+ nums.sort()
+ for i in range(n):
+ if i > 0 and nums[i] == nums[i-1]: # 因为i=0这个元素会直接往下执行
+ continue
+ l, r = i+1, n-1
+ while l < r:
+ tmp = nums[i] + nums[l] + nums[r]
+ if tmp == 0:
+ res.append([nums[i], nums[l], nums[r]])
+ l += 1
+ r -= 1
+ while l < r and nums[l] == nums[l-1]:
+ l += 1
+ while l < r and nums[r] == nums[r+1]:
+ r -= 1
+ elif tmp > 0:
+ r -= 1
+ else:
+ l += 1
+ return res
+```
+
diff --git a/docs/leetcode/python/016._3sum_closest.md b/docs/Leetcode_Solutions/016._3sum_closest.md
similarity index 100%
rename from docs/leetcode/python/016._3sum_closest.md
rename to docs/Leetcode_Solutions/016._3sum_closest.md
diff --git a/docs/leetcode/python/017._letter_combinations_of_a_phone_number.md b/docs/Leetcode_Solutions/017._letter_combinations_of_a_phone_number.md
similarity index 100%
rename from docs/leetcode/python/017._letter_combinations_of_a_phone_number.md
rename to docs/Leetcode_Solutions/017._letter_combinations_of_a_phone_number.md
diff --git a/docs/leetcode/python/018._4sum.md b/docs/Leetcode_Solutions/018._4sum.md
similarity index 100%
rename from docs/leetcode/python/018._4sum.md
rename to docs/Leetcode_Solutions/018._4sum.md
diff --git a/docs/leetcode/python/019._remove_nth_node_from_end_of_list.md b/docs/Leetcode_Solutions/019._remove_nth_node_from_end_of_list.md
similarity index 95%
rename from docs/leetcode/python/019._remove_nth_node_from_end_of_list.md
rename to docs/Leetcode_Solutions/019._remove_nth_node_from_end_of_list.md
index 5de9f6673..5bdefb7a0 100644
--- a/docs/leetcode/python/019._remove_nth_node_from_end_of_list.md
+++ b/docs/Leetcode_Solutions/019._remove_nth_node_from_end_of_list.md
@@ -1,42 +1,42 @@
-### 19. Remove Nth Node From End of List
-
-题目:
-
-
-
-
-难度: Medium
-
-
-AC击败了95.80%的Python用户,技巧 dummy head 和双指针。
-
-切记最后要返回```dummy.next```而不是```head```,因为有这样一种情况,删掉节点后```linked list```空了,那返回```head```的话结果显然不同。如:
-输入链表为```[1]```, ```n = 1```, 应该返回```None```而不是```[1]```
-
-```python
-class Solution(object):
- def removeNthFromEnd(self, head, n):
- """
- :type head: ListNode
- :type n: int
- :rtype: ListNode
- """
- dummy = ListNode(-1)
- dummy.next = head
- p, q = dummy, dummy
-
- for i in range(n):
- q = q.next
-
- while q.next:
- p = p.next
- q = q.next
-
- p.next = p.next.next
- return dummy.next
-
-```
-
-
-
-
+### 19. Remove Nth Node From End of List
+
+题目:
+
+
+
+
+难度: Medium
+
+
+AC击败了95.80%的Python用户,技巧 dummy head 和双指针。
+
+切记最后要返回```dummy.next```而不是```head```,因为有这样一种情况,删掉节点后```linked list```空了,那返回```head```的话结果显然不同。如:
+输入链表为```[1]```, ```n = 1```, 应该返回```None```而不是```[1]```
+
+```python
+class Solution(object):
+ def removeNthFromEnd(self, head, n):
+ """
+ :type head: ListNode
+ :type n: int
+ :rtype: ListNode
+ """
+ dummy = ListNode(-1)
+ dummy.next = head
+ p, q = dummy, dummy
+
+ for i in range(n):
+ q = q.next
+
+ while q.next:
+ p = p.next
+ q = q.next
+
+ p.next = p.next.next
+ return dummy.next
+
+```
+
+
+
+
diff --git a/docs/Leetcode_Solutions/020._valid_parentheses.md b/docs/Leetcode_Solutions/020._valid_parentheses.md
new file mode 100644
index 000000000..3b008ac91
--- /dev/null
+++ b/docs/Leetcode_Solutions/020._valid_parentheses.md
@@ -0,0 +1,52 @@
+### 20. Valid Parentheses
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+### 思路:
+
+因为一共只有三种状况"(" -> ")", "[" -> "]", "{" -> "}".
+
+一遇到左括号就入栈,右括号出栈,这样来寻找对应
+
+需要检查几件事:
+
+- 出现右括号时stack里还有没有东西
+- 出stack时是否对应
+- 最终stack是否为空
+
+
+
+```python
+class Solution(object):
+ def isValid(self, s):
+ """
+ :type s: str
+ :rtype: bool
+ """
+ leftP = '([{'
+ rightP = ')]}'
+ stack = []
+ for char in s:
+ if char in leftP:
+ stack.append(char)
+ if char in rightP:
+ if not stack:
+ return False
+ tmp = stack.pop()
+ if char == ')' and tmp != '(':
+ return False
+ if char == ']' and tmp != '[':
+ return False
+ if char == '}' and tmp != '{':
+ return False
+ return stack == []
+```
+
diff --git a/docs/leetcode/python/021._merge_two_sorted_lists.md b/docs/Leetcode_Solutions/021._merge_two_sorted_lists.md
similarity index 94%
rename from docs/leetcode/python/021._merge_two_sorted_lists.md
rename to docs/Leetcode_Solutions/021._merge_two_sorted_lists.md
index 1122f7df9..40517726c 100644
--- a/docs/leetcode/python/021._merge_two_sorted_lists.md
+++ b/docs/Leetcode_Solutions/021._merge_two_sorted_lists.md
@@ -1,48 +1,48 @@
-### 21. Merge Two Sorted Lists
-
-题目:
-
-
-
-
-难度: Easy
-
-
-同样适用dummy head
-
-```python
-class Solution(object):
- def mergeTwoLists(self, l1, l2):
- """
- :type l1: ListNode
- :type l2: ListNode
- :rtype: ListNode
- """
- if l1 == None:
- return l2
- if l2 == None:
- return l1
-
- dummy = ListNode(-1)
- cur = dummy
-
- while l1 and l2:
- if l1.val < l2.val:
- cur.next = l1
- l1 = l1.next
- else:
- cur.next = l2
- l2 = l2.next
- cur = cur.next
-
- if l1:
- cur.next = l1
- else:
- cur.next = l2
- return dummy.next
-
-```
-
-
-
-
+### 21. Merge Two Sorted Lists
+
+题目:
+
+
+
+
+难度: Easy
+
+
+同样适用dummy head
+
+```python
+class Solution(object):
+ def mergeTwoLists(self, l1, l2):
+ """
+ :type l1: ListNode
+ :type l2: ListNode
+ :rtype: ListNode
+ """
+ if l1 == None:
+ return l2
+ if l2 == None:
+ return l1
+
+ dummy = ListNode(-1)
+ cur = dummy
+
+ while l1 and l2:
+ if l1.val < l2.val:
+ cur.next = l1
+ l1 = l1.next
+ else:
+ cur.next = l2
+ l2 = l2.next
+ cur = cur.next
+
+ if l1:
+ cur.next = l1
+ else:
+ cur.next = l2
+ return dummy.next
+
+```
+
+
+
+
diff --git a/docs/leetcode/python/022._generate_parentheses.md b/docs/Leetcode_Solutions/022._generate_parentheses.md
similarity index 97%
rename from docs/leetcode/python/022._generate_parentheses.md
rename to docs/Leetcode_Solutions/022._generate_parentheses.md
index 06282a26e..ae14c9089 100644
--- a/docs/leetcode/python/022._generate_parentheses.md
+++ b/docs/Leetcode_Solutions/022._generate_parentheses.md
@@ -1,88 +1,88 @@
-### 22. Generate Parentheses
-
-题目:
-
-
-
-难度:
-
-Medium
-
-
-
-
-
-```python
-class Solution(object):
- def generateParenthesis(self,n):
- """
- :type n: int
- :rtype: List[str]
- """
- self.res = []
- self.singleStr('', 0, 0, n)
- return self.res
-
- def singleStr(self, s, left, right, n):
- if left == n and right == n:
- self.res.append(s)
- if left < n:
- self.singleStr(s + '(',left + 1, right,n)
- if right < left:
- self.singleStr(s + ')',left, right + 1, n)
-
-```
-
-
-非常牛逼的讲解,需要这样的人来给我们讲算法
-
-####以Generate Parentheses为例,backtrack的题到底该怎么去思考?
-
-
-所谓Backtracking都是这样的思路:在当前局面下,你有若干种选择。那么尝试每一种选择。如果已经发现某种选择肯定不行(因为违反了某些限定条件),就返回;如果某种选择试到最后发现是正确解,就将其加入解集
-
-所以你思考递归题时,只要明确三点就行:选择 (Options),限制 (Restraints),结束条件 (Termination)。即“ORT原则”(这个是我自己编的)
-
-
-
-
-对于这道题,在任何时刻,你都有两种选择:
-1. 加左括号。
-2. 加右括号。
-
-同时有以下限制:
-1. 如果左括号已经用完了,则不能再加左括号了。
-2. 如果已经出现的右括号和左括号一样多,则不能再加右括号了。因为那样的话新加入的右括号一定无法匹配。
-
-结束条件是:
-左右括号都已经用完。
-
-结束后的正确性:
-左右括号用完以后,一定是正确解。因为1. 左右括号一样多,2. 每个右括号都一定有与之配对的左括号。因此一旦结束就可以加入解集(有时也可能出现结束以后不一定是正确解的情况,这时要多一步判断)。
-
-递归函数传入参数:
-限制和结束条件中有“用完”和“一样多”字样,因此你需要知道左右括号的数目。
-当然你还需要知道当前局面sublist和解集res。
-
-因此,把上面的思路拼起来就是代码:
-
- if (左右括号都已用完) {
- 加入解集,返回
- }
- //否则开始试各种选择
- if (还有左括号可以用) {
- 加一个左括号,继续递归
- }
- if (右括号小于左括号) {
- 加一个右括号,继续递归
- }
-
-
-
-你帖的那段代码逻辑中加了一条限制:“3. 是否还有右括号剩余。如有才加右括号”。这是合理的。不过对于这道题,如果满足限制1、2时,3一定自动满足,所以可以不判断3。
-
-这题其实是最好的backtracking初学练习之一,因为ORT三者都非常简单明显。你不妨按上述思路再梳理一遍,还有问题的话再说。
-
-
-
-以上文字来自 1point3arces的牛人解答
+### 22. Generate Parentheses
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+
+
+
+```python
+class Solution(object):
+ def generateParenthesis(self,n):
+ """
+ :type n: int
+ :rtype: List[str]
+ """
+ self.res = []
+ self.singleStr('', 0, 0, n)
+ return self.res
+
+ def singleStr(self, s, left, right, n):
+ if left == n and right == n:
+ self.res.append(s)
+ if left < n:
+ self.singleStr(s + '(',left + 1, right,n)
+ if right < left:
+ self.singleStr(s + ')',left, right + 1, n)
+
+```
+
+
+非常牛逼的讲解,需要这样的人来给我们讲算法
+
+####以Generate Parentheses为例,backtrack的题到底该怎么去思考?
+
+
+所谓Backtracking都是这样的思路:在当前局面下,你有若干种选择。那么尝试每一种选择。如果已经发现某种选择肯定不行(因为违反了某些限定条件),就返回;如果某种选择试到最后发现是正确解,就将其加入解集
+
+所以你思考递归题时,只要明确三点就行:选择 (Options),限制 (Restraints),结束条件 (Termination)。即“ORT原则”(这个是我自己编的)
+
+
+
+
+对于这道题,在任何时刻,你都有两种选择:
+1. 加左括号。
+2. 加右括号。
+
+同时有以下限制:
+1. 如果左括号已经用完了,则不能再加左括号了。
+2. 如果已经出现的右括号和左括号一样多,则不能再加右括号了。因为那样的话新加入的右括号一定无法匹配。
+
+结束条件是:
+左右括号都已经用完。
+
+结束后的正确性:
+左右括号用完以后,一定是正确解。因为1. 左右括号一样多,2. 每个右括号都一定有与之配对的左括号。因此一旦结束就可以加入解集(有时也可能出现结束以后不一定是正确解的情况,这时要多一步判断)。
+
+递归函数传入参数:
+限制和结束条件中有“用完”和“一样多”字样,因此你需要知道左右括号的数目。
+当然你还需要知道当前局面sublist和解集res。
+
+因此,把上面的思路拼起来就是代码:
+
+ if (左右括号都已用完) {
+ 加入解集,返回
+ }
+ //否则开始试各种选择
+ if (还有左括号可以用) {
+ 加一个左括号,继续递归
+ }
+ if (右括号小于左括号) {
+ 加一个右括号,继续递归
+ }
+
+
+
+你帖的那段代码逻辑中加了一条限制:“3. 是否还有右括号剩余。如有才加右括号”。这是合理的。不过对于这道题,如果满足限制1、2时,3一定自动满足,所以可以不判断3。
+
+这题其实是最好的backtracking初学练习之一,因为ORT三者都非常简单明显。你不妨按上述思路再梳理一遍,还有问题的话再说。
+
+
+
+以上文字来自 1point3arces的牛人解答
diff --git a/docs/leetcode/python/023._merge_k_sorted_lists.md b/docs/Leetcode_Solutions/023._merge_k_sorted_lists.md
similarity index 100%
rename from docs/leetcode/python/023._merge_k_sorted_lists.md
rename to docs/Leetcode_Solutions/023._merge_k_sorted_lists.md
diff --git a/docs/Leetcode_Solutions/024._swap_nodes_in_pairs.md b/docs/Leetcode_Solutions/024._swap_nodes_in_pairs.md
new file mode 100644
index 000000000..907744af1
--- /dev/null
+++ b/docs/Leetcode_Solutions/024._swap_nodes_in_pairs.md
@@ -0,0 +1,35 @@
+###24. Swap Nodes in Pairs
+
+题目:
+
+
+
+难度 : Easy
+
+看了hint,用loop做,每个node关系要弄清楚
+
+
+```
+
+class Solution(object):
+ def swapPairs(self, head):
+ """
+ :type head: ListNode
+ :rtype: ListNode
+ """
+ if head == None or head.next == None:
+ return head
+
+ dummy = ListNode(-1)
+ dummy.next = head
+
+ cur = dummy
+
+ while cur.next and cur.next.next:
+ next_one, next_two, next_three = cur.next, cur.next.next, cur.next.next.next
+ cur.next = next_two
+ next_two.next = next_one
+ next_one.next = next_three
+ cur = next_one
+ return dummy.next
+```
\ No newline at end of file
diff --git a/docs/Leetcode_Solutions/026._Remove_Duplicates_from_Sorted_Array.md b/docs/Leetcode_Solutions/026._Remove_Duplicates_from_Sorted_Array.md
new file mode 100644
index 000000000..23b43561c
--- /dev/null
+++ b/docs/Leetcode_Solutions/026._Remove_Duplicates_from_Sorted_Array.md
@@ -0,0 +1,73 @@
+### 26. Remove Duplicates from Sorted Array
+
+
+
+题目:
+
+
+
+难度:
+Easy
+
+思路:
+因为题目说了是```sorted array```,所以只需要不停判断当前位置值和下一位置是否相等,若相等则```pop掉当前值```,否则```move```到下一位置做重复判断
+
+
+```python
+class Solution(object):
+ def removeDuplicates(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ i = 0
+ while i < (len(nums) - 1):
+ if nums[i] == nums[i+1]:
+ nums.remove(nums[i])
+ else:
+ i += 1
+ return len(nums)
+```
+
+
+这里代码用```while loop```而不用```for loop```是因为```pop```操作之后```nums```的长度会变化
+
+如:```for i in range(len(nums)-1)```实际上固定了```range```里面的值了,不会二次判断
+
+```
+n = 10
+for i in range(n):
+ n = n - 1 # 尽管n在变化
+ print(i)
+
+上面这段代码的输出结果为:
+
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/Leetcode_Solutions/027._Remove_Element.md b/docs/Leetcode_Solutions/027._Remove_Element.md
new file mode 100644
index 000000000..3603a5b3d
--- /dev/null
+++ b/docs/Leetcode_Solutions/027._Remove_Element.md
@@ -0,0 +1,25 @@
+### 27. Remove Element
+
+
+
+题目:
+
+
+
+难度:
+Easy
+
+瞬秒
+
+```python
+class Solution(object):
+ def removeElement(self, nums, val):
+ """
+ :type nums: List[int]
+ :type val: int
+ :rtype: int
+ """
+ while val in nums:
+ nums.remove(val)
+ return len(nums)
+```
diff --git a/docs/leetcode/python/028._implement_strstr.md b/docs/Leetcode_Solutions/028._implement_strstr().md
similarity index 100%
rename from docs/leetcode/python/028._implement_strstr.md
rename to docs/Leetcode_Solutions/028._implement_strstr().md
diff --git a/docs/leetcode/python/030._Substring_with_Concatenation_of_All_Words.md b/docs/Leetcode_Solutions/030._Substring_with_Concatenation_of_All_Words.md
similarity index 98%
rename from docs/leetcode/python/030._Substring_with_Concatenation_of_All_Words.md
rename to docs/Leetcode_Solutions/030._Substring_with_Concatenation_of_All_Words.md
index 24d5c0849..0dd9eea26 100644
--- a/docs/leetcode/python/030._Substring_with_Concatenation_of_All_Words.md
+++ b/docs/Leetcode_Solutions/030._Substring_with_Concatenation_of_All_Words.md
@@ -1,7 +1,7 @@
### 30. Substring with Concatenation of All Words
题目:
-
+
难度 : Hard
diff --git a/docs/leetcode/python/031._next_permutation.md b/docs/Leetcode_Solutions/031._next_permutation.md
similarity index 100%
rename from docs/leetcode/python/031._next_permutation.md
rename to docs/Leetcode_Solutions/031._next_permutation.md
diff --git a/docs/leetcode/python/033._search_in_rotated_sorted_array.md b/docs/Leetcode_Solutions/033._search_in_rotated_sorted_array.md
similarity index 91%
rename from docs/leetcode/python/033._search_in_rotated_sorted_array.md
rename to docs/Leetcode_Solutions/033._search_in_rotated_sorted_array.md
index 0da34a59f..c2e6eb74c 100644
--- a/docs/leetcode/python/033._search_in_rotated_sorted_array.md
+++ b/docs/Leetcode_Solutions/033._search_in_rotated_sorted_array.md
@@ -14,7 +14,7 @@ Medium
下面是rotated-array图解,
-
+
所以直接用二分,O(lg(n))
diff --git a/docs/leetcode/python/034._Search_for_a_Range.md b/docs/Leetcode_Solutions/034._Search for a Range.md
similarity index 100%
rename from docs/leetcode/python/034._Search_for_a_Range.md
rename to docs/Leetcode_Solutions/034._Search for a Range.md
diff --git a/docs/Leetcode_Solutions/035._search_insert_position.md b/docs/Leetcode_Solutions/035._search_insert_position.md
new file mode 100644
index 000000000..1b14c88ce
--- /dev/null
+++ b/docs/Leetcode_Solutions/035._search_insert_position.md
@@ -0,0 +1,48 @@
+### 35. Search Insert Position
+
+题目:
+
+
+
+难度:
+
+Medium
+
+找到第一个比```target```大的值的```index```,如果没找到则返回```len(nums)```,但是代码中直接返回```i```值就行了
+
+### 思路一:暴力
+
+```python
+class Solution(object):
+ def searchInsert(self, nums, target):
+ """
+ :type nums: List[int]
+ :type target: int
+ :rtype: int
+ """
+ i = 0
+ while nums[i] < target:
+ i += 1
+ if i == len(nums):
+ return i
+ return i
+```
+### 思路二:二分
+
+```python
+class Solution(object):
+ def searchInsert(self, nums, target):
+ """
+ :type nums: List[int]
+ :type target: int
+ :rtype: int
+ """
+ left, right = 0, len(nums) - 1
+ while left <= right:
+ mid = left + ((right - left) >> 2)
+ if nums[mid] < target:
+ left = mid + 1
+ else:
+ right = mid - 1
+ return left
+```
diff --git a/docs/leetcode/python/038._Count_and_Say.md b/docs/Leetcode_Solutions/038._Count_and_Say.md
similarity index 100%
rename from docs/leetcode/python/038._Count_and_Say.md
rename to docs/Leetcode_Solutions/038._Count_and_Say.md
diff --git a/docs/leetcode/python/039._combination_sum.md b/docs/Leetcode_Solutions/039._combination_sum.md
similarity index 100%
rename from docs/leetcode/python/039._combination_sum.md
rename to docs/Leetcode_Solutions/039._combination_sum.md
diff --git a/docs/leetcode/python/040._combination_sum_ii.md b/docs/Leetcode_Solutions/040._combination_sum_ii.md
similarity index 100%
rename from docs/leetcode/python/040._combination_sum_ii.md
rename to docs/Leetcode_Solutions/040._combination_sum_ii.md
diff --git a/docs/leetcode/python/042._trapping_rain_water.md b/docs/Leetcode_Solutions/042._trapping_rain_water.md
similarity index 100%
rename from docs/leetcode/python/042._trapping_rain_water.md
rename to docs/Leetcode_Solutions/042._trapping_rain_water.md
diff --git a/docs/Leetcode_Solutions/043._multiply_strings.md b/docs/Leetcode_Solutions/043._multiply_strings.md
new file mode 100644
index 000000000..461c8ee91
--- /dev/null
+++ b/docs/Leetcode_Solutions/043._multiply_strings.md
@@ -0,0 +1,81 @@
+###43. Multiply Strings
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+思路:
+
+虽然写了一堆similar problems,拿到的时候也算有思路,但是还是觉得很难写
+
+参考了别人的思路:
+
+1. m位的数字乘以n位的数字的结果最大为m+n位:
+999*99 < 1000*100 = 100000,最多为3+2 = 5位数。
+2. 先将字符串逆序便于从最低位开始计算。
+
+
+觉得这样写才是最容易理解的,看一个具体的🌰:
+
+```
+123 * 456
+
+ 123
+ * 456
+
+
+先把每一位拿来相乘:得到
+ 1 2 3
+ 4 5 6
+
+ 6 12 18
+ 5 10 15
+ 4 8 12
+
+这样在全部加起来和做进位处理
+ 5 6 0 8 8
+
+
+```
+
+
+
+
+```
+class Solution(object):
+ def multiply(self, num1, num2):
+ """
+ :type num1: str
+ :type num2: str
+ :rtype: str
+ """
+ if num1 == '0' or num2 == '0' : return '0'
+ len1,len2 = len(num1),len(num2)
+
+ num1 = num1[::-1]
+ num2 = num2[::-1]
+ # 99 * 99 < 10000, maxmize 4 digit
+ arr = [0 for i in range(len1 + len2)]
+
+ for i in xrange(len1):
+ for j in xrange(len2):
+ arr[i+j] += (ord(num1[i]) - ord('0')) * (ord(num2[j]) - ord('0'))
+
+
+ res = [0 for i in range(len1 + len2)]
+
+ for i in range(len(arr)):
+ res[i] = arr[i] % 10
+ if i < len(arr) - 1:
+ arr[i+1] += arr[i]/10
+
+ i = len(arr)-1
+ if res[i] == 0:
+ i -= 1
+ return ''.join(str(j) for j in res[:i+1][::-1])
+```
diff --git a/docs/leetcode/python/044._wildcard_matching.md b/docs/Leetcode_Solutions/044._wildcard_matching.md
similarity index 100%
rename from docs/leetcode/python/044._wildcard_matching.md
rename to docs/Leetcode_Solutions/044._wildcard_matching.md
diff --git a/docs/leetcode/python/045._Jump_Game_II.md b/docs/Leetcode_Solutions/045._Jump_Game_II.md
similarity index 100%
rename from docs/leetcode/python/045._Jump_Game_II.md
rename to docs/Leetcode_Solutions/045._Jump_Game_II.md
diff --git a/docs/Leetcode_Solutions/046._permutations.md b/docs/Leetcode_Solutions/046._permutations.md
new file mode 100644
index 000000000..a79e7c67c
--- /dev/null
+++ b/docs/Leetcode_Solutions/046._permutations.md
@@ -0,0 +1,138 @@
+###46. Permutations
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+复习了一下,自己写的容易理解版本:
+
+每次调一个放入现有
+
+```
+class Solution(object):
+ def permute(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ self.result = []
+ self.recPermute([],nums)
+ return self.result
+
+ def recPermute(self, sofar, rest):
+ if rest == []:
+ self.result.append(sofar)
+ else:
+ for i in range(len(rest)):
+ next = sofar + [rest[i]]
+ remaining = rest[:i] + rest[i+1:]
+ self.recPermute(next, remaining)
+```
+
+交换
+
+
+
+```
+class Solution(object):
+ def permute(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ result = []
+ self.helper(nums,0,result)
+ return result
+
+ def helper(self,nums,begin,result):
+ n = len(nums)
+ if begin == n:
+ tmp = nums[:]
+ result.append(tmp)
+ return
+
+ for i in range(begin,n):
+ nums[begin], nums[i] = nums[i],nums[begin]
+ self.helper(nums,begin+1,result)
+ nums[begin],nums[i] = nums[i],nums[begin]
+
+```
+
+
+
+
+
+
+好像还有一个巧妙的版本
+
+
+```
+class Solution:
+ # @param num, a list of integer
+ # @return a list of lists of integers
+ def permute(self, num):
+ if len(num) == 0: return []
+ if len(num) == 1: return [num]
+ res = []
+ for i in range(len(num)):
+ for j in self.permute(num[:i] + num[i+1:]):
+ res.append([num[i]] + j)
+ return res
+```
+
+
+更容易理解的写法:
+
+
+```
+class Solution:
+ # @param num, a list of integer
+ # @return a list of lists of integers
+ def permute(self, num):
+ if len(num) == 0: return []
+ if len(num) == 1: return [num]
+ res = []
+ for i in range(len(num)):
+ x = num[i]
+ xs = num[:i] + num[i+1:]
+ for j in self.permute(xs):
+ res.append([x] + j)
+ return res
+
+```
+
+就是一定要有递归的信念❤️
+
+
+
+还有介绍的基本无memory使用的算法:
+
+
+```
+class Solution:
+ # @param num, a list of integer
+ # @return a list of lists of integers
+ def permute(self, num):
+ if len(num) == 0: yield []
+ if len(num) == 1: yield [num]
+ res = []
+ for i in range(len(num)):
+ x = num[i]
+ xs = num[:i] + num[i+1:]
+ for j in self.permute(xs):
+ res.append([x] + j)
+ yield res
+
+```
+
+但是这个yield只是生产generator,要看结果还是要用for in的。
+
+
+
+
+
diff --git a/docs/Leetcode_Solutions/047._permutations_ii.md b/docs/Leetcode_Solutions/047._permutations_ii.md
new file mode 100644
index 000000000..68a3ead84
--- /dev/null
+++ b/docs/Leetcode_Solutions/047._permutations_ii.md
@@ -0,0 +1,42 @@
+###47. Permutations II
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+虽然想到了,但是没有靠自己的力量implement出来,还是比较容易了理解的,因为如果有重复的,那么处理只用处理第一个,就只用把第一个提出来,剩下的管它怎么permute。
+
+第二次碰到这个元素就不要再用它了,因为可能出现的组合已经有了。
+
+
+看代码:
+base case 处理掉
+sort一下,设置一个prevNum变量
+
+如果碰到过了,就continue,去继续执行下一个
+
+
+```
+class Solution(object):
+ def permuteUnique(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ if len(nums) == 0: return []
+ if len(nums) == 1: return [nums]
+ res = []
+ nums.sort()
+ for i in range(len(nums)):
+ if i > 0 and nums[i] == nums[i-1]: continue
+ for j in self.permuteUnique(nums[:i] + nums[i+1:]):
+ res.append([nums[i]] + j)
+ return res
+```
+
+
diff --git a/docs/Leetcode_Solutions/048._rotate_image.md b/docs/Leetcode_Solutions/048._rotate_image.md
new file mode 100644
index 000000000..bff771bbb
--- /dev/null
+++ b/docs/Leetcode_Solutions/048._rotate_image.md
@@ -0,0 +1,118 @@
+###48. Rotate Image
+
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+
+思路一:
+
+```
+rotate之前: 之后:
+ 1 2 3 4 13 9 5 1
+ 5 6 7 8 14 10 6 2
+ 9 10 11 12 15 11 7 3
+ 13 14 15 16 16 12 8 4
+
+```
+看网上的hint,是先沿着对角线变换一次,再验证水平中线变换一次
+
+
+```
+16 12 8 4 13 9 5 1
+15 11 7 3 14 10 6 2
+14 10 6 2 15 11 7 3
+13 9 5 1 16 12 8 4
+```
+
+对角线变换的规律是
+(i,j), (n-1-j,n-1-i)
+
+上下变换规律
+(i,j),(n-1-i,j)
+
+
+```
+class Solution(object):
+ def rotate(self, matrix):
+ """
+ :type matrix: List[List[int]]
+ :rtype: void Do not return anything, modify matrix in-place instead.
+ """
+ n = len(matrix)
+ for i in range(n):
+ for j in range(n):
+ if j < n-1-i:
+ matrix[i][j],matrix[n-1-j][n-1-i] = matrix[n-1-j][n-1-i],matrix[i][j]
+
+ for i in range(n/2):
+ for j in range(n):
+ matrix[i][j],matrix[n-1-i][j] = matrix[n-1-i][j],matrix[i][j]
+
+
+```
+
+
+思路二:
+
+参考这里
+
+
+
+找规律,一次完成四个数的该有的变换
+
+```
+
+1 2 3 4 5
+
+6 7 8 9 10
+
+11 12 13 14 15
+
+16 17 18 19 20
+
+21 22 23 24 25
+
+```
+
+观察一下,第一个数开始的变换是 (0,0)->(0,4)->(4,4)->(4,0)
+第二个数的变换是 (0,1)->(1,4)->(4,3)->(3,0)
+
+变换是 (x,y) -> (y, n-1-x) -> (n-1-x,n-1-y)->(n-1-y,x)
+
+然后处理第一行是从(0,0)->(0,n-2),第二列是(1,1)->(1,n-3).
+
+第i行(i, i)(i, n – 2 – i).终止条件也有了。
+
+虽然都是O(N^2),但是这个比上面的稍快
+
+```
+class Solution(object):
+ def rotate(self, matrix):
+ """
+ :type matrix: List[List[int]]
+ :rtype: void Do not return anything, modify matrix in-place instead.
+ """
+ n = len(matrix)
+
+ # row, col
+ for i in range(n):
+ for j in range(i,n-1-i):
+ matrix[i][j],matrix[j][n-1-i],matrix[n-1-i][n-1-j],matrix[n-1-j][i] = \
+ matrix[n-1-j][i],matrix[i][j],matrix[j][n-1-i],matrix[n-1-i][n-1-j]
+```
+
+
+这里的问题是矩阵都是方形,如果不是方形,貌似难很多。
+
+
+
+
+
+
diff --git a/docs/leetcode/python/049._group_anagrams_python.md b/docs/Leetcode_Solutions/049._group_anagrams_python.md
similarity index 100%
rename from docs/leetcode/python/049._group_anagrams_python.md
rename to docs/Leetcode_Solutions/049._group_anagrams_python.md
diff --git a/docs/leetcode/python/050._pow(x,_n).md b/docs/Leetcode_Solutions/050._pow(x,_n).md
similarity index 100%
rename from docs/leetcode/python/050._pow(x,_n).md
rename to docs/Leetcode_Solutions/050._pow(x,_n).md
diff --git a/docs/leetcode/python/051._n-queens.md b/docs/Leetcode_Solutions/051._n-queens.md
similarity index 100%
rename from docs/leetcode/python/051._n-queens.md
rename to docs/Leetcode_Solutions/051._n-queens.md
diff --git a/docs/leetcode/python/052._n-queens_ii.md b/docs/Leetcode_Solutions/052._n-queens_ii.md
similarity index 100%
rename from docs/leetcode/python/052._n-queens_ii.md
rename to docs/Leetcode_Solutions/052._n-queens_ii.md
diff --git a/docs/leetcode/python/053._maximum_subarray.md b/docs/Leetcode_Solutions/053._maximum_subarray.md
similarity index 73%
rename from docs/leetcode/python/053._maximum_subarray.md
rename to docs/Leetcode_Solutions/053._maximum_subarray.md
index 5cfbacf7f..e71c549d1 100644
--- a/docs/leetcode/python/053._maximum_subarray.md
+++ b/docs/Leetcode_Solutions/053._maximum_subarray.md
@@ -1,33 +1,14 @@
-# 53. Maximum Subarray 最大子序和
+### 53. Maximum Subarray
-**难度: Medium **
+题目:
+
-## 刷题内容
-> 原题连接
+难度:
+Medium
-* https://leetcode.com/problems/maximum-subarray
-* https://leetcode-cn.com/problems/maximum-subarray
-> 内容描述
-
-```
-给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
-
-示例:
-
-输入: [-2,1,-3,4,-1,2,1,-5,4],
-输出: 6
-解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。
-
-进阶:
-
-如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。
-```
-
-## 解题方案
-
-> 思路 1
+思路一:
O(N^2)
@@ -50,11 +31,13 @@ class Solution(object):
return m
```
-> 思路 2
+思路二:
-* 动态规划(只关注:当然值 和 当前值+过去的状态,是变好还是变坏,一定是回看容易理解)
-* ms(i) = max(ms[i-1]+ a[i],a[i])
-* 到i处的最大值两个可能,一个是加上a[i], 另一个从a[i]起头,重新开始。可以AC
+动归
+
+ms(i) = max(ms[i-1]+ a[i],a[i])
+
+到i处的最大值两个可能,一个是加上a[i],另一个从a[i]起头,重新开始。可以AC
```python
class Solution(object):
@@ -70,7 +53,9 @@ class Solution(object):
return max(maxSum)
```
-> 思路 3
+
+思路三:
+
Kadane’s Algorithm wikipedia可以查到,然后一般的是负的可以还回0,这里需要稍作修改,参考
@@ -108,10 +93,14 @@ class Solution(object):
return maxSum
```
-> 思路 4
+
+思路四:
+
+
参见clrs 第71页,用divide and conquer,有伪码
+
最大的subarray sum有三个可能,左半段或者右半段,或者跨越左右半段,
速度比较慢,AC代码,复杂度O(NlogN)
@@ -153,4 +142,5 @@ class Solution(object):
return max(left_sum, right_sum, cross_sum)
return find_max_subarray(nums, 0, len(nums)-1)
+
```
diff --git a/docs/leetcode/python/054._spiral_matrix.md b/docs/Leetcode_Solutions/054._spiral_matrix.md
similarity index 100%
rename from docs/leetcode/python/054._spiral_matrix.md
rename to docs/Leetcode_Solutions/054._spiral_matrix.md
diff --git a/docs/leetcode/python/055._jump_game.md b/docs/Leetcode_Solutions/055._jump_game.md
similarity index 100%
rename from docs/leetcode/python/055._jump_game.md
rename to docs/Leetcode_Solutions/055._jump_game.md
diff --git a/docs/leetcode/python/056._Merge_Intervals.md b/docs/Leetcode_Solutions/056._Merge_Intervals.md
similarity index 100%
rename from docs/leetcode/python/056._Merge_Intervals.md
rename to docs/Leetcode_Solutions/056._Merge_Intervals.md
diff --git a/docs/leetcode/python/058._length_of_last_word.md b/docs/Leetcode_Solutions/058._length_of_last_word.md
similarity index 100%
rename from docs/leetcode/python/058._length_of_last_word.md
rename to docs/Leetcode_Solutions/058._length_of_last_word.md
diff --git a/docs/leetcode/python/059._spiral_matrix_ii.md b/docs/Leetcode_Solutions/059._spiral_matrix_ii.md
similarity index 100%
rename from docs/leetcode/python/059._spiral_matrix_ii.md
rename to docs/Leetcode_Solutions/059._spiral_matrix_ii.md
diff --git a/docs/leetcode/python/060._permutation_sequence.md b/docs/Leetcode_Solutions/060._permutation_sequence.md
similarity index 100%
rename from docs/leetcode/python/060._permutation_sequence.md
rename to docs/Leetcode_Solutions/060._permutation_sequence.md
diff --git a/docs/leetcode/python/061._rotate_list.md b/docs/Leetcode_Solutions/061._rotate_list.md
similarity index 100%
rename from docs/leetcode/python/061._rotate_list.md
rename to docs/Leetcode_Solutions/061._rotate_list.md
diff --git a/docs/Leetcode_Solutions/064._minimum_path_sum.md b/docs/Leetcode_Solutions/064._minimum_path_sum.md
new file mode 100644
index 000000000..591c171b5
--- /dev/null
+++ b/docs/Leetcode_Solutions/064._minimum_path_sum.md
@@ -0,0 +1,58 @@
+
+###64. Minimum Path Sum
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+
+非常明显的DP
+
+状态转移方程
+
+dp[i][j] = gird[i][j] + min(dp[i-1][j], dp[i][j-1])
+
+
+然后注意一下边界的处理,一开始dp[0][0] = grid[0][0]
+
+第一行和第一列,之后开始全用状态转移方程
+
+
+```
+class Solution(object):
+ def minPathSum(self, grid):
+ """
+ :type grid: List[List[int]]
+ :rtype: int
+ """
+ m = len(grid)
+ n = len(grid[0]) if m else 0
+
+ dp = [[0 for i in range(n)] for i in range(m)]
+
+ dp[0][0] = grid[0][0]
+
+ # first row
+ for i in range(1,n):
+ dp[0][i] = grid[0][i] + dp[0][i-1]
+
+ # first col
+ for i in range(1,m):
+ dp[i][0] = grid[i][0] + dp[i-1][0]
+
+
+ for i in range(1,m):
+ for j in range(1,n):
+ dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1])
+
+
+ return dp[m-1][n-1]
+
+
+
+```
diff --git a/docs/leetcode/python/065.unique_paths_ii.md b/docs/Leetcode_Solutions/065.unique_paths_ii.md
similarity index 100%
rename from docs/leetcode/python/065.unique_paths_ii.md
rename to docs/Leetcode_Solutions/065.unique_paths_ii.md
diff --git a/docs/leetcode/python/066._plus_one.md b/docs/Leetcode_Solutions/066._plus_one.md
similarity index 100%
rename from docs/leetcode/python/066._plus_one.md
rename to docs/Leetcode_Solutions/066._plus_one.md
diff --git a/docs/leetcode/python/067._add_binary.md b/docs/Leetcode_Solutions/067._add_binary.md
similarity index 100%
rename from docs/leetcode/python/067._add_binary.md
rename to docs/Leetcode_Solutions/067._add_binary.md
diff --git a/docs/leetcode/python/069._sqrt(x).md b/docs/Leetcode_Solutions/069._sqrt(x).md
similarity index 100%
rename from docs/leetcode/python/069._sqrt(x).md
rename to docs/Leetcode_Solutions/069._sqrt(x).md
diff --git a/docs/leetcode/python/070._Climbing_Stairs.md b/docs/Leetcode_Solutions/070. Climbing Stairs.md
similarity index 97%
rename from docs/leetcode/python/070._Climbing_Stairs.md
rename to docs/Leetcode_Solutions/070. Climbing Stairs.md
index 5c7ce3077..890b2f338 100644
--- a/docs/leetcode/python/070._Climbing_Stairs.md
+++ b/docs/Leetcode_Solutions/070. Climbing Stairs.md
@@ -77,7 +77,7 @@ class Solution(object):
- Space complexity : O(1). Constant space is used.
另外还有一个公式法:
-
+
由于这里面相当于```standard Fibonacci```函数向前进了一步,排列为1,2,3,5而非原本的1,1,2,3,所以代码中使用```n+1```
```python
diff --git a/docs/leetcode/python/072._edit_distance.md b/docs/Leetcode_Solutions/072._edit_distance.md
similarity index 52%
rename from docs/leetcode/python/072._edit_distance.md
rename to docs/Leetcode_Solutions/072._edit_distance.md
index 3a502d081..c2720f92b 100644
--- a/docs/leetcode/python/072._edit_distance.md
+++ b/docs/Leetcode_Solutions/072._edit_distance.md
@@ -1,4 +1,4 @@
-### 72. Edit Distance
+###72. Edit Distance
题目:
@@ -33,20 +33,6 @@ Hard
上面的就不用解释了,min分别对应:删除、插入、以及替代(1/0取决 word1[i] == word2[j] ),反正也是tabular类型,画表来解决问题。
-简单说,就是这样:
-
-1.delete:dp[i-1][j] + 1 —— 保留了从 word1[0:i-1] 转变到 word2[0:j] 的最优操作次数,因为我们的 word1 的 0~i-1 已经能够转变到 word2 了,
-所以我们就直接把 word1 中的最后一个字符删除掉就行了。所以就需要额外进行一个 删除 操作。
-
-2.insert:dp[i][j-1] + 1 —— 保留了从 word1[0:i] 转变到 word2[0:j-1] 的最优操作次数,因为我们的 word1 的 0~i 只能转变到 word2 的倒数第二位,所以我们就直接在 word1 的末尾添加一个与 word2 的最后一个字符相同的字符就可以了。所以就需要额外进行一个 插入 操作。
-
-3.replace:dp[i-1][j-1] + 1 —— 保留了从 word1[0:i-1] 转变到 word2[0:j-1] 的最优操作次数,因为我们的 word1 的 0~i-1 只能转变到 word2 的倒数第二位,而 word1 的最后一位与 word2 的最后一位是不同的,所以现在的情况只需要额外的一个 替换 操作即可。
-
-无论我们选取上面 3 中操作的哪种操作,我们选其中最小的值就可以了。
-
-参考链接:http://www.cnblogs.com/pandora/archive/2009/12/20/levenshtein_distance.html
-
-***要始终明确一点,```dp[i][j]```的含义是使得```word1的前i字符子串```与```word2的前j字符子串```相等所需要的操作数,这也是为什么我们需要在初始化```dp矩阵```时需要行列数均加上```1```***
用wikipedia上的伪码改造
@@ -99,7 +85,7 @@ g 7 7 6 5 4 4 3
AC代码
-```python
+```
class Solution(object):
def minDistance(self, word1, word2):
"""
@@ -107,12 +93,24 @@ class Solution(object):
:type word2: str
:rtype: int
"""
- if len(word1) == 0 or len(word2) == 0: # corner cases
- return max(len(word1), len(word2))
- dp = [[i+j for j in range(len(word2)+1)] for i in range(len(word1)+1)]
- for i in range(1, len(word1)+1):
- for j in range(1, len(word2)+1):
- tmp_dist = 0 if word1[i-1] == word2[j-1] else 1
- dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]+1, dp[i-1][j-1]+tmp_dist)
- return dp[-1][-1]
+ m,n = len(word1), len(word2)
+ dp = [[0 for i in range(m+1)] for j in range(n+1)]
+
+ for i in range(1,m+1):
+ dp[0][i] = i
+
+ for j in range(1,n+1):
+ dp[j][0] = j
+
+ for j in range(1,n+1):
+ for i in range(1,m+1):
+ cost = 0 if word1[i-1] == word2[j-1] else 1
+ dp[j][i] = min(dp[j-1][i] + 1, dp[j][i-1] + 1, dp[j-1][i-1] + cost)
+
+ return dp[n][m]
```
+
+
+貌似还有提升版本,但是比较明显即使有伪码,一开始也出错于下标.
+
+升级版 to be learned.
\ No newline at end of file
diff --git a/docs/leetcode/python/073._Set_Matrix_Zeroes.md b/docs/Leetcode_Solutions/073. Set Matrix Zeroes.md
similarity index 90%
rename from docs/leetcode/python/073._Set_Matrix_Zeroes.md
rename to docs/Leetcode_Solutions/073. Set Matrix Zeroes.md
index b8d12ccd1..0b30f99ed 100644
--- a/docs/leetcode/python/073._Set_Matrix_Zeroes.md
+++ b/docs/Leetcode_Solutions/073. Set Matrix Zeroes.md
@@ -15,7 +15,7 @@
Naive AC代码,一看类似那个 game of life,不用extra space,不用O(mn),应该就是用状态转移机了(?),所以还是先naive AC把:
-```python
+```
class Solution(object):
def setZeroes(self, matrix):
"""
@@ -27,14 +27,19 @@ class Solution(object):
matrix[i][m] = 0
for n in range(row):
matrix[n][j] = 0
-
+
+
row = len(matrix)
col = len(matrix[0]) if row else 0
- new_matrix = [matrix[i][:] for i in range(row)]
-
+
+ newM = []
+ for i in range(row):
+ newM.append(matrix[i][:])
+
+
for i in range(row):
for j in range(col):
- if new_matrix[i][j] == 0:
+ if newM[i][j] == 0:
setZero(i,j)
```
diff --git a/docs/leetcode/python/074._search_a_2d_matrix.md b/docs/Leetcode_Solutions/074._search_a_2d_matrix.md
similarity index 100%
rename from docs/leetcode/python/074._search_a_2d_matrix.md
rename to docs/Leetcode_Solutions/074._search_a_2d_matrix.md
diff --git a/docs/Leetcode_Solutions/075._sort_colors.md b/docs/Leetcode_Solutions/075._sort_colors.md
new file mode 100644
index 000000000..e70f4e6ad
--- /dev/null
+++ b/docs/Leetcode_Solutions/075._sort_colors.md
@@ -0,0 +1,54 @@
+###75. Sort Colors
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+思路:
+
+这个问题是 Dutch National Flag Problem, 荷兰旗问题
+
+
+
+思路其实是类似partition的,比x小的放左边,比x大的放右边。
+
+这里是用三个指针,begin, cur, end,cur需要遍历整个数组
+
+- cur 指向0,交换begin与cur, begin++,cur++
+- cur 指向1,不做任何交换,cur++
+- cur 指向2,交换end与cur,end--
+
+之所以cur指向2,交换之后不前进是因为我们不知道end此时指向的元素是几,如果交换过来的是0或者1,那么明显我们需要做进一步的处理,所以最终判断条件是end =< cur应该就结束了
+
+这样的three-way-partition也只是3-way好用吧?如果有4个数,那么这样则是无效的,或者如果是4-way,那么可以转换成3-way+2-way
+
+
+```
+class Solution(object):
+ def sortColors(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: void Do not return anything, modify nums in-place instead.
+ """
+ begin,cur,end = 0,0,len(nums) - 1
+
+ while cur <= end:
+ if nums[cur] == 0:
+ nums[begin],nums[cur] = nums[cur],nums[begin]
+ cur += 1
+ begin += 1
+
+ elif nums[cur] == 1:
+ cur += 1
+
+ else: # nums[cur] == 2
+ nums[cur],nums[end] = nums[end],nums[cur]
+ end -=1
+
+```
+
diff --git a/docs/leetcode/python/076._Minimum_Window_Substring.md b/docs/Leetcode_Solutions/076._Minimum_Window_Substring.md
similarity index 100%
rename from docs/leetcode/python/076._Minimum_Window_Substring.md
rename to docs/Leetcode_Solutions/076._Minimum_Window_Substring.md
diff --git a/docs/leetcode/python/077._combinations.md b/docs/Leetcode_Solutions/077._combinations.md
similarity index 100%
rename from docs/leetcode/python/077._combinations.md
rename to docs/Leetcode_Solutions/077._combinations.md
diff --git a/docs/Leetcode_Solutions/078.Subsets .md b/docs/Leetcode_Solutions/078.Subsets .md
new file mode 100644
index 000000000..e5b100563
--- /dev/null
+++ b/docs/Leetcode_Solutions/078.Subsets .md
@@ -0,0 +1,47 @@
+### 78. Subsets
+
+题目:
+
+
+
+难度 : Medium
+
+
+Python代码
+
+```python
+class Solution(object):
+ def subsets(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ results = [[]]
+ for num in nums:
+ results.extend([result + [num] for result in results])
+ return results
+
+```
+
+
+BackTrack 标准解法版
+
+
+```python
+class Solution:
+
+ def search(self, nums, S, index):
+ if index == len(nums):
+ self.results.append(S)
+ return
+
+ self.search(nums, S + [nums[index]], index + 1)
+ self.search(nums, S, index + 1)
+
+ def subsets(self, nums):
+ self.results = []
+ self.search(nums, [], 0)
+ return self.results
+```
+
+对每个元素,有两种可能,加入S和不加入S,写起来思路还是很清爽的
diff --git a/docs/leetcode/python/079._word_search.md b/docs/Leetcode_Solutions/079._word_search.md
similarity index 100%
rename from docs/leetcode/python/079._word_search.md
rename to docs/Leetcode_Solutions/079._word_search.md
diff --git a/docs/leetcode/python/082._remove_duplicates_from_sorted_list_ii.md b/docs/Leetcode_Solutions/082._remove_duplicates_from_sorted_list_ii.md
similarity index 100%
rename from docs/leetcode/python/082._remove_duplicates_from_sorted_list_ii.md
rename to docs/Leetcode_Solutions/082._remove_duplicates_from_sorted_list_ii.md
diff --git a/docs/leetcode/python/083._remove_duplicates_from_sorted_list.md b/docs/Leetcode_Solutions/083._remove_duplicates_from_sorted_list.md
similarity index 100%
rename from docs/leetcode/python/083._remove_duplicates_from_sorted_list.md
rename to docs/Leetcode_Solutions/083._remove_duplicates_from_sorted_list.md
diff --git a/docs/leetcode/python/086._partition_list.md b/docs/Leetcode_Solutions/086._partition_list.md
similarity index 100%
rename from docs/leetcode/python/086._partition_list.md
rename to docs/Leetcode_Solutions/086._partition_list.md
diff --git a/docs/Leetcode_Solutions/088._merge_sorted_array.md b/docs/Leetcode_Solutions/088._merge_sorted_array.md
new file mode 100644
index 000000000..029b3c330
--- /dev/null
+++ b/docs/Leetcode_Solutions/088._merge_sorted_array.md
@@ -0,0 +1,46 @@
+### 88. Merge Sorted Array
+
+
+题目:
+
+
+
+难度 : Easy
+
+### 思路:
+
+给的数组可能是这样的
+
+- nums1 : [0]
+- m : 0
+- nums2 : [1]
+- n : 1
+
+
+所以要判断m和n是不是仍然大于0
+
+
+AC代码
+
+
+```python
+class Solution:
+ def merge(self, nums1, m, nums2, n):
+ """
+ :type nums1: List[int]
+ :type m: int
+ :type nums2: List[int]
+ :type n: int
+ :rtype: void Do not return anything, modify nums1 in-place instead.
+ """
+ while m > 0 and n > 0:
+ if nums1[m-1] > nums2[n-1]:
+ nums1[m+n-1] = nums1[m-1]
+ m -= 1
+ else:
+ nums1[m+n-1] = nums2[n-1]
+ n -= 1
+ if n > 0:
+ nums1[:n] = nums2[:n]
+
+```
diff --git a/docs/leetcode/python/089._gray_code.md b/docs/Leetcode_Solutions/089._gray_code.md
similarity index 100%
rename from docs/leetcode/python/089._gray_code.md
rename to docs/Leetcode_Solutions/089._gray_code.md
diff --git a/docs/Leetcode_Solutions/090._subsets_ii.md b/docs/Leetcode_Solutions/090._subsets_ii.md
new file mode 100644
index 000000000..99661e3da
--- /dev/null
+++ b/docs/Leetcode_Solutions/090._subsets_ii.md
@@ -0,0 +1,80 @@
+### 90. Subsets II
+
+题目:
+
+
+
+难度 : Medium
+
+
+思路:
+
+
+参考别人的
+
+现在来观察规律,与之前有不同之处是我们需要一个位置来mark,因为不再需要往之前出现过的地方再加了,看这个:
+
+
+```
+[[],[1]] 是 [1] 的子集合
+[[],[1],[2],[1,2]] 是 [1,2] 的子集合,实际上就是1的子集合们加了一个2
+新来的2不能再从头开始加了,它需要从[ .., [2],[1,2] ]加 才是合理的
+
+****当出现多个重复数字时,应该从 已经拥有了新数字所出现全部次数的list开始加才是合理的****
+[[],[1]] 是 [1] 的子集合
+[[],[1],[2],[1,2]] 是 [1,2] 的子集合,实际上就是1的子集合们加了一个2
+[
+ [2],
+ [1],
+ [1,2,2],
+ [2,2],
+ [1,2],
+ []
+] 是 [1,2,2] 的子集和,实际上也就是[1,2]的子集合加了一个2
+新来的2不能再从头开始加了,它需要从[ .., [2,2],[1,2,2] ]加 才是合理的
+例如:
+```
+
+
+这里这个start是来记录了之前一次数组的长度,temp_size记住目前数组的长度,然后用这个来达到去重的目的,非常聪明
+
+自己的解法
+```python
+class Solution(object):
+ def subsetsWithDup(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ nums.sort()
+ results = [[]]
+ for i in range(len(nums)):
+ if any(nums[i] in result for result in results):
+ results.extend([result + [nums[i]] for result in results if result.count(nums[i]) == i - nums.index(nums[i])])
+ else:
+ results.extend([result + [nums[i]] for result in results])
+ return results
+
+```
+
+
+别人的,但是一个意思
+```python
+class Solution(object):
+ def subsetsWithDup(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ nums.sort()
+ result = [[]]
+ temp_size = 0
+ for i in range(len(nums)):
+ start = temp_size if i >= 1 and nums[i] == nums[i-1] else 0
+ temp_size = len(result)
+ for j in range(start, temp_size):
+ result.append(result[j] + [nums[i]])
+ return result
+
+```
+
diff --git a/docs/leetcode/python/091._decode_ways.md b/docs/Leetcode_Solutions/091._decode_ways.md
similarity index 100%
rename from docs/leetcode/python/091._decode_ways.md
rename to docs/Leetcode_Solutions/091._decode_ways.md
diff --git a/docs/leetcode/python/092._reverse_linked_list_ii.md b/docs/Leetcode_Solutions/092._reverse_linked_list_ii.md
similarity index 100%
rename from docs/leetcode/python/092._reverse_linked_list_ii.md
rename to docs/Leetcode_Solutions/092._reverse_linked_list_ii.md
diff --git a/docs/leetcode/python/093._restore_ip_addresses.md b/docs/Leetcode_Solutions/093._restore_ip_addresses.md
similarity index 100%
rename from docs/leetcode/python/093._restore_ip_addresses.md
rename to docs/Leetcode_Solutions/093._restore_ip_addresses.md
diff --git a/docs/Leetcode_Solutions/094._binary_tree_inorder_traversal.md b/docs/Leetcode_Solutions/094._binary_tree_inorder_traversal.md
new file mode 100644
index 000000000..dc288f127
--- /dev/null
+++ b/docs/Leetcode_Solutions/094._binary_tree_inorder_traversal.md
@@ -0,0 +1,92 @@
+### 94. Binary Tree Inorder Traversal
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+递归版本1⃣️:自己瞬秒的
+
+
+
+
+```python
+class Solution(object):
+ def inorderTraversal(self, root):
+ """
+ :type root: TreeNode
+ :rtype: List[int]
+ """
+ res = []
+ if not root:
+ return res
+ if root.left:
+ res.extend(self.inorderTraversal(root.left))
+ res.append(root.val)
+ if root.right:
+ res.extend(self.inorderTraversal(root.right))
+ return res
+```
+
+递归版本2⃣️:
+```python
+class Solution(object):
+ def inorderTraversal(self, root):
+ """
+ :type root: TreeNode
+ :rtype: List[int]
+ """
+ self.lst = []
+ self.DFS(root)
+ return self.lst
+
+
+ def DFS(self,root):
+ if root == None:
+ return
+ if root.left:
+ self.DFS(root.left)
+ self.lst.append(root.val)
+ if root.right:
+ self.DFS(root.right)
+
+```
+
+非递归用stack,我听谁讲过 😓
+
+// to be done
+
+
+via wikipedia
+
+
+递归:
+
+```
+inorder(node)
+ if (node = null)
+ return
+ inorder(node.left)
+ visit(node)
+ inorder(node.right)
+```
+
+
+非递归,跟之前那个iterator有得一拼,其实好几个题都是在玩这个花样?
+
+```
+iterativeInorder(node)
+ s ← empty stack
+ while (not s.isEmpty() or node ≠ null)
+ if (node ≠ null)
+ s.push(node)
+ node ← node.left
+ else
+ node ← s.pop()
+ visit(node)
+ node ← node.right
+```
diff --git a/docs/Leetcode_Solutions/096._unique_binary_search_trees.md b/docs/Leetcode_Solutions/096._unique_binary_search_trees.md
new file mode 100644
index 000000000..2e29cf929
--- /dev/null
+++ b/docs/Leetcode_Solutions/096._unique_binary_search_trees.md
@@ -0,0 +1,43 @@
+###96. Unique Binary Search Trees
+
+
+
+题目:
+
+
+
+难度:
+Medium
+
+思路:
+
+
+参照此处hint:
+
+
+
+
+首先明确n个不等的数它们能构成的二叉搜索树的种类都是相等的.
+
+毫无头绪,对于1...n的bst,可以这样看,k可以作为root,那么1..k-1必定在左边,k+1...n必定在右边,而1...k-1课产生的bst树是dp[k-1],右边产生的数是dp[n-k],所以能生成的树的数量是 dp[k-1]* dp[n-k]
+
+dp[n] = sum(dp[k-1]*dp[n-k]),从0到k
+
+
+```
+class Solution(object):
+ def numTrees(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ dp = [ 1 for i in range(n+1)]
+
+ for i in range(2,n+1):
+ s = 0
+ for k in range(i):
+ s += dp[k]*dp[i-k-1]
+ dp[i] = s
+
+ return dp[-1]
+```
\ No newline at end of file
diff --git a/docs/leetcode/python/098._validate_binary_search_tree.md b/docs/Leetcode_Solutions/098._validate_binary_search_tree.md
similarity index 100%
rename from docs/leetcode/python/098._validate_binary_search_tree.md
rename to docs/Leetcode_Solutions/098._validate_binary_search_tree.md
diff --git a/docs/leetcode/python/100._same_tree.md b/docs/Leetcode_Solutions/100._same_tree.md
similarity index 95%
rename from docs/leetcode/python/100._same_tree.md
rename to docs/Leetcode_Solutions/100._same_tree.md
index f1e4a0b26..f12c86c3a 100644
--- a/docs/leetcode/python/100._same_tree.md
+++ b/docs/Leetcode_Solutions/100._same_tree.md
@@ -1,49 +1,49 @@
-### 100. Same Tree
-
-题目:
-
-
-
-
-难度:
-
-Easy
-
-
-太简单了,递归一行!
-
-
-```python
-# Definition for a binary tree node.
-# class TreeNode(object):
-# def __init__(self, x):
-# self.val = x
-# self.left = None
-# self.right = None
-
-class Solution(object):
- def isSameTree(self, p, q):
- """
- :type p: TreeNode
- :type q: TreeNode
- :rtype: bool
- """
- return p.val == q.val and all(map(self.isSameTree, (p.left, p.right), (q.left, q.right))) if p and q else p is q
-```
-
-```python
-class Solution(object):
- def isSameTree(self, p, q):
- """
- :type p: TreeNode
- :type q: TreeNode
- :rtype: bool
- """
- if (not p and q) or (p and not q):
- return False
- if not p and not q:
- return True
- if p.val == q.val:
- return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right)
- return False
-```
+### 100. Same Tree
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+太简单了,递归一行!
+
+
+```python
+# Definition for a binary tree node.
+# class TreeNode(object):
+# def __init__(self, x):
+# self.val = x
+# self.left = None
+# self.right = None
+
+class Solution(object):
+ def isSameTree(self, p, q):
+ """
+ :type p: TreeNode
+ :type q: TreeNode
+ :rtype: bool
+ """
+ return p.val == q.val and all(map(self.isSameTree, (p.left, p.right), (q.left, q.right))) if p and q else p is q
+```
+
+```python
+class Solution(object):
+ def isSameTree(self, p, q):
+ """
+ :type p: TreeNode
+ :type q: TreeNode
+ :rtype: bool
+ """
+ if (not p and q) or (p and not q):
+ return False
+ if not p and not q:
+ return True
+ if p.val == q.val:
+ return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right)
+ return False
+```
diff --git a/docs/leetcode/python/101._symmetric_tree.md b/docs/Leetcode_Solutions/101._symmetric_tree.md
similarity index 95%
rename from docs/leetcode/python/101._symmetric_tree.md
rename to docs/Leetcode_Solutions/101._symmetric_tree.md
index ac5b08266..cb6f5219b 100644
--- a/docs/leetcode/python/101._symmetric_tree.md
+++ b/docs/Leetcode_Solutions/101._symmetric_tree.md
@@ -1,45 +1,45 @@
-### 101. Symmetric Tree
-
-题目:
-
-
-
-
-难度:
-
-Easy
-
-
-两棵树symmetric, 有几种可能:
-
-- 均为none ,symmetric
-- 左孩子,右孩子都不存在,并且值相等, symmetric
-- 右子树 和 另一棵树的左子树相等,左子树 和另一颗树的右子树相等 🌲
-
-
-```python
-class Solution(object):
- def isSymmetric(self, root):
- """
- :type root: TreeNode
- :rtype: bool
- """
- if not root:
- return True
- return self.symmetric(root.left, root.right)
-
- def symmetric(self, l1, l2):
- if not l1 or not l2:
- if not l1 and not l2:
- return True
- else:
- return False
- if l1.val == l2.val:
- return self.symmetric(l1.left, l2.right) and self.symmetric(l1.right, l2.left)
- else:
- return False
-```
-
-
-
-
+### 101. Symmetric Tree
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+两棵树symmetric, 有几种可能:
+
+- 均为none ,symmetric
+- 左孩子,右孩子都不存在,并且值相等, symmetric
+- 右子树 和 另一棵树的左子树相等,左子树 和另一颗树的右子树相等 🌲
+
+
+```python
+class Solution(object):
+ def isSymmetric(self, root):
+ """
+ :type root: TreeNode
+ :rtype: bool
+ """
+ if not root:
+ return True
+ return self.symmetric(root.left, root.right)
+
+ def symmetric(self, l1, l2):
+ if not l1 or not l2:
+ if not l1 and not l2:
+ return True
+ else:
+ return False
+ if l1.val == l2.val:
+ return self.symmetric(l1.left, l2.right) and self.symmetric(l1.right, l2.left)
+ else:
+ return False
+```
+
+
+
+
diff --git a/docs/leetcode/python/102._binary_tree_level_order_traversal.md b/docs/Leetcode_Solutions/102._binary_tree_level_order_traversal.md
similarity index 54%
rename from docs/leetcode/python/102._binary_tree_level_order_traversal.md
rename to docs/Leetcode_Solutions/102._binary_tree_level_order_traversal.md
index d95eac61f..7d4ac4efb 100644
--- a/docs/leetcode/python/102._binary_tree_level_order_traversal.md
+++ b/docs/Leetcode_Solutions/102._binary_tree_level_order_traversal.md
@@ -1,61 +1,15 @@
-# 102. Binary Tree Level Order Traversal
-**难度: 中等 **
+### 102. Binary Tree Level Order Traversal
-## 刷题内容
+题目:
-> 原题连接
+
-* https://leetcode.com/problems/binary-tree-level-order-traversal
-> 内容描述
+难度:
-```
-Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
-
-For example:
-Given binary tree [3,9,20,null,null,15,7],
- 3
- / \
- 9 20
- / \
- 15 7
-return its level order traversal as:
-[
- [3],
- [9,20],
- [15,7]
-]
-```
-
-## 解题方案
-
-> 思路 1
-
-递归
-
-```python
-class Solution(object):
- def levelOrder(self, root):
- """
- :type root: TreeNode
- :rtype: List[List[int]]
- """
- res = []
- self.recurHelper(root, 0, res)
- return res
-
- def recurHelper(self, root, level, res):
- if not root: return
- if len(res) < level + 1:
- res.append([])
- res[level].append(root.val)
- self.recurHelper(root.left, level+1, res)
- self.recurHelper(root.right, level+1, res)
-```
-
-> 思路 2
+Medium
-迭代,利用curLevel和nextLevel来记录,然后按层append.
+第一种做法:利用curLevel和nextLevel来记录,然后按层append.
```python
@@ -82,4 +36,27 @@ class Solution(object):
```
+第二种做法:递归
+
+
+```python
+class Solution(object):
+ def levelOrder(self, root):
+ """
+ :type root: TreeNode
+ :rtype: List[List[int]]
+ """
+ res = []
+ self.iter_order(root, 0, res)
+ return res
+
+ def iter_order(self, root, level, res):
+ if not root: return
+ if len(res) < level + 1:
+ res.append([])
+ res[level].append(root.val)
+ self.iter_order(root.left, level+1, res)
+ self.iter_order(root.right, level+1, res)
+```
+用递归来记录每一层,需要更加学习,不算easy
diff --git a/docs/leetcode/python/103._binary_tree_zigzag_level_order_traversal.md b/docs/Leetcode_Solutions/103._binary_tree_zigzag_level_order_traversal.md
similarity index 95%
rename from docs/leetcode/python/103._binary_tree_zigzag_level_order_traversal.md
rename to docs/Leetcode_Solutions/103._binary_tree_zigzag_level_order_traversal.md
index 0f5f55fd1..edc9b3986 100644
--- a/docs/leetcode/python/103._binary_tree_zigzag_level_order_traversal.md
+++ b/docs/Leetcode_Solutions/103._binary_tree_zigzag_level_order_traversal.md
@@ -1,43 +1,43 @@
-### 103. Binary Tree Zigzag Level Order Traversal
-
-题目:
-
-
-
-
-难度:
-
-Medium
-
-
-
-```python
-class Solution(object):
- def zigzagLevelOrder(self, root):
- """
- :type root: TreeNode
- :rtype: List[List[int]]
- """
- if not root:
- return []
- res, cur_level, level_count = [], [root], 0
- while cur_level:
- next_level, tmp_res = [], []
- for node in cur_level:
- tmp_res.append(node.val)
- if node.left:
- next_level.append(node.left)
- if node.right:
- next_level.append(node.right)
- if level_count % 2 == 0:
- res.append(tmp_res)
- else:
- tmp_res.reverse()
- res.append(tmp_res)
- level_count += 1
- cur_level = next_level
-
- return res
-```
-
-
+### 103. Binary Tree Zigzag Level Order Traversal
+
+题目:
+
+
+
+
+难度:
+
+Medium
+
+
+
+```python
+class Solution(object):
+ def zigzagLevelOrder(self, root):
+ """
+ :type root: TreeNode
+ :rtype: List[List[int]]
+ """
+ if not root:
+ return []
+ res, cur_level, level_count = [], [root], 0
+ while cur_level:
+ next_level, tmp_res = [], []
+ for node in cur_level:
+ tmp_res.append(node.val)
+ if node.left:
+ next_level.append(node.left)
+ if node.right:
+ next_level.append(node.right)
+ if level_count % 2 == 0:
+ res.append(tmp_res)
+ else:
+ tmp_res.reverse()
+ res.append(tmp_res)
+ level_count += 1
+ cur_level = next_level
+
+ return res
+```
+
+
diff --git a/docs/leetcode/python/104._maximum_depth_of_binary_tree.md b/docs/Leetcode_Solutions/104._maximum_depth_of_binary_tree.md
similarity index 95%
rename from docs/leetcode/python/104._maximum_depth_of_binary_tree.md
rename to docs/Leetcode_Solutions/104._maximum_depth_of_binary_tree.md
index ffd5898a8..451160d32 100644
--- a/docs/leetcode/python/104._maximum_depth_of_binary_tree.md
+++ b/docs/Leetcode_Solutions/104._maximum_depth_of_binary_tree.md
@@ -1,23 +1,23 @@
-### 104. Maximum Depth of Binary Tree
-
-题目:
-
-
-
-难度:
-
-Easy
-
-
-简单题,但是这道题跟[leetcode111](https://github.com/Lisanaaa/thinking_in_lc/blob/master/111._minimum_depth_of_binary_tree.md)不一样,这道题没有特殊情况,所以一行就够了
-
-
-```python
-class Solution(object):
- def maxDepth(self, root):
- """
- :type root: TreeNode
- :rtype: int
- """
- return 1 + max(map(self.maxDepth, (root.left, root.right))) if root else 0
-```
+### 104. Maximum Depth of Binary Tree
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+简单题,但是这道题跟[leetcode111](https://github.com/Lisanaaa/thinking_in_lc/blob/master/111._minimum_depth_of_binary_tree.md)不一样,这道题没有特殊情况,所以一行就够了
+
+
+```python
+class Solution(object):
+ def maxDepth(self, root):
+ """
+ :type root: TreeNode
+ :rtype: int
+ """
+ return 1 + max(map(self.maxDepth, (root.left, root.right))) if root else 0
+```
diff --git a/docs/Leetcode_Solutions/105._construct_binary_tree_from_preorder_and_inorder_traversal.md b/docs/Leetcode_Solutions/105._construct_binary_tree_from_preorder_and_inorder_traversal.md
new file mode 100644
index 000000000..7ed244dd9
--- /dev/null
+++ b/docs/Leetcode_Solutions/105._construct_binary_tree_from_preorder_and_inorder_traversal.md
@@ -0,0 +1,100 @@
+###105. Construct Binary Tree from Preorder and Inorder Traversal
+
+题目:
+
+
+
+难度 : Medium
+
+
+preorder 是 根 -> 左 -> 右
+inorder 是 左 -> 根 -> 右
+
+
+首先pre的第一个就是整个树的root, 假设 pre[0] = in[k],那么in的前k-1个就是树的左子树,后面部分就是树的右子树,这样递归来看.
+
+然后递归来看,对于前k-1个又是同样的道理吧。
+
+然后用递归,写了一颗小树测试,感觉上是对的,
+
+
+```
+class TreeNode(object):
+ def __init__(self, x):
+ self.val = x
+ self.left = None
+ self.right = None
+
+nodeA = TreeNode('A')
+nodeB = TreeNode('B')
+nodeC = TreeNode('C')
+nodeD = TreeNode('D')
+nodeE = TreeNode('E')
+nodeF = TreeNode('F')
+
+nodeA.left = nodeB
+nodeA.right = nodeC
+nodeB.left = nodeD
+nodeB.right = nodeE
+nodeC.left = nodeF
+
+
+ # A
+ # / \
+ # B C
+ # / \ /
+ # D E F
+
+
+def construct(preorder, inorder):
+ if preorder == inorder == []:
+ return None
+ else:
+ rootVal = preorder[0]
+ root = TreeNode(rootVal)
+ k = inorder.index(rootVal)
+ if len(preorder) == len(inorder) == 1:
+ return root
+ else:
+ root.left = construct(preorder[1:1+k],inorder[:k])
+ root.right = construct(preorder[k+1:],inorder[k+1:])
+ return root
+root = construct(['A','B','D','E','C','F'],['D','B','E','A','F','C'])
+
+```
+
+尝试AC发现,memory limit超,用大一点的数据测试RecursionError: maximum recursion depth exceeded。
+
+根据网上的参考改成偏iteration一点的递归, AC通过
+
+mark一下,为了避免数组的复杂操作,这里直接用左右界和数组的引用来代表一段前序遍历和中序遍历。直接用递归更改list本身不能AC,但是变成这样就可以AC,因为更改数组会拷贝数组带来很多内存和递归上的麻烦,是这样的么?
+
+这个技巧还比较常见,就是用原本list的角标,而不去cut list本身
+
+
+```
+class Solution(object):
+ def buildTree(self, preorder, inorder):
+ """
+ :type preorder: List[int]
+ :type inorder: List[int]
+ :rtype: TreeNode
+ """
+ def buildTree(preorder, inorder, lp, rp, li, ri):
+ if lp > rp or li > ri:
+ return None
+
+ root = TreeNode(preorder[lp])
+ k = inorder.index(preorder[lp])
+
+ # left node
+ left = buildTree(preorder, inorder, lp+1, lp + k - li, li, k - 1)
+ right = buildTree(preorder, inorder, lp + k - li + 1, rp, k+1, ri)
+
+ root.left = left
+ root.right = right
+
+ return root
+
+ return buildTree(preorder, inorder, 0 , len(preorder) - 1, 0, len(inorder) -1)
+```
diff --git a/docs/leetcode/python/106._construct_binary_tree_from_inorder_and_postorder_traversal.md b/docs/Leetcode_Solutions/106._construct_binary_tree_from_inorder_and_postorder_traversal.md
similarity index 100%
rename from docs/leetcode/python/106._construct_binary_tree_from_inorder_and_postorder_traversal.md
rename to docs/Leetcode_Solutions/106._construct_binary_tree_from_inorder_and_postorder_traversal.md
diff --git a/docs/leetcode/python/107._binary_tree_level_order_traversal_ii.md b/docs/Leetcode_Solutions/107._binary_tree_level_order_traversal_ii.md
similarity index 97%
rename from docs/leetcode/python/107._binary_tree_level_order_traversal_ii.md
rename to docs/Leetcode_Solutions/107._binary_tree_level_order_traversal_ii.md
index 3ef6e4d8c..a7fd3d732 100644
--- a/docs/leetcode/python/107._binary_tree_level_order_traversal_ii.md
+++ b/docs/Leetcode_Solutions/107._binary_tree_level_order_traversal_ii.md
@@ -14,34 +14,34 @@ Easy
```
-# Definition for a binary tree node.
-# class TreeNode(object):
-# def __init__(self, x):
-# self.val = x
-# self.left = None
-# self.right = None
-
-class Solution(object):
- def levelOrderBottom(self, root):
- """
- :type root: TreeNode
- :rtype: List[List[int]]
- """
- res = []
-
- if root == None: return []
-
- curLevel = [root]
- while curLevel:
- nextLevel = []
- tmpRes = []
- for node in curLevel:
- tmpRes.append(node.val)
- if node.left: nextLevel.append(node.left)
- if node.right: nextLevel.append(node.right)
- res.append(tmpRes)
- curLevel = nextLevel
- res.reverse()
+# Definition for a binary tree node.
+# class TreeNode(object):
+# def __init__(self, x):
+# self.val = x
+# self.left = None
+# self.right = None
+
+class Solution(object):
+ def levelOrderBottom(self, root):
+ """
+ :type root: TreeNode
+ :rtype: List[List[int]]
+ """
+ res = []
+
+ if root == None: return []
+
+ curLevel = [root]
+ while curLevel:
+ nextLevel = []
+ tmpRes = []
+ for node in curLevel:
+ tmpRes.append(node.val)
+ if node.left: nextLevel.append(node.left)
+ if node.right: nextLevel.append(node.right)
+ res.append(tmpRes)
+ curLevel = nextLevel
+ res.reverse()
return res
```
diff --git a/docs/Leetcode_Solutions/108._convert_sorted_array_to_binary_search_tree.md b/docs/Leetcode_Solutions/108._convert_sorted_array_to_binary_search_tree.md
new file mode 100644
index 000000000..12705f918
--- /dev/null
+++ b/docs/Leetcode_Solutions/108._convert_sorted_array_to_binary_search_tree.md
@@ -0,0 +1,41 @@
+###108. Convert Sorted Array to Binary Search Tree
+
+题目:
+
+
+
+难度:
+Medium
+
+
+思路:
+
+递归
+
+- nums为空,return None
+- nums 只有一个, return其为根节点
+- nums 大于一个,nums[n/2]为中间元素,根结点,nums[:mid]为左子树, nums[mid+1:]为右子树
+
+
+```
+class Solution(object):
+ def sortedArrayToBST(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: TreeNode
+ """
+ n = len(nums)
+
+ if n == 0 :
+ return None
+ if n == 1 :
+ return TreeNode(nums[0])
+ else:
+ mid = n / 2
+ root = TreeNode(nums[mid])
+ root.left = self.sortedArrayToBST(nums[:mid])
+ root.right = self.sortedArrayToBST(nums[mid+1:])
+ return root
+
+
+```
diff --git a/docs/Leetcode_Solutions/109._convert_sorted_list_to_binary_search_tree.md b/docs/Leetcode_Solutions/109._convert_sorted_list_to_binary_search_tree.md
new file mode 100644
index 000000000..4ca36dc47
--- /dev/null
+++ b/docs/Leetcode_Solutions/109._convert_sorted_list_to_binary_search_tree.md
@@ -0,0 +1,47 @@
+###109. Convert Sorted List to Binary Search Tree
+
+
+
+题目:
+
+
+
+难度:
+
+Medium
+
+思路:
+
+跟解array to binary search tree一样,递归,找到list中间点,把它变成root,左边为左树,右边为右子树
+
+值得注意的是需要找到的是list中间的前一个,所以用一个dummy node,然后反复使用linked list找中点的代码
+
+```
+class Solution(object):
+ def sortedListToBST(self, head):
+ """
+ :type head: ListNode
+ :rtype: TreeNode
+ """
+
+ if head == None:
+ return None
+ elif head.next == None:
+ return TreeNode(head.val)
+ else:
+ dummy = ListNode(-1)
+ dummy.next = head
+ slow, fast = dummy, dummy
+ while fast.next and fast.next.next:
+ slow = slow.next
+ fast = fast.next.next
+
+ # print slow.val
+ mid = slow.next
+ slow.next = None
+
+ root = TreeNode(mid.val)
+ root.left = self.sortedListToBST(head)
+ root.right = self.sortedListToBST(mid.next)
+ return root
+```
diff --git a/docs/Leetcode_Solutions/110._balanced_binary_tree.md b/docs/Leetcode_Solutions/110._balanced_binary_tree.md
new file mode 100644
index 000000000..4b32130f9
--- /dev/null
+++ b/docs/Leetcode_Solutions/110._balanced_binary_tree.md
@@ -0,0 +1,37 @@
+###110. Balanced Binary Tree
+
+题目:
+
+
+
+难度:
+Easy
+
+
+全程递归中
+
+
+
+```
+class Solution(object):
+ def isBalanced(self, root):
+ """
+ :type root: TreeNode
+ :rtype: bool
+ """
+ if root == None:
+ return True
+
+ lh = self.height(root.left)
+ rh = self.height(root.right)
+
+ if abs(lh-rh) <= 1 and self.isBalanced(root.left) and self.isBalanced(root.right):
+ return True
+ return False
+
+
+ def height(self, node):
+ if node == None:
+ return 0
+ return 1 + max(self.height(node.left),self.height(node.right))
+```
\ No newline at end of file
diff --git a/docs/leetcode/python/111._minimum_depth_of_binary_tree.md b/docs/Leetcode_Solutions/111._minimum_depth_of_binary_tree.md
similarity index 100%
rename from docs/leetcode/python/111._minimum_depth_of_binary_tree.md
rename to docs/Leetcode_Solutions/111._minimum_depth_of_binary_tree.md
diff --git a/docs/leetcode/python/112._path_sum.md b/docs/Leetcode_Solutions/112._path_sum.md
similarity index 100%
rename from docs/leetcode/python/112._path_sum.md
rename to docs/Leetcode_Solutions/112._path_sum.md
diff --git a/docs/leetcode/python/113._path_sum_ii.md b/docs/Leetcode_Solutions/113._path_sum_ii.md
similarity index 100%
rename from docs/leetcode/python/113._path_sum_ii.md
rename to docs/Leetcode_Solutions/113._path_sum_ii.md
diff --git a/docs/Leetcode_Solutions/114._flatten_binary_tree_to_linked_list.md b/docs/Leetcode_Solutions/114._flatten_binary_tree_to_linked_list.md
new file mode 100644
index 000000000..f23fd7870
--- /dev/null
+++ b/docs/Leetcode_Solutions/114._flatten_binary_tree_to_linked_list.md
@@ -0,0 +1,42 @@
+###114. Flatten Binary Tree to Linked List
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+有hint,又是玩DFS的preorder,用的loop,也不算很聪明的算法
+
+用stack来放node,每次把pop出来的node左边变成null,把它的right指向下一个pop出来的node,也就是为嘛有prev,然后root处特殊处理一下
+
+
+```
+
+class Solution(object):
+ def flatten(self, root):
+ """
+ :type root: TreeNode
+ :rtype: void Do not return anything, modify root in-place instead.
+ """
+ if root == None:
+ return
+ s = []
+ s.append(root)
+ prev = root
+ while s:
+ node = s.pop()
+ if node.right:
+ s.append(node.right)
+ if node.left:
+ s.append(node.left)
+ node.left = None
+ if node == root:
+ continue
+ else:
+ prev.right = node
+ prev = node
+```
diff --git a/docs/Leetcode_Solutions/116._populating_next_right_pointers_in_each_node.md b/docs/Leetcode_Solutions/116._populating_next_right_pointers_in_each_node.md
new file mode 100644
index 000000000..ed51a5c1e
--- /dev/null
+++ b/docs/Leetcode_Solutions/116._populating_next_right_pointers_in_each_node.md
@@ -0,0 +1,36 @@
+###116. Populating Next Right Pointers in Each Node
+
+题目:
+
+
+
+
+难度:
+
+Medium
+
+思路: 跟level print一样,把每个level由左到右记录。
+然后这层level的右指向右,最后一个指向None。
+处理一下边界条件,完工。
+
+看题目tag给的DFS,所以是否有哪种push & pop stack的方法可以特别来处理指向呢-》 有待研究
+
+```
+class Solution(object):
+ def connect(self, root):
+ """
+ :type root: TreeLinkNode
+ :rtype: nothing
+ """
+ if root == None: return root
+ thislevel = [root]
+ while thislevel:
+ nextlevel = list()
+ for n in thislevel:
+ if n.left: nextlevel.append(n.left)
+ if n.right: nextlevel.append(n.right)
+ for i in range(len(thislevel)-1):
+ thislevel[i].next = thislevel[i+1]
+ thislevel[-1].next = None
+ thislevel = nextlevel
+```
diff --git a/docs/Leetcode_Solutions/118._pascal's_triangle.md b/docs/Leetcode_Solutions/118._pascal's_triangle.md
new file mode 100644
index 000000000..72e7a44f9
--- /dev/null
+++ b/docs/Leetcode_Solutions/118._pascal's_triangle.md
@@ -0,0 +1,36 @@
+###118. Pascal's Triangle
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+高中数学知识,把行数理理清楚就ok
+
+
+```
+class Solution(object):
+ def generate(self, numRows):
+ """
+ :type numRows: int
+ :rtype: List[List[int]]
+ """
+ res = [[1],[1,1]]
+ if numRows < 3:
+ return res[:numRows]
+ for i in range(3, numRows+1):
+ tmp = [1] * i
+ for j in range(1,i-1):
+ tmp[j] = res[i-2][j-1] + res[i-2][j]
+ res.append(tmp)
+ return res
+
+
+```
+
+
diff --git a/docs/Leetcode_Solutions/119. Pascal's Triangle II.md b/docs/Leetcode_Solutions/119. Pascal's Triangle II.md
new file mode 100644
index 000000000..dbf97df9d
--- /dev/null
+++ b/docs/Leetcode_Solutions/119. Pascal's Triangle II.md
@@ -0,0 +1,59 @@
+### 119. Pascal's Triangle II
+
+题目:
+
+
+难度 : Easy
+
+
+
+思路:
+
+高中数学
+
+
+
+这种算法会超时|||
+
+```
+class Solution(object):
+ def getRow(self, rowIndex):
+ """
+ :type rowIndex: int
+ :rtype: List[int]
+ """
+ def combNum(n,k):
+ if k == 0 or k == n :
+ return 1
+ return combNum(n-1,k-1) + combNum(n-1,k)
+ res = []
+ for i in range(rowIndex + 1):
+ res.append(combNum(rowIndex,i))
+
+ return res
+```
+
+
+
+用118改的,AC代码
+
+
+
+```
+class Solution(object):
+ def getRow(self, rowIndex):
+ """
+ :type rowIndex: int
+ :rtype: List[int]
+ """
+ res = [[1],[1,1]]
+ if rowIndex < 2:
+ return res[rowIndex]
+ for i in range(3, rowIndex+2):
+ tmp = [1] * i
+ for j in range(1,i-1):
+ tmp[j] = res[i-2][j-1] + res[i-2][j]
+ res.append(tmp)
+ return res[-1]
+```
+
diff --git a/docs/leetcode/python/120._Triangle.md b/docs/Leetcode_Solutions/120. Triangle.md
similarity index 100%
rename from docs/leetcode/python/120._Triangle.md
rename to docs/Leetcode_Solutions/120. Triangle.md
diff --git a/docs/Leetcode_Solutions/121._Best_Time_to_Buy_and_Sell_Stock.md b/docs/Leetcode_Solutions/121._Best_Time_to_Buy_and_Sell_Stock.md
new file mode 100644
index 000000000..2edfa898b
--- /dev/null
+++ b/docs/Leetcode_Solutions/121._Best_Time_to_Buy_and_Sell_Stock.md
@@ -0,0 +1,59 @@
+### 121. Best Time to Buy and Sell Stock
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+思路
+
+All the straight forward solution should work, but if the interviewer twists the question slightly
+by giving the difference array of prices, Ex: for ```{1, 7, 4, 11}```, if he gives ```{0, 6, -3, 7}```,
+you might end up being confused.
+
+Here, the logic is to calculate the difference ```(maxCur += prices[i] - prices[i-1])```
+of the original array, and find a contiguous subarray giving maximum profit.
+If the difference falls below ```0```, reset it to zero.
+
+参考[Maximum subarray problem](https://en.wikipedia.org/wiki/Maximum_subarray_problem),
+[Kadane's Algorithm](https://discuss.leetcode.com/topic/19853/kadane-s-algorithm-since-no-one-has-mentioned-about-this-so-far-in-case-if-interviewer-twists-the-input)
+
+
+```
+Why maxCur = Math.max(0, maxCur += prices[i] - prices[i-1]); ?
+
+Well, we can assume opt(i) as the max Profit you will get if you sell the stock at day i;
+
+We now face two situations:
+
+We hold a stock at day i, which means opt(i) = opt(i - 1) - prices[i - 1] + prices[i] (max Profit you can get if you sell stock at day(i-1) - money you lose if you buy the stock at day (i-1) + money you gain if you sell the stock at day i.
+
+We do not hold a stock at day i, which means we cannot sell any stock at day i. In this case, money we can get at day i is 0;
+
+opt(i) is the best case of 1 and 2.
+
+So, opt(i) = Max{opt(i - 1) - prices[i - 1] + prices[i], 0}
+```
+
+
+```python
+class Solution(object):
+ def maxProfit(self, prices):
+ """
+ :type prices: List[int]
+ :rtype: int
+ """
+ if not prices:
+ return 0
+ res, max_cur = 0, 0
+ for i in range(1, len(prices)):
+ max_cur = max(0, max_cur+prices[i]-prices[i-1])
+ res = max(res, max_cur)
+ return res
+```
+
+
diff --git a/docs/leetcode/python/125._valid_palindrome.md b/docs/Leetcode_Solutions/125._valid_palindrome.md
similarity index 100%
rename from docs/leetcode/python/125._valid_palindrome.md
rename to docs/Leetcode_Solutions/125._valid_palindrome.md
diff --git a/docs/leetcode/python/126._Word_Ladder_II.md b/docs/Leetcode_Solutions/126. Word Ladder II.md
similarity index 100%
rename from docs/leetcode/python/126._Word_Ladder_II.md
rename to docs/Leetcode_Solutions/126. Word Ladder II.md
diff --git a/docs/leetcode/python/127._word_ladder.md b/docs/Leetcode_Solutions/127._word_ladder.md
similarity index 100%
rename from docs/leetcode/python/127._word_ladder.md
rename to docs/Leetcode_Solutions/127._word_ladder.md
diff --git a/docs/leetcode/python/128._Longest_Consecutive_Sequence.md b/docs/Leetcode_Solutions/128._Longest_Consecutive_Sequence.md
similarity index 100%
rename from docs/leetcode/python/128._Longest_Consecutive_Sequence.md
rename to docs/Leetcode_Solutions/128._Longest_Consecutive_Sequence.md
diff --git a/docs/leetcode/python/129._sum_root_to_leaf_numbers.md b/docs/Leetcode_Solutions/129._sum_root_to_leaf_numbers.md
similarity index 100%
rename from docs/leetcode/python/129._sum_root_to_leaf_numbers.md
rename to docs/Leetcode_Solutions/129._sum_root_to_leaf_numbers.md
diff --git a/docs/leetcode/python/130._surrounded_regions.md b/docs/Leetcode_Solutions/130._surrounded_regions.md
similarity index 100%
rename from docs/leetcode/python/130._surrounded_regions.md
rename to docs/Leetcode_Solutions/130._surrounded_regions.md
diff --git a/docs/leetcode/python/131._palindrome_partitioning.md b/docs/Leetcode_Solutions/131._palindrome_partitioning.md
similarity index 100%
rename from docs/leetcode/python/131._palindrome_partitioning.md
rename to docs/Leetcode_Solutions/131._palindrome_partitioning.md
diff --git a/docs/leetcode/python/133._clone_graph.md b/docs/Leetcode_Solutions/133._clone_graph.md
similarity index 100%
rename from docs/leetcode/python/133._clone_graph.md
rename to docs/Leetcode_Solutions/133._clone_graph.md
diff --git a/docs/leetcode/python/136._single_number.md b/docs/Leetcode_Solutions/136._single_number.md
similarity index 100%
rename from docs/leetcode/python/136._single_number.md
rename to docs/Leetcode_Solutions/136._single_number.md
diff --git a/docs/Leetcode_Solutions/139._word_break.md b/docs/Leetcode_Solutions/139._word_break.md
new file mode 100644
index 000000000..815737dec
--- /dev/null
+++ b/docs/Leetcode_Solutions/139._word_break.md
@@ -0,0 +1,59 @@
+### 139. Word Break
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+
+```ok[i]``` tells whether ```s[:i]``` can be built.
+
+```python
+class Solution(object):
+ def wordBreak(self, s, wordDict):
+ """
+ :type s: str
+ :type wordDict: List[str]
+ :rtype: bool
+ """
+ ok = [True]
+ for i in range(1, len(s)+1):
+ ok += [any(ok[j] and s[j:i] in wordDict for j in range(i))]
+ return ok[-1]
+```
+
+但是往list里面加数据的方法有快有慢,下面是对比:
+```
+>>> from timeit import timeit
+>>> timeit('x.append(1)', 'x = []', number=10000000)
+1.9880003412529277
+>>> timeit('x += 1,', 'x = []', number=10000000)
+1.2676891852971721
+>>> timeit('x += [1]', 'x = []', number=10000000)
+3.361207239950204
+```
+因此我们可以将代码直接换成下面的格式
+```python
+ok += any(ok[j] and s[j:i] in wordDict for j in range(i)) # 会报错
+```
+但是这样会报错,TypeError: 'bool' object is not iterable,因此bool类型数据不能这样加,别的可以(list类型本身当然要注意哈)
+
+因此在这个例子中我们这样:
+```python
+class Solution(object):
+ def wordBreak(self, s, wordDict):
+ """
+ :type s: str
+ :type wordDict: List[str]
+ :rtype: bool
+ """
+ ok = [True]
+ for i in range(1, len(s)+1):
+ ok += any(ok[j] and s[j:i] in wordDict for j in range(i)),
+ return ok[-1]
+```
+代码里面的那个逗号构建了一个tuple,也会快一点
diff --git a/docs/leetcode/python/140._word_break_ii.md b/docs/Leetcode_Solutions/140._word_break_ii.md
similarity index 100%
rename from docs/leetcode/python/140._word_break_ii.md
rename to docs/Leetcode_Solutions/140._word_break_ii.md
diff --git a/docs/leetcode/python/141._linked_list_cycle.md b/docs/Leetcode_Solutions/141._linked_list_cycle.md
similarity index 95%
rename from docs/leetcode/python/141._linked_list_cycle.md
rename to docs/Leetcode_Solutions/141._linked_list_cycle.md
index 49417387a..2d50901e9 100644
--- a/docs/leetcode/python/141._linked_list_cycle.md
+++ b/docs/Leetcode_Solutions/141._linked_list_cycle.md
@@ -1,105 +1,105 @@
-### 141. Linked List Cycle
-
-题目:
-
-
-
-
-难度:
-
-Easy
-
-
-想法一:
-
-直接超时
-
-```
-class Solution(object):
- def hasCycle(self, head):
- """
- :type head: ListNode
- :rtype: bool
- """
- if head == None: return False
- lst = []
- cur = head
- while cur:
- if cur in lst:
- return True
- lst.append(cur)
- cur = cur.next
- return False
-```
-
-
-
-想法二:相当用boolean array记录某个点是否被访问过,时间,空间复杂度都是O(n)
-
-```
-class Solution(object):
- def hasCycle(self, head):
- """
- :type head: ListNode
- :rtype: bool
- """
- if head == None: return False
- dictx = {}
- cur = head
- while cur:
- if cur in dictx:
- return True
- dictx[cur] = 1
- cur = cur.next
- return False
-```
-
-结果这种方法的run time还比较快
-
-查了一下,有解答说可以有空间复杂度O(1),时间复杂度O(n)。两个指针,一个快一个慢,快的每次走两步,慢的每次走一步,如果有环,最终会在某处相遇。这也是一个算法。这种快慢指针配合已经不是第一次遇到了,比如找linklist中间的node。
-
-
-
-但是并没有觉得这样的算法是O(n), worst case time complexity is O(N+K), which is O(n).
-
-
-```python
-python
-class Solution(object):
- def hasCycle(self, head):
- """
- :type head: ListNode
- :rtype: bool
- """
- slow = head
- fast = head
- while fast and fast.next:
- slow = slow.next
- fast = fast.next.next
- if slow == fast:
- return True
- return False
-```
-
-
-```java
-java
-public class Solution {
- public boolean hasCycle(ListNode head) {
- if (head == null){
- return false;
- }
- ListNode fast = head;
- ListNode slow = head;
- while (fast != null && slow != null && fast.next != null){
- fast = fast.next.next;
- slow = slow.next;
- if (slow == fast){
- return true;
- }
- }
- return false;
- }
-}
-```
-
+### 141. Linked List Cycle
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+想法一:
+
+直接超时
+
+```
+class Solution(object):
+ def hasCycle(self, head):
+ """
+ :type head: ListNode
+ :rtype: bool
+ """
+ if head == None: return False
+ lst = []
+ cur = head
+ while cur:
+ if cur in lst:
+ return True
+ lst.append(cur)
+ cur = cur.next
+ return False
+```
+
+
+
+想法二:相当用boolean array记录某个点是否被访问过,时间,空间复杂度都是O(n)
+
+```
+class Solution(object):
+ def hasCycle(self, head):
+ """
+ :type head: ListNode
+ :rtype: bool
+ """
+ if head == None: return False
+ dictx = {}
+ cur = head
+ while cur:
+ if cur in dictx:
+ return True
+ dictx[cur] = 1
+ cur = cur.next
+ return False
+```
+
+结果这种方法的run time还比较快
+
+查了一下,有解答说可以有空间复杂度O(1),时间复杂度O(n)。两个指针,一个快一个慢,快的每次走两步,慢的每次走一步,如果有环,最终会在某处相遇。这也是一个算法。这种快慢指针配合已经不是第一次遇到了,比如找linklist中间的node。
+
+
+
+但是并没有觉得这样的算法是O(n), worst case time complexity is O(N+K), which is O(n).
+
+
+```python
+python
+class Solution(object):
+ def hasCycle(self, head):
+ """
+ :type head: ListNode
+ :rtype: bool
+ """
+ slow = head
+ fast = head
+ while fast and fast.next:
+ slow = slow.next
+ fast = fast.next.next
+ if slow == fast:
+ return True
+ return False
+```
+
+
+```java
+java
+public class Solution {
+ public boolean hasCycle(ListNode head) {
+ if (head == null){
+ return false;
+ }
+ ListNode fast = head;
+ ListNode slow = head;
+ while (fast != null && slow != null && fast.next != null){
+ fast = fast.next.next;
+ slow = slow.next;
+ if (slow == fast){
+ return true;
+ }
+ }
+ return false;
+ }
+}
+```
+
diff --git a/docs/leetcode/python/142_Linked_List_Cycle_II.md b/docs/Leetcode_Solutions/142_Linked_List_Cycle_II.md
similarity index 100%
rename from docs/leetcode/python/142_Linked_List_Cycle_II.md
rename to docs/Leetcode_Solutions/142_Linked_List_Cycle_II.md
diff --git a/docs/leetcode/python/143._reorder_list.md b/docs/Leetcode_Solutions/143._reorder_list.md
similarity index 100%
rename from docs/leetcode/python/143._reorder_list.md
rename to docs/Leetcode_Solutions/143._reorder_list.md
diff --git a/docs/leetcode/python/144._binary_tree_preorder_traversal.md b/docs/Leetcode_Solutions/144._binary_tree_preorder_traversal.md
similarity index 54%
rename from docs/leetcode/python/144._binary_tree_preorder_traversal.md
rename to docs/Leetcode_Solutions/144._binary_tree_preorder_traversal.md
index 8dd38e7fe..8f5e21689 100644
--- a/docs/leetcode/python/144._binary_tree_preorder_traversal.md
+++ b/docs/Leetcode_Solutions/144._binary_tree_preorder_traversal.md
@@ -1,35 +1,15 @@
-# 144. Binary Tree Preorder Traversal
-**难度: 中等 **
+### 144. Binary Tree Preorder Traversal
-## 刷题内容
+题目:
-> 原题连接
+
-* https://leetcode.com/problems/binary-tree-preorder-traversal
-> 内容描述
+难度:
-```
-Given a binary tree, return the preorder traversal of its nodes' values.
-
-Example:
-
-Input: [1,null,2,3]
- 1
- \
- 2
- /
- 3
-
-Output: [1,2,3]
-Follow up: Recursive solution is trivial, could you do it iteratively?
-```
-
-## 解题方案
-
-> 思路 1
+Medium
-Recursive递归,瞬秒
+Recursive,瞬秒
```python
@@ -50,10 +30,6 @@ class Solution(object):
return res
```
-> 思路 2
-
-或者我们可以先写一下先序遍历的函数,然后一个一个贴上去
-
```python
class Solution(object):
def preorderTraversal(self, root):
@@ -77,7 +53,7 @@ class Solution(object):
```
-Iterative, 迭代
+Iterative
```python
@@ -87,18 +63,19 @@ class Solution(object):
:type root: TreeNode
:rtype: List[int]
"""
+ if root == None:
+ return []
res = []
- if not root:
- return res
- stack = []
- stack.append(root)
-
- while(len(stack) > 0):
- node = stack.pop()
- res.append(node.val)
- if node.right:
- stack.append(node.right)
- if node.left:
- stack.append(node.left)
+
+ stack = []
+ stack.append(root)
+ while stack:
+ node = stack.pop()
+ res.append(node.val)
+ if node.right:
+ stack.append(node.right)
+ if node.left:
+ stack.append(node.left)
return res
+
```
diff --git a/docs/Leetcode_Solutions/145._binary_tree_postorder_traversal.md b/docs/Leetcode_Solutions/145._binary_tree_postorder_traversal.md
new file mode 100644
index 000000000..788cfc623
--- /dev/null
+++ b/docs/Leetcode_Solutions/145._binary_tree_postorder_traversal.md
@@ -0,0 +1,67 @@
+###145. Binary Tree Postorder Traversal
+
+题目:
+
+
+
+
+难度:
+
+Hard
+
+wikipedia 助你幸福
+
+递归版本
+
+```
+postorder(node)
+ if (node = null)
+ return
+ postorder(node.left)
+ postorder(node.right)
+ visit(node)
+```
+
+
+迭代版本
+
+```
+iterativePostorder(node)
+ s ← empty stack
+ lastNodeVisited ← null
+ while (not s.isEmpty() or node ≠ null)
+ if (node ≠ null)
+ s.push(node)
+ node ← node.left
+ else
+ peekNode ← s.peek()
+ // if right child exists and traversing node
+ // from left child, then move right
+ if (peekNode.right ≠ null and lastNodeVisited ≠ peekNode.right)
+ node ← peekNode.right
+ else
+ visit(peekNode)
+ lastNodeVisited ← s.pop()
+```
+
+
+
+刷进度直接用递归AC
+
+```
+class Solution(object):
+ def postorderTraversal(self, root):
+ """
+ :type root: TreeNode
+ :rtype: List[int]
+ """
+ self.result = []
+ self.postOrder(root)
+ return self.result
+
+ def postOrder(self, root):
+ if root == None : return
+ self.postOrder(root.left)
+ self.postOrder(root.right)
+ self.result.append(root.val)
+```
\ No newline at end of file
diff --git a/docs/leetcode/python/147._insertion_sort_list.md b/docs/Leetcode_Solutions/147._insertion_sort_list.md
similarity index 100%
rename from docs/leetcode/python/147._insertion_sort_list.md
rename to docs/Leetcode_Solutions/147._insertion_sort_list.md
diff --git a/docs/leetcode/python/148._sort_list.md b/docs/Leetcode_Solutions/148._sort_list.md
similarity index 100%
rename from docs/leetcode/python/148._sort_list.md
rename to docs/Leetcode_Solutions/148._sort_list.md
diff --git a/docs/leetcode/python/150._evaluate_reverse_polish_notation.md b/docs/Leetcode_Solutions/150._evaluate_reverse_polish_notation.md
similarity index 100%
rename from docs/leetcode/python/150._evaluate_reverse_polish_notation.md
rename to docs/Leetcode_Solutions/150._evaluate_reverse_polish_notation.md
diff --git a/docs/leetcode/python/151._reverse_words_in_a_string.md b/docs/Leetcode_Solutions/151._reverse_words_in_a_string.md
similarity index 100%
rename from docs/leetcode/python/151._reverse_words_in_a_string.md
rename to docs/Leetcode_Solutions/151._reverse_words_in_a_string.md
diff --git a/docs/leetcode/python/152._maximum_product_subarray.md b/docs/Leetcode_Solutions/152._maximum_product_subarray.md
similarity index 100%
rename from docs/leetcode/python/152._maximum_product_subarray.md
rename to docs/Leetcode_Solutions/152._maximum_product_subarray.md
diff --git a/docs/leetcode/python/153._find_minimum_in_rotated_sorted_array.md b/docs/Leetcode_Solutions/153._find_minimum_in_rotated_sorted_array.md
similarity index 100%
rename from docs/leetcode/python/153._find_minimum_in_rotated_sorted_array.md
rename to docs/Leetcode_Solutions/153._find_minimum_in_rotated_sorted_array.md
diff --git a/docs/leetcode/python/155._min_stack.md b/docs/Leetcode_Solutions/155._min_stack.md
similarity index 100%
rename from docs/leetcode/python/155._min_stack.md
rename to docs/Leetcode_Solutions/155._min_stack.md
diff --git a/docs/leetcode/python/159._Longest_Substring_with_At_Most_Two_Distinct_Characters.md b/docs/Leetcode_Solutions/159._Longest_Substring_with_At_Most_Two_Distinct_Characters.md
similarity index 100%
rename from docs/leetcode/python/159._Longest_Substring_with_At_Most_Two_Distinct_Characters.md
rename to docs/Leetcode_Solutions/159._Longest_Substring_with_At_Most_Two_Distinct_Characters.md
diff --git a/docs/leetcode/python/160._intersection_of_two_linked_lists.md b/docs/Leetcode_Solutions/160._intersection_of_two_linked_lists.md
similarity index 100%
rename from docs/leetcode/python/160._intersection_of_two_linked_lists.md
rename to docs/Leetcode_Solutions/160._intersection_of_two_linked_lists.md
diff --git a/docs/leetcode/python/162._find_peak_element.md b/docs/Leetcode_Solutions/162._find_peak_element.md
similarity index 100%
rename from docs/leetcode/python/162._find_peak_element.md
rename to docs/Leetcode_Solutions/162._find_peak_element.md
diff --git a/docs/leetcode/python/165._compare_version_numbers.md b/docs/Leetcode_Solutions/165._compare_version_numbers.md
similarity index 100%
rename from docs/leetcode/python/165._compare_version_numbers.md
rename to docs/Leetcode_Solutions/165._compare_version_numbers.md
diff --git a/docs/leetcode/python/166._Fraction_to_Recurring_Decimal.md b/docs/Leetcode_Solutions/166._Fraction_to_Recurring_Decimal.md
similarity index 100%
rename from docs/leetcode/python/166._Fraction_to_Recurring_Decimal.md
rename to docs/Leetcode_Solutions/166._Fraction_to_Recurring_Decimal.md
diff --git a/docs/leetcode/python/167._two_sum_ii_-_input_array_is_sorted.md b/docs/Leetcode_Solutions/167._two_sum_ii_-_input_array_is_sorted.md
similarity index 100%
rename from docs/leetcode/python/167._two_sum_ii_-_input_array_is_sorted.md
rename to docs/Leetcode_Solutions/167._two_sum_ii_-_input_array_is_sorted.md
diff --git a/docs/leetcode/python/168._excel_sheet_column_title.md b/docs/Leetcode_Solutions/168._excel_sheet_column_title.md
similarity index 97%
rename from docs/leetcode/python/168._excel_sheet_column_title.md
rename to docs/Leetcode_Solutions/168._excel_sheet_column_title.md
index 1746fa858..547f083ee 100644
--- a/docs/leetcode/python/168._excel_sheet_column_title.md
+++ b/docs/Leetcode_Solutions/168._excel_sheet_column_title.md
@@ -12,17 +12,17 @@ Easy
依旧26进制的反击,不过这个反击我做的没之前那个好,看了hint
```
-class Solution(object):
- def convertToTitle(self, n):
- """
- :type n: int
- :rtype: str
- """
- ans = ''
- while n :
- ans = chr(ord('A') + (n - 1) % 26) + ans
- n = (n - 1) // 26
- return ans
+class Solution(object):
+ def convertToTitle(self, n):
+ """
+ :type n: int
+ :rtype: str
+ """
+ ans = ''
+ while n :
+ ans = chr(ord('A') + (n - 1) % 26) + ans
+ n = (n - 1) // 26
+ return ans
```
diff --git a/docs/leetcode/python/169._majority_element.md b/docs/Leetcode_Solutions/169._majority_element.md
similarity index 100%
rename from docs/leetcode/python/169._majority_element.md
rename to docs/Leetcode_Solutions/169._majority_element.md
diff --git a/docs/leetcode/python/171._excel_sheet_column_number.md b/docs/Leetcode_Solutions/171._excel_sheet_column_number.md
similarity index 97%
rename from docs/leetcode/python/171._excel_sheet_column_number.md
rename to docs/Leetcode_Solutions/171._excel_sheet_column_number.md
index 0a92b3808..4521f737c 100644
--- a/docs/leetcode/python/171._excel_sheet_column_number.md
+++ b/docs/Leetcode_Solutions/171._excel_sheet_column_number.md
@@ -13,22 +13,22 @@ Easy
26进制的反击
```
-class Solution(object):
- def titleToNumber(self, s):
- """
- :type s: str
- :rtype: int
- """
- maps = {}
- for i in range(65,91):
- maps[chr(i)] = i - 64
-
- lst = list(s)
- lst.reverse()
- num = 0
- for idx,item in enumerate(lst):
- num += maps[item] * (26 ** idx)
- return num
+class Solution(object):
+ def titleToNumber(self, s):
+ """
+ :type s: str
+ :rtype: int
+ """
+ maps = {}
+ for i in range(65,91):
+ maps[chr(i)] = i - 64
+
+ lst = list(s)
+ lst.reverse()
+ num = 0
+ for idx,item in enumerate(lst):
+ num += maps[item] * (26 ** idx)
+ return num
```
diff --git a/docs/leetcode/python/173._binary_search_tree_iterator.md b/docs/Leetcode_Solutions/173._binary_search_tree_iterator.md
similarity index 100%
rename from docs/leetcode/python/173._binary_search_tree_iterator.md
rename to docs/Leetcode_Solutions/173._binary_search_tree_iterator.md
diff --git a/docs/Leetcode_Solutions/189._rotate_array.md b/docs/Leetcode_Solutions/189._rotate_array.md
new file mode 100644
index 000000000..080a1e581
--- /dev/null
+++ b/docs/Leetcode_Solutions/189._rotate_array.md
@@ -0,0 +1,23 @@
+###189. Rotate Array
+
+题目:
+
+
+
+难度 : Easy
+
+
+作弊神奇python大法
+
+```
+class Solution(object):
+ def rotate(self, nums, k):
+ """
+ :type nums: List[int]
+ :type k: int
+ :rtype: void Do not return anything, modify nums in-place instead.
+ """
+ n = len(nums)
+ nums[:] = nums[n-k:] + nums[:n-k]
+ œ
+```
diff --git a/docs/leetcode/python/191._number_of_1_bits.md b/docs/Leetcode_Solutions/191._number_of_1_bits.md
similarity index 100%
rename from docs/leetcode/python/191._number_of_1_bits.md
rename to docs/Leetcode_Solutions/191._number_of_1_bits.md
diff --git a/docs/leetcode/python/198._house_robber.md b/docs/Leetcode_Solutions/198._house_robber.md
similarity index 100%
rename from docs/leetcode/python/198._house_robber.md
rename to docs/Leetcode_Solutions/198._house_robber.md
diff --git a/docs/leetcode/python/199._binary_tree_right_side_view.md b/docs/Leetcode_Solutions/199._binary_tree_right_side_view.md
similarity index 100%
rename from docs/leetcode/python/199._binary_tree_right_side_view.md
rename to docs/Leetcode_Solutions/199._binary_tree_right_side_view.md
diff --git a/docs/leetcode/python/200._number_of_islands.md b/docs/Leetcode_Solutions/200._number_of_islands.md
similarity index 100%
rename from docs/leetcode/python/200._number_of_islands.md
rename to docs/Leetcode_Solutions/200._number_of_islands.md
diff --git a/docs/leetcode/python/203._remove_linked_list_elements.md b/docs/Leetcode_Solutions/203._remove_linked_list_elements.md
similarity index 96%
rename from docs/leetcode/python/203._remove_linked_list_elements.md
rename to docs/Leetcode_Solutions/203._remove_linked_list_elements.md
index 7dcb32ee2..15aa10efa 100644
--- a/docs/leetcode/python/203._remove_linked_list_elements.md
+++ b/docs/Leetcode_Solutions/203._remove_linked_list_elements.md
@@ -13,26 +13,26 @@ AC代码如下:
-```
-class Solution(object):
- def removeElements(self, head, val):
- """
- :type head: ListNode
- :type val: int
- :rtype: ListNode
- """
- dummy = ListNode(-1)
- dummy.next = head
-
- cur = dummy
-
- while cur.next:
- if cur.next.val == val:
- cur.next = cur.next.next
- else:
- cur = cur.next
-
- return dummy.next
+```
+class Solution(object):
+ def removeElements(self, head, val):
+ """
+ :type head: ListNode
+ :type val: int
+ :rtype: ListNode
+ """
+ dummy = ListNode(-1)
+ dummy.next = head
+
+ cur = dummy
+
+ while cur.next:
+ if cur.next.val == val:
+ cur.next = cur.next.next
+ else:
+ cur = cur.next
+
+ return dummy.next
```
\ No newline at end of file
diff --git a/docs/leetcode/python/204._count_primes.md b/docs/Leetcode_Solutions/204._count_primes.md
similarity index 100%
rename from docs/leetcode/python/204._count_primes.md
rename to docs/Leetcode_Solutions/204._count_primes.md
diff --git a/docs/leetcode/python/205._isomorphic_strings.md b/docs/Leetcode_Solutions/205._isomorphic_strings.md
similarity index 97%
rename from docs/leetcode/python/205._isomorphic_strings.md
rename to docs/Leetcode_Solutions/205._isomorphic_strings.md
index 9e4b6f178..47b0ab772 100644
--- a/docs/leetcode/python/205._isomorphic_strings.md
+++ b/docs/Leetcode_Solutions/205._isomorphic_strings.md
@@ -10,29 +10,29 @@
AC之法,用dictionary,因为限制,所以确保s 和 t 是isomorphic 同时 t 和 s 是
-```
-class Solution(object):
- def isIsomorphic(self, s, t):
- """
- :type s: str
- :type t: str
- :rtype: bool
- """
+```
+class Solution(object):
+ def isIsomorphic(self, s, t):
+ """
+ :type s: str
+ :type t: str
+ :rtype: bool
+ """
return self.iso(s,t) and self.iso(t,s)
-
- def iso(self,s, t):
- """
- :type s: str
- :type t: str
- :rtype: bool
- """
- mapx = {}
- for i in range(len(s)):
- if s[i] not in mapx:
- mapx[s[i]] = t[i]
- elif s[i] in mapx:
- if t[i] != mapx[s[i]]:
- return False
+
+ def iso(self,s, t):
+ """
+ :type s: str
+ :type t: str
+ :rtype: bool
+ """
+ mapx = {}
+ for i in range(len(s)):
+ if s[i] not in mapx:
+ mapx[s[i]] = t[i]
+ elif s[i] in mapx:
+ if t[i] != mapx[s[i]]:
+ return False
return True
diff --git a/docs/leetcode/python/206._reverse_linked_list.md b/docs/Leetcode_Solutions/206._reverse_linked_list.md
similarity index 69%
rename from docs/leetcode/python/206._reverse_linked_list.md
rename to docs/Leetcode_Solutions/206._reverse_linked_list.md
index 97c10db26..485a55e05 100644
--- a/docs/leetcode/python/206._reverse_linked_list.md
+++ b/docs/Leetcode_Solutions/206._reverse_linked_list.md
@@ -28,25 +28,7 @@ class Solution(object):
cur = nxt
return prev
```
-其实一个指针就够了
-```python
-class Solution(object):
- def reverseList(self, head):
- """
- :type head: ListNode
- :rtype: ListNode
- """
- if not head:
- return head
- prev = None
- while head.next:
- tmp = head.next
- head.next = prev
- prev = head
- head = tmp
- head.next = prev
- return head
-```
+
递归版本,可以再消化一下.
diff --git a/docs/leetcode/python/207._course_schedule.md b/docs/Leetcode_Solutions/207._course_schedule.md
similarity index 100%
rename from docs/leetcode/python/207._course_schedule.md
rename to docs/Leetcode_Solutions/207._course_schedule.md
diff --git a/docs/leetcode/python/208._implement_trie_(prefix_tree).md b/docs/Leetcode_Solutions/208._implement_trie_(prefix_tree).md
similarity index 95%
rename from docs/leetcode/python/208._implement_trie_(prefix_tree).md
rename to docs/Leetcode_Solutions/208._implement_trie_(prefix_tree).md
index a828b2fd5..8ee06db58 100644
--- a/docs/leetcode/python/208._implement_trie_(prefix_tree).md
+++ b/docs/Leetcode_Solutions/208._implement_trie_(prefix_tree).md
@@ -1,89 +1,89 @@
-### 208. Implement Trie (Prefix Tree)
-
-题目:
-
-
-
-
-难度:
-
-Medium
-
-这个Python实现也太精美了吧,谷歌复写之
-
-然后还unlock了一个solution,to read
-
-Trie整个都需要 to read,精美,可爱😊
-
-
-
-
-```python
-class TrieNode(object):
- def __init__(self):
- """
- Initialize your data structure here.
- """
- self.childs = dict()
- self.isWord = False
-
-
-
-class Trie(object):
-
- def __init__(self):
- self.root = TrieNode()
-
- def insert(self, word):
- """
- Inserts a word into the trie.
- :type word: str
- :rtype: void
- """
- node = self.root
- for letter in word:
- child = node.childs.get(letter)
- if child is None:
- child = TrieNode()
- node.childs[letter] = child
- node = child
- node.isWord = True
-
- def search(self, word):
- """
- Returns if the word is in the trie.
- :type word: str
- :rtype: bool
- """
- node = self.root
- for i in word:
- child = node.childs.get(i)
- if child is None:
- return False
- node = child
- return node.isWord
-
-
- def startsWith(self, prefix):
- """
- Returns if there is any word in the trie
- that starts with the given prefix.
- :type prefix: str
- :rtype: bool
- """
- node = self.root
- for letter in prefix:
- child = node.childs.get(letter)
- if child is None:
- return False
- node = child
- return True
-
-
-# Your Trie object will be instantiated and called as such:
-# trie = Trie()
-# trie.insert("somestring")
-# trie.search("key")
-
-```
-
+### 208. Implement Trie (Prefix Tree)
+
+题目:
+
+
+
+
+难度:
+
+Medium
+
+这个Python实现也太精美了吧,谷歌复写之
+
+然后还unlock了一个solution,to read
+
+Trie整个都需要 to read,精美,可爱😊
+
+
+
+
+```python
+class TrieNode(object):
+ def __init__(self):
+ """
+ Initialize your data structure here.
+ """
+ self.childs = dict()
+ self.isWord = False
+
+
+
+class Trie(object):
+
+ def __init__(self):
+ self.root = TrieNode()
+
+ def insert(self, word):
+ """
+ Inserts a word into the trie.
+ :type word: str
+ :rtype: void
+ """
+ node = self.root
+ for letter in word:
+ child = node.childs.get(letter)
+ if child is None:
+ child = TrieNode()
+ node.childs[letter] = child
+ node = child
+ node.isWord = True
+
+ def search(self, word):
+ """
+ Returns if the word is in the trie.
+ :type word: str
+ :rtype: bool
+ """
+ node = self.root
+ for i in word:
+ child = node.childs.get(i)
+ if child is None:
+ return False
+ node = child
+ return node.isWord
+
+
+ def startsWith(self, prefix):
+ """
+ Returns if there is any word in the trie
+ that starts with the given prefix.
+ :type prefix: str
+ :rtype: bool
+ """
+ node = self.root
+ for letter in prefix:
+ child = node.childs.get(letter)
+ if child is None:
+ return False
+ node = child
+ return True
+
+
+# Your Trie object will be instantiated and called as such:
+# trie = Trie()
+# trie.insert("somestring")
+# trie.search("key")
+
+```
+
diff --git a/docs/leetcode/python/210._course_schedule_ii.md b/docs/Leetcode_Solutions/210._course_schedule_ii.md
similarity index 100%
rename from docs/leetcode/python/210._course_schedule_ii.md
rename to docs/Leetcode_Solutions/210._course_schedule_ii.md
diff --git a/docs/leetcode/python/211._Add_and_Search_Word_-_Data_structure_design.md b/docs/Leetcode_Solutions/211. Add and Search Word - Data structure design.md
similarity index 100%
rename from docs/leetcode/python/211._Add_and_Search_Word_-_Data_structure_design.md
rename to docs/Leetcode_Solutions/211. Add and Search Word - Data structure design.md
diff --git a/docs/leetcode/python/213._house_robber_ii.md b/docs/Leetcode_Solutions/213._house_robber_ii.md
similarity index 100%
rename from docs/leetcode/python/213._house_robber_ii.md
rename to docs/Leetcode_Solutions/213._house_robber_ii.md
diff --git a/docs/leetcode/python/216._combination_sum_iii.md b/docs/Leetcode_Solutions/216._combination_sum_iii.md
similarity index 100%
rename from docs/leetcode/python/216._combination_sum_iii.md
rename to docs/Leetcode_Solutions/216._combination_sum_iii.md
diff --git a/docs/Leetcode_Solutions/217._contains_duplicate.md b/docs/Leetcode_Solutions/217._contains_duplicate.md
new file mode 100644
index 000000000..f6c2a2aef
--- /dev/null
+++ b/docs/Leetcode_Solutions/217._contains_duplicate.md
@@ -0,0 +1,62 @@
+###217. Contains Duplicate
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+我直接sort,然后比较相邻的元素,这样O(n),也是笨办法,居然unlocked a solution,所以来读读解答.
+
+三个办法:
+
+- linear search O(n^2)
+- sort O(n)
+- hashtable
+
+
+我用的sort
+
+```
+class Solution(object):
+ def containsDuplicate(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: bool
+ """
+ nums.sort()
+ for i in range(len(nums)-1):
+ if nums[i] == nums[i+1]:
+ return True
+ return False
+```
+
+
+
+
+看给的Java解法
+
+
+```
+public boolean containsDuplicate(int[] nums) {
+ Set set = new HashSet<>(nums.length);
+ for (int x: nums) {
+ if (set.contains(x)) return true;
+ set.add(x);
+ }
+ return false;
+}
+```
+
+还有一个取巧的Python解法,我也看到了
+
+```
+class Solution(object):
+ def containsDuplicate(self, nums):
+ if len(nums) > len(set(nums)):
+ return True
+ return False
+```
\ No newline at end of file
diff --git a/docs/leetcode/python/218._The_Skyline_Problem.md b/docs/Leetcode_Solutions/218._The _Skyline_Problem .md
similarity index 98%
rename from docs/leetcode/python/218._The_Skyline_Problem.md
rename to docs/Leetcode_Solutions/218._The _Skyline_Problem .md
index e11d460f8..34d9c9176 100644
--- a/docs/leetcode/python/218._The_Skyline_Problem.md
+++ b/docs/Leetcode_Solutions/218._The _Skyline_Problem .md
@@ -131,4 +131,4 @@ Author: Keqi Huang
If you like it, please spread your support
-
+
diff --git a/docs/Leetcode_Solutions/219._contains_duplicate_ii.md b/docs/Leetcode_Solutions/219._contains_duplicate_ii.md
new file mode 100644
index 000000000..8c5868c6f
--- /dev/null
+++ b/docs/Leetcode_Solutions/219._contains_duplicate_ii.md
@@ -0,0 +1,35 @@
+###219. Contains Duplicate II
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+经过了Contains Duplicate的考验,用hash table(也叫dictionary)来存,这个元素还没出现过,就放hash table,如果出现了,计算相邻距离,小于等于k则return true,否则更新hash table中元素的位置,
+
+
+我用的sort
+
+```
+class Solution(object):
+ def containsNearbyDuplicate(self, nums, k):
+ """
+ :type nums: List[int]
+ :type k: int
+ :rtype: bool
+ """
+ if len(nums) < 2 : return False
+ lookup = {}
+ for i in range(len(nums)):
+ if nums[i] not in lookup:
+ lookup[nums[i]] = i
+ else:
+ if i - lookup[nums[i]] <= k :
+ return True
+ lookup[nums[i]] = i
+ return False
+```
\ No newline at end of file
diff --git a/docs/leetcode/python/221._maximal_square.md b/docs/Leetcode_Solutions/221._maximal_square.md
similarity index 100%
rename from docs/leetcode/python/221._maximal_square.md
rename to docs/Leetcode_Solutions/221._maximal_square.md
diff --git a/docs/leetcode/python/222._count_complete_tree_nodes.md b/docs/Leetcode_Solutions/222._count_complete_tree_nodes.md
similarity index 100%
rename from docs/leetcode/python/222._count_complete_tree_nodes.md
rename to docs/Leetcode_Solutions/222._count_complete_tree_nodes.md
diff --git a/docs/Leetcode_Solutions/223._rectangle_area.md b/docs/Leetcode_Solutions/223._rectangle_area.md
new file mode 100644
index 000000000..3edba1bc3
--- /dev/null
+++ b/docs/Leetcode_Solutions/223._rectangle_area.md
@@ -0,0 +1,50 @@
+###223. Rectangle Area
+
+题目:
+
+
+
+难度 : Easy
+
+
+这道题是我瞎了狗眼,🐶,之前看错了,以为要求相交的部分,结果是求cover的部分,所以写的长||||||
+
+
+```
+class Solution(object):
+ def computeArea(self, A, B, C, D, E, F, G, H):
+ """
+ :type A: int
+ :type B: int
+ :type C: int
+ :type D: int
+ :type E: int
+ :type F: int
+ :type G: int
+ :type H: int
+ :rtype: int
+ """
+ return self.area(C - A, D - B) + self.area(H - F, G - E ) - self.area(self.interSect(A,C,E,G), self.interSect(B,D,F,H))
+
+ def area(self, w, h):
+ if w * h < 0:
+ return - w * h
+ return w * h
+
+
+ def interSect(self, A, C, E, G):
+ if E > C:
+ return 0
+ elif G < A:
+ return 0
+ elif E >= A and G <= C:
+ return G - E
+ elif A >= E and C <= G:
+ return C - A
+ elif G <= C and G >= A and E <= A:
+ return G - A
+ else:
+ return C - E
+
+
+```
diff --git a/docs/leetcode/python/224._Basic_Calculator.md b/docs/Leetcode_Solutions/224. Basic Calculator .md
similarity index 100%
rename from docs/leetcode/python/224._Basic_Calculator.md
rename to docs/Leetcode_Solutions/224. Basic Calculator .md
diff --git a/docs/leetcode/python/225._implement_stack_using_queues.md b/docs/Leetcode_Solutions/225._implement_stack_using_queues.md
similarity index 99%
rename from docs/leetcode/python/225._implement_stack_using_queues.md
rename to docs/Leetcode_Solutions/225._implement_stack_using_queues.md
index 9f61d9722..10a1ac200 100644
--- a/docs/leetcode/python/225._implement_stack_using_queues.md
+++ b/docs/Leetcode_Solutions/225._implement_stack_using_queues.md
@@ -13,7 +13,7 @@ Easy
又到了作弊神预言Python的强项
-```
+```
class Stack(object):
def __init__(self):
"""
diff --git a/docs/Leetcode_Solutions/226._invert_binary_tree.md b/docs/Leetcode_Solutions/226._invert_binary_tree.md
new file mode 100644
index 000000000..b66918814
--- /dev/null
+++ b/docs/Leetcode_Solutions/226._invert_binary_tree.md
@@ -0,0 +1,33 @@
+###226. Invert Binary Tree
+
+题目:
+
+
+
+难度:
+
+Easy
+
+然后查了一下,有更简单的写法
+
+
+```
+
+class Solution(object):
+ def invertTree(self, root):
+ """
+ :type root: TreeNode
+ :rtype: TreeNode
+ """
+ if root == None: return None
+ elif root.left == None and root.right == None: return root
+ else:
+ leftNode = root.left
+ rightNode = root.right
+ root.right = leftNode
+ root.left = rightNode
+ self.invertTree(root.left)
+ self.invertTree(root.right)
+ return root
+```
+
diff --git a/docs/leetcode/python/227._basic_calculator_ii.md b/docs/Leetcode_Solutions/227._basic_calculator_ii.md
similarity index 100%
rename from docs/leetcode/python/227._basic_calculator_ii.md
rename to docs/Leetcode_Solutions/227._basic_calculator_ii.md
diff --git a/docs/leetcode/python/228._summary_ranges.md b/docs/Leetcode_Solutions/228._summary_ranges.md
similarity index 96%
rename from docs/leetcode/python/228._summary_ranges.md
rename to docs/Leetcode_Solutions/228._summary_ranges.md
index 27486605e..ce9dce0f9 100644
--- a/docs/leetcode/python/228._summary_ranges.md
+++ b/docs/Leetcode_Solutions/228._summary_ranges.md
@@ -1,58 +1,58 @@
-### 228. Summary Ranges
-
-题目:
-
-
-
-难度:
-
-Medium
-
-
-Just collect the ranges, then format and return them.
-
-```python
-class Solution(object):
- def summaryRanges(self, nums):
- """
- :type nums: List[int]
- :rtype: List[str]
- """
- ranges = []
- for i in nums:
- if not ranges or i > ranges[-1][-1] + 1:
- ranges += [],
- ranges[-1][1:] = i,
- return ['->'.join(map(str, r)) for r in ranges]
-```
-About the commas :-)
-
-```
-ranges += [],
-r[1:] = n,
-```
-Why the trailing commas? Because it turns the right hand side into a tuple and I get the same effects as these more common alternatives:
-```
-ranges += [[]]
-or
-ranges.append([])
-
-r[1:] = [n]
-```
-Without the comma, …
-
-- ranges += [] wouldn’t add [] itself but only its elements, i.e., nothing.
-- r[1:] = n wouldn’t work, because my n is not an iterable.
-
-Why do it this way instead of the more common alternatives I showed above? Because it’s shorter and faster (according to tests I did a while back).
-
-写到这里可能又有疑问了🤔️,为什么不可以直接写```ranges[-1][1] = i```呢,当然是会报```IndexError: list assignment index out of range```错误啦,那为什么```ranges[-1][1:] = i,```可以呢?
-
-简单来说
-
-L1=L 与 L1=L[:]
-- L1和L 都是对同一个对象的引用(所谓绑定的意思)。
-- L[:] 是生成了一个和L不同的新的对象,L1 变为了L[:] 这个对象的引用。
-
-
-参考[stefan](https://leetcode.com/problems/summary-ranges/discuss/63193)
+### 228. Summary Ranges
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+Just collect the ranges, then format and return them.
+
+```python
+class Solution(object):
+ def summaryRanges(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[str]
+ """
+ ranges = []
+ for i in nums:
+ if not ranges or i > ranges[-1][-1] + 1:
+ ranges += [],
+ ranges[-1][1:] = i,
+ return ['->'.join(map(str, r)) for r in ranges]
+```
+About the commas :-)
+
+```
+ranges += [],
+r[1:] = n,
+```
+Why the trailing commas? Because it turns the right hand side into a tuple and I get the same effects as these more common alternatives:
+```
+ranges += [[]]
+or
+ranges.append([])
+
+r[1:] = [n]
+```
+Without the comma, …
+
+- ranges += [] wouldn’t add [] itself but only its elements, i.e., nothing.
+- r[1:] = n wouldn’t work, because my n is not an iterable.
+
+Why do it this way instead of the more common alternatives I showed above? Because it’s shorter and faster (according to tests I did a while back).
+
+写到这里可能又有疑问了🤔️,为什么不可以直接写```ranges[-1][1] = i```呢,当然是会报```IndexError: list assignment index out of range```错误啦,那为什么```ranges[-1][1:] = i,```可以呢?
+
+简单来说
+
+L1=L 与 L1=L[:]
+- L1和L 都是对同一个对象的引用(所谓绑定的意思)。
+- L[:] 是生成了一个和L不同的新的对象,L1 变为了L[:] 这个对象的引用。
+
+
+参考[stefan](https://leetcode.com/problems/summary-ranges/discuss/63193)
diff --git a/docs/leetcode/python/229._majority_element_ii.md b/docs/Leetcode_Solutions/229._majority_element_ii.md
similarity index 100%
rename from docs/leetcode/python/229._majority_element_ii.md
rename to docs/Leetcode_Solutions/229._majority_element_ii.md
diff --git a/docs/leetcode/python/230._kth_smallest_element_in_a_bst.md b/docs/Leetcode_Solutions/230._kth_smallest_element_in_a_bst.md
similarity index 96%
rename from docs/leetcode/python/230._kth_smallest_element_in_a_bst.md
rename to docs/Leetcode_Solutions/230._kth_smallest_element_in_a_bst.md
index 0746ef6ca..b51fc7a07 100644
--- a/docs/leetcode/python/230._kth_smallest_element_in_a_bst.md
+++ b/docs/Leetcode_Solutions/230._kth_smallest_element_in_a_bst.md
@@ -1,48 +1,48 @@
-### 230. Kth Smallest Element in a BST
-
-题目:
-
-
-
-难度:
-Medium
-
-
-跟昨天做的一道题类似,一上来就走取巧之路。
-
-InOrder排序,输出,当然也完全可以用昨天的binary tree iterator,入stack,出stack,直到输出第k位
-
-
-```python
-class Solution(object):
- def kthSmallest(self, root, k):
- """
- :type root: TreeNode
- :type k: int
- :rtype: int
- """
- self.root = root
- self.lst = []
- self.inOrder(root)
- return self.lst[k-1]
-
- def inOrder(self, root):
- if root == None:
- return
- self.inOrder(root.left)
- self.lst.append(root.val)
- self.inOrder(root.right)
-```
-
-
-现在看到kth 就条件反射的想用divide & conquer, 扫root的左子树看nodes量,如果nodes数量是k-1,那么node就刚好是第k个,如果大于k > 左子树数量,扫右子树,同时更新root为root.right。
-
-看到的言论:
-
-> If we can change the BST node structure, We can add a new Integer to mark the number of element in the left sub-tree.
-
-when the node is not null.
-
-- if k == node.leftNum + 1, return node
-- if k > node.leftNum + 1, make k -= node.leftNum + 1, and then node = node.right
-- otherwise, node = node.left
+### 230. Kth Smallest Element in a BST
+
+题目:
+
+
+
+难度:
+Medium
+
+
+跟昨天做的一道题类似,一上来就走取巧之路。
+
+InOrder排序,输出,当然也完全可以用昨天的binary tree iterator,入stack,出stack,直到输出第k位
+
+
+```python
+class Solution(object):
+ def kthSmallest(self, root, k):
+ """
+ :type root: TreeNode
+ :type k: int
+ :rtype: int
+ """
+ self.root = root
+ self.lst = []
+ self.inOrder(root)
+ return self.lst[k-1]
+
+ def inOrder(self, root):
+ if root == None:
+ return
+ self.inOrder(root.left)
+ self.lst.append(root.val)
+ self.inOrder(root.right)
+```
+
+
+现在看到kth 就条件反射的想用divide & conquer, 扫root的左子树看nodes量,如果nodes数量是k-1,那么node就刚好是第k个,如果大于k > 左子树数量,扫右子树,同时更新root为root.right。
+
+看到的言论:
+
+> If we can change the BST node structure, We can add a new Integer to mark the number of element in the left sub-tree.
+
+when the node is not null.
+
+- if k == node.leftNum + 1, return node
+- if k > node.leftNum + 1, make k -= node.leftNum + 1, and then node = node.right
+- otherwise, node = node.left
diff --git a/docs/leetcode/python/231._Power_of_Two.md b/docs/Leetcode_Solutions/231. _Power_of_Two.md
similarity index 100%
rename from docs/leetcode/python/231._Power_of_Two.md
rename to docs/Leetcode_Solutions/231. _Power_of_Two.md
diff --git a/docs/leetcode/python/232._implement_queue_using_stacks.md b/docs/Leetcode_Solutions/232._implement_queue_using_stacks.md
similarity index 100%
rename from docs/leetcode/python/232._implement_queue_using_stacks.md
rename to docs/Leetcode_Solutions/232._implement_queue_using_stacks.md
diff --git a/docs/Leetcode_Solutions/234._palindrome_linked_list.md b/docs/Leetcode_Solutions/234._palindrome_linked_list.md
new file mode 100644
index 000000000..586e69584
--- /dev/null
+++ b/docs/Leetcode_Solutions/234._palindrome_linked_list.md
@@ -0,0 +1,124 @@
+###234. Palindrome Linked List
+
+题目:
+
+
+
+难度:
+Easy
+
+这道题我花了很久的时间
+
+
+思路是:“先翻转整个链表,然后和之前的链表比较”
+
+但是一直不能AC,然后去谷歌了,然后debug的过程发现原来的linked list也不存在了.
+
+
+“先翻转整个链表,然后和之前的链表比较”听起来是可行的,但是当你“翻转了整个链表”以后,“之前的链表”已经不存在了啊。这时候的head其实是指向翻转后的链表的最后一个元素,所以这段代码的本质是:“比较链表的第1个和最后1个元素是否相同”。
+
+
+如果用这个思路的话,你就必须创建一个原始链表的备份才行。但与其那样做,还不如干脆把List中元素拷贝到数组中算了,因为都是O(N)内存,后者实现起来还简单快捷一些。
+
+
+所以艰难的第一个AC办法:
+
+
+```
+class Solution(object):
+ def isPalindrome(self, head):
+ """
+ :type head: ListNode
+ :rtype: bool
+ """
+ if head == None or head.next == None:
+ return True
+
+ cur = head
+ stack = []
+ while cur:
+ stack.append(cur.val)
+ cur = cur.next
+
+ while head and stack:
+ if head.val != stack.pop():
+ return False
+ else:
+ head = head.next
+ return True
+```
+
+这道题并不能算Easy吧:
+
+思路二:
+找到中间的节点,把linked list拆成两个部分,后半部分linkedlist reverse,然后比较两个linked list值是否相同,看例子:
+
+
+```
+1 -> 3 -> 1 拆成 1 和 1
+
+1 -> 3 -> 5 ->5 -> 3 -> 1 拆成 1-> 3 -> 5 和 5 -> 3 -> 1
+
+```
+
+然后用这个思路的时候还有一个问题,就是特别简单的Python递归可能建议不用递归,因为递归反倒可能recursion到极限,用loop可能更顺.
+
+第二个AC之法,因为懒,所以老用之前用过的代码:
+
+这个速度也是慢的厉害
+
+
+
+```
+class Solution(object):
+ def isPalindrome(self, head):
+ """
+ :type head: ListNode
+ :rtype: bool
+ """
+ if head == None or head.next == None:
+ return True
+
+ mid = self.findMid(head)
+ mid = self.reverseList(mid)
+
+ while head and mid:
+ if head.val != mid.val:
+ return False
+ else:
+ head = head.next
+ mid = mid.next
+ return True
+
+
+
+ def findMid(self, head):
+ if head == None:
+ return None
+ else:
+ slow = head
+ fast = head
+
+ while fast.next and fast.next.next:
+ slow = slow.next
+ fast = fast.next.next
+
+ print(slow.val)
+ return slow.next
+
+ def reverseList(self, head):
+ """
+ :type head: ListNode
+ :rtype: ListNode
+ """
+ prev = None
+ cur = head
+ while(cur):
+ nxt = cur.next
+ cur.next = prev
+ prev = cur
+ cur = nxt
+ return prev
+```
+
+然后看了一下,如果把这三块写在一起,会轻松一些,AC速度快很多
diff --git a/docs/leetcode/python/235._lowest_common_ancestor_of_a_binary_search_tree.md b/docs/Leetcode_Solutions/235._lowest_common_ancestor_of_a_binary_search_tree.md
similarity index 100%
rename from docs/leetcode/python/235._lowest_common_ancestor_of_a_binary_search_tree.md
rename to docs/Leetcode_Solutions/235._lowest_common_ancestor_of_a_binary_search_tree.md
diff --git a/docs/leetcode/python/236._lowest_common_ancestor_of_a_binary_tree.md b/docs/Leetcode_Solutions/236._lowest_common_ancestor_of_a_binary_tree.md
similarity index 99%
rename from docs/leetcode/python/236._lowest_common_ancestor_of_a_binary_tree.md
rename to docs/Leetcode_Solutions/236._lowest_common_ancestor_of_a_binary_tree.md
index 90d397641..271c462ad 100644
--- a/docs/leetcode/python/236._lowest_common_ancestor_of_a_binary_tree.md
+++ b/docs/Leetcode_Solutions/236._lowest_common_ancestor_of_a_binary_tree.md
@@ -79,7 +79,7 @@ AC代码
-```
+```
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
"""
diff --git a/docs/leetcode/python/237._delete_node_in_a_linked_list.md b/docs/Leetcode_Solutions/237._delete_node_in_a_linked_list.md
similarity index 96%
rename from docs/leetcode/python/237._delete_node_in_a_linked_list.md
rename to docs/Leetcode_Solutions/237._delete_node_in_a_linked_list.md
index cd8be88c9..d401e090d 100644
--- a/docs/leetcode/python/237._delete_node_in_a_linked_list.md
+++ b/docs/Leetcode_Solutions/237._delete_node_in_a_linked_list.md
@@ -1,52 +1,52 @@
-### 237. Delete Node in a Linked List
-
-题目:
-
-
-
-难度:
-Easy
-
-
-
-这道题,第一感觉,像删链表一样来删,把所有的node val前移一个,但是有个问题,为什么tail那个node还是存在?哼(ˉ(∞)ˉ)唧..
-
-已经被解答:
-
-
-
-
-
-另外一个O(1)的办法更好,把后一个node的val移到待删这个节点,并且把node.next = node.next.next
-
-题目说了不会删最后一个点,所以node.next.next一定存在,所以直接让node的val等于它next的val,然后让node的next指向它的next的next,举个例子:
- 1->2->3->4->5->None,要删除第四个节点,就让4变成5,然后让第四个节点指向第五个节点的next,
-这样原来的第四个节点就不存在了,虽然原来的第五个节点仍然存在且指向None,变成了1->2->3->5->None-<5
-
-
-
-```python
-O(1)时间
-class Solution(object):
- def deleteNode(self, node):
- """
- :type node: ListNode
- :rtype: void Do not return anything, modify node in-place instead.
- """
- node.val = node.next.val
- node.next = node.next.next
-```
-```python
-O(n)时间
-class Solution(object):
- def deleteNode(self, node):
- """
- :type node: ListNode
- :rtype: void Do not return anything, modify node in-place instead.
- """
- while node.next:
- node.val = node.next.val
- prev, node = node, node.next
- # clear reference to tail
- prev.next = None
-```
+### 237. Delete Node in a Linked List
+
+题目:
+
+
+
+难度:
+Easy
+
+
+
+这道题,第一感觉,像删链表一样来删,把所有的node val前移一个,但是有个问题,为什么tail那个node还是存在?哼(ˉ(∞)ˉ)唧..
+
+已经被解答:
+
+
+
+
+
+另外一个O(1)的办法更好,把后一个node的val移到待删这个节点,并且把node.next = node.next.next
+
+题目说了不会删最后一个点,所以node.next.next一定存在,所以直接让node的val等于它next的val,然后让node的next指向它的next的next,举个例子:
+ 1->2->3->4->5->None,要删除第四个节点,就让4变成5,然后让第四个节点指向第五个节点的next,
+这样原来的第四个节点就不存在了,虽然原来的第五个节点仍然存在且指向None,变成了1->2->3->5->None-<5
+
+
+
+```python
+O(1)时间
+class Solution(object):
+ def deleteNode(self, node):
+ """
+ :type node: ListNode
+ :rtype: void Do not return anything, modify node in-place instead.
+ """
+ node.val = node.next.val
+ node.next = node.next.next
+```
+```python
+O(n)时间
+class Solution(object):
+ def deleteNode(self, node):
+ """
+ :type node: ListNode
+ :rtype: void Do not return anything, modify node in-place instead.
+ """
+ while node.next:
+ node.val = node.next.val
+ prev, node = node, node.next
+ # clear reference to tail
+ prev.next = None
+```
diff --git a/docs/leetcode/python/238._product_of_array_except_self.md b/docs/Leetcode_Solutions/238._product_of_array_except_self.md
similarity index 100%
rename from docs/leetcode/python/238._product_of_array_except_self.md
rename to docs/Leetcode_Solutions/238._product_of_array_except_self.md
diff --git a/docs/leetcode/python/240._search_a_2d_matrix_ii.md b/docs/Leetcode_Solutions/240._search_a_2d_matrix_ii.md
similarity index 100%
rename from docs/leetcode/python/240._search_a_2d_matrix_ii.md
rename to docs/Leetcode_Solutions/240._search_a_2d_matrix_ii.md
diff --git a/docs/leetcode/python/242._valid_anagram.md b/docs/Leetcode_Solutions/242._valid_anagram.md
similarity index 100%
rename from docs/leetcode/python/242._valid_anagram.md
rename to docs/Leetcode_Solutions/242._valid_anagram.md
diff --git a/docs/leetcode/python/252._Meeting_Rooms.md b/docs/Leetcode_Solutions/252. Meeting Rooms.md
similarity index 100%
rename from docs/leetcode/python/252._Meeting_Rooms.md
rename to docs/Leetcode_Solutions/252. Meeting Rooms.md
diff --git a/docs/leetcode/python/255._Verify_Preorder_Sequence_in_Binary_Search_Tree.md b/docs/Leetcode_Solutions/255._Verify_Preorder_Sequence_in_Binary_Search_Tree.md
similarity index 100%
rename from docs/leetcode/python/255._Verify_Preorder_Sequence_in_Binary_Search_Tree.md
rename to docs/Leetcode_Solutions/255._Verify_Preorder_Sequence_in_Binary_Search_Tree.md
diff --git a/docs/leetcode/python/256._Paint_House.md b/docs/Leetcode_Solutions/256. Paint House.md
similarity index 100%
rename from docs/leetcode/python/256._Paint_House.md
rename to docs/Leetcode_Solutions/256. Paint House.md
diff --git a/docs/Leetcode_Solutions/257._binary_tree_paths.md b/docs/Leetcode_Solutions/257._binary_tree_paths.md
new file mode 100644
index 000000000..c0fdea6ed
--- /dev/null
+++ b/docs/Leetcode_Solutions/257._binary_tree_paths.md
@@ -0,0 +1,45 @@
+###257. Binary Tree Paths
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+Tag : tree, DFS
+
+类似的题目是Path Sum Ⅱ
+
+
+第一眼看起来不像easy题目,然后堵了一下自己写的Path Sum Ⅱ自己的解答
+
+同一种花样
+
+```
+class Solution:
+ # @param {TreeNode} root
+ # @return {string[]}
+ def binaryTreePaths(self, root):
+ if root == None: return []
+ result = []
+ self.auxTreePaths(root,result,"")
+ return result
+
+
+ def auxTreePaths(self,root,result,curStr):
+ if root == None:
+ return
+ curStr += str(root.val)
+ if root.left == None and root.right == None:
+ result.append(curStr)
+ if root.left:
+ self.auxTreePaths(root.left,result,curStr + "->")
+ if root.right:
+ self.auxTreePaths(root.right,result,curStr + "->")
+
+```
+
diff --git a/docs/leetcode/python/258._Add_Digits.md b/docs/Leetcode_Solutions/258_ Add_Digits.md
similarity index 100%
rename from docs/leetcode/python/258._Add_Digits.md
rename to docs/Leetcode_Solutions/258_ Add_Digits.md
diff --git a/docs/leetcode/python/261._Graph_Valid_Tree.md b/docs/Leetcode_Solutions/261. Graph Valid Tree.md
similarity index 100%
rename from docs/leetcode/python/261._Graph_Valid_Tree.md
rename to docs/Leetcode_Solutions/261. Graph Valid Tree.md
diff --git a/docs/leetcode/python/263._ugly_number.md b/docs/Leetcode_Solutions/263._ugly_number.md
similarity index 100%
rename from docs/leetcode/python/263._ugly_number.md
rename to docs/Leetcode_Solutions/263._ugly_number.md
diff --git a/docs/leetcode/python/264._ugly_number_ii.md b/docs/Leetcode_Solutions/264._ugly_number_ii.md
similarity index 98%
rename from docs/leetcode/python/264._ugly_number_ii.md
rename to docs/Leetcode_Solutions/264._ugly_number_ii.md
index cece144eb..ba1546b9e 100644
--- a/docs/leetcode/python/264._ugly_number_ii.md
+++ b/docs/Leetcode_Solutions/264._ugly_number_ii.md
@@ -102,39 +102,39 @@ class Solution(object):
还可以优化:
根据页面hint 来做的
-
-```
-class Solution(object):
- def nthUglyNumber(self, n):
- """
- :type n: int
- :rtype: int
- """
- if n == 1:
- return 1
- else:
- import collections
- q2 = collections.deque()
- q3 = collections.deque()
- q5 = collections.deque()
- q2.append(2)
- q3.append(3)
- q5.append(5)
- while n > 1:
- x = min(q2[0],q3[0],q5[0])
- if x == q2[0]:
- x = q2.popleft()
- q2.append(2*x)
- q3.append(3*x)
- q5.append(5*x)
- elif x == q3[0]:
- x = q3.popleft()
- q3.append(3*x)
- q5.append(5*x)
- else:
- x = q5.popleft()
- q5.append(5*x)
- n -= 1
- return x
+
+```
+class Solution(object):
+ def nthUglyNumber(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ if n == 1:
+ return 1
+ else:
+ import collections
+ q2 = collections.deque()
+ q3 = collections.deque()
+ q5 = collections.deque()
+ q2.append(2)
+ q3.append(3)
+ q5.append(5)
+ while n > 1:
+ x = min(q2[0],q3[0],q5[0])
+ if x == q2[0]:
+ x = q2.popleft()
+ q2.append(2*x)
+ q3.append(3*x)
+ q5.append(5*x)
+ elif x == q3[0]:
+ x = q3.popleft()
+ q3.append(3*x)
+ q5.append(5*x)
+ else:
+ x = q5.popleft()
+ q5.append(5*x)
+ n -= 1
+ return x
```
diff --git a/docs/leetcode/python/265._Paint_House_II.md b/docs/Leetcode_Solutions/265. Paint House II.md
similarity index 100%
rename from docs/leetcode/python/265._Paint_House_II.md
rename to docs/Leetcode_Solutions/265. Paint House II.md
diff --git a/docs/leetcode/python/266._Palindrome_Permutation.md b/docs/Leetcode_Solutions/266. Palindrome Permutation.md
similarity index 100%
rename from docs/leetcode/python/266._Palindrome_Permutation.md
rename to docs/Leetcode_Solutions/266. Palindrome Permutation.md
diff --git a/docs/leetcode/python/267._Palindrome_Permutation_II.md b/docs/Leetcode_Solutions/267. Palindrome Permutation II.md
similarity index 100%
rename from docs/leetcode/python/267._Palindrome_Permutation_II.md
rename to docs/Leetcode_Solutions/267. Palindrome Permutation II.md
diff --git a/docs/leetcode/python/268._missing_number.md b/docs/Leetcode_Solutions/268._missing_number.md
similarity index 93%
rename from docs/leetcode/python/268._missing_number.md
rename to docs/Leetcode_Solutions/268._missing_number.md
index f44567eeb..fbd54da5a 100644
--- a/docs/leetcode/python/268._missing_number.md
+++ b/docs/Leetcode_Solutions/268._missing_number.md
@@ -1,49 +1,49 @@
-### 268. Missing Number
-
-题目:
-
-
-
-难度:
-
-Medium
-
-
-
-等差数列前n项和减去数组之和,一行瞬秒
-```(注意题目input从0开始取值)```
-
-
-```python
-class Solution(object):
- def missingNumber(self, nums):
- """
- :type nums: List[int]
- :rtype: int
- """
- return len(nums) * (len(nums) + 1) / 2 - sum(nums)
-```
-
-
-
-第二种解法是位运算:位运算(异或运算)
-
-
-
-```python
-class Solution(object):
- def missingNumber(self, nums):
- """
- :type nums: List[int]
- :rtype: int
- """
- res = n = len(nums)
- for i in range(n):
- res ^= i
- res ^= nums[i]
- return res
-```
-
-
-
-
+### 268. Missing Number
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+
+等差数列前n项和减去数组之和,一行瞬秒
+```(注意题目input从0开始取值)```
+
+
+```python
+class Solution(object):
+ def missingNumber(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ return len(nums) * (len(nums) + 1) / 2 - sum(nums)
+```
+
+
+
+第二种解法是位运算:位运算(异或运算)
+
+
+
+```python
+class Solution(object):
+ def missingNumber(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ res = n = len(nums)
+ for i in range(n):
+ res ^= i
+ res ^= nums[i]
+ return res
+```
+
+
+
+
diff --git a/docs/Leetcode_Solutions/270. Closest Binary Search Tree Value.md b/docs/Leetcode_Solutions/270. Closest Binary Search Tree Value.md
new file mode 100644
index 000000000..b2aafe48a
--- /dev/null
+++ b/docs/Leetcode_Solutions/270. Closest Binary Search Tree Value.md
@@ -0,0 +1,66 @@
+### 270. Closest Binary Search Tree Val
+
+题目:
+
+
+
+
+
+难度 : Easy
+
+最简单的算法是inorder一遍,得到有序的lst,然后O(N) 寻找最靠近的,但是明显不是很高效。
+
+AC代码
+
+```
+class Solution(object):
+ def closestValue(self, root, target):
+ """
+ :type root: TreeNode
+ :type target: float
+ :rtype: int
+ """
+ lst = []
+
+ def inorder(root):
+ if root:
+ inorder(root.left)
+ lst.append(root.val)
+ inorder(root.right)
+
+ inorder(root)
+
+ close = lst[0]
+ diff = abs(target - lst[0])
+
+ for i in lst:
+ if abs(target - i) < diff:
+ close = i
+ diff = abs(target - i )
+
+ return close
+```
+
+
+
+AC代码,跟binary search tree 寻值一样, loop 一遍树来寻找
+
+
+
+```
+
+class Solution(object):
+ def closestValue(self, root, target):
+ """
+ :type root: TreeNode
+ :type target: float
+ :rtype: int
+ """
+ close = root.val
+
+ while root:
+ close = root.val if abs(target - root.val) < abs(target - close) else close
+ root = root.right if root.val < target else root.left
+ return close
+```
+
diff --git a/docs/leetcode/python/276._Paint_Fence.md b/docs/Leetcode_Solutions/276. Paint Fence.md
similarity index 100%
rename from docs/leetcode/python/276._Paint_Fence.md
rename to docs/Leetcode_Solutions/276. Paint Fence.md
diff --git a/docs/leetcode/python/277._Find_the_Celebrity.md b/docs/Leetcode_Solutions/277. Find the Celebrity.md
similarity index 100%
rename from docs/leetcode/python/277._Find_the_Celebrity.md
rename to docs/Leetcode_Solutions/277. Find the Celebrity.md
diff --git a/docs/leetcode/python/278._First_Bad_Version.md b/docs/Leetcode_Solutions/278._First_Bad _Version.md
similarity index 100%
rename from docs/leetcode/python/278._First_Bad_Version.md
rename to docs/Leetcode_Solutions/278._First_Bad _Version.md
diff --git a/docs/Leetcode_Solutions/279._perfect_squares.md b/docs/Leetcode_Solutions/279._perfect_squares.md
new file mode 100644
index 000000000..f4d8bd50f
--- /dev/null
+++ b/docs/Leetcode_Solutions/279._perfect_squares.md
@@ -0,0 +1,116 @@
+
+### 279. Perfect Squares
+
+
+题目:
+
+
+
+难度:
+
+Medium
+
+### 思路一:
+DP, 状态转移方程:
+
+```dp[i] = min(dp[i], dp[i - j * j] + 1)```
+
+
+
+
+```python
+class Solution(object):
+ def numSquares(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ dp = [0] * (n+1)
+ for i in range(n+1):
+ dp[i] = i
+ j = 1
+ while j * j <= i:
+ dp[i] = min(dp[i], dp[i-j*j] + 1)
+ j += 1
+ return dp[-1]
+```
+但是这个方法贼慢,beats 12%, 有时候提交甚至会超时,有时候又不会。。。。因此想别的办法
+
+### 思路二:
+
+Static DP, beats 90.39%
+
+```python
+class Solution(object):
+ dp = [0]
+ def numSquares(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ while len(self.dp) <= n:
+ m = len(self.dp)
+ inf = float('inf')
+ i = 1
+ while i * i <= m:
+ inf = min(inf, self.dp[m-i*i] + 1)
+ i += 1
+ self.dp.append(inf)
+ return self.dp[n]
+```
+
+进一步简化可以写成:
+```python
+class Solution(object):
+ dp = [0]
+ def numSquares(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ while len(self.dp) <= n:
+ self.dp += min(self.dp[-j*j] + 1 for j in range(1, int(len(self.dp)**0.5+1))),
+ return self.dp[n]
+```
+这里有个问题现在还没搞明白,以后再好好想一下,写成```return self.dp[-1]```提交就失败,
+```
+Submission Result: Wrong Answer
+Input: 1024
+Output: 4
+Expected: 1
+```
+
+### 思路三:
+
+还是慢,有个数学方法, runtime beats 98.48%
+```python
+import math
+class Solution(object):
+ def numSquares(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ def isSquare(num):
+ tmp = int(math.sqrt(num))
+ return tmp * tmp == num
+ while n & 3 == 0: # n % 4 == 0
+ n >>= 2
+ if n & 7 == 7: # n % 8 == 7
+ return 4
+ if isSquare(n):
+ return 1
+ sqrt_n = int(math.sqrt(n))
+ for i in range(1, sqrt_n + 1):
+ if isSquare(n-i*i):
+ return 2
+ return 3
+```
+in order to understand, I suggest u read:
+
+here is the [Lagrange's Four Square theorem](https://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem
+) - Limit the result to <= 4:
+
+And this [article](http://www.alpertron.com.ar/4SQUARES.HTM), in which you can also find the way to present a number as a sum of four squares:
+
+
diff --git a/docs/leetcode/python/280._Wiggle_Sort.md b/docs/Leetcode_Solutions/280._Wiggle_Sort.md
similarity index 100%
rename from docs/leetcode/python/280._Wiggle_Sort.md
rename to docs/Leetcode_Solutions/280._Wiggle_Sort.md
diff --git a/docs/leetcode/python/283._move_zeroes.md b/docs/Leetcode_Solutions/283._move_zeroes.md
similarity index 100%
rename from docs/leetcode/python/283._move_zeroes.md
rename to docs/Leetcode_Solutions/283._move_zeroes.md
diff --git a/docs/leetcode/python/285._inorder_successor_in_bst.md b/docs/Leetcode_Solutions/285._inorder_successor_in_bst.md
similarity index 64%
rename from docs/leetcode/python/285._inorder_successor_in_bst.md
rename to docs/Leetcode_Solutions/285._inorder_successor_in_bst.md
index b3a941587..a5a489be9 100644
--- a/docs/leetcode/python/285._inorder_successor_in_bst.md
+++ b/docs/Leetcode_Solutions/285._inorder_successor_in_bst.md
@@ -1,50 +1,15 @@
-# 285. Inorder Successor in BST
+###285. Inorder Successor in BST
-**难度: 中等 **
-## 刷题内容
+题目:
+
-> 原题连接
-* https://leetcode.com/problems/inorder-successor-in-bst
+难度:
+Medium
-> 内容描述
+思路:
-```
-
-Given a binary search tree and a node in it, find the in-order successor of that node in the BST.
-
-Note: If the given node has no in-order successor in the tree, return null.
-
-Example 1:
-
-Input: root = [2,1,3], p = 1
-
- 2
- / \
-1 3
-
-Output: 2
-Example 2:
-
-Input: root = [5,3,6,2,4,null,null,1], p = 6
-
- 5
- / \
- 3 6
- / \
- 2 4
- /
-1
-
-Output: null
-```
-
-## 解题方案
-
-> 思路 1
-
-首先可以去看一下[二叉树的一些操作](https://github.com/apachecn/LeetCode/blob/master/docs/Leetcode_Solutions/Summarization/%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E4%B8%80%E4%BA%9B%E6%93%8D%E4%BD%9C.md)
BST的特性,对于一个node,它的所有左侧node都比它小,它的所有右侧node都比它大。最小的元素在最左边,最大的元素在最右边。
@@ -79,9 +44,10 @@ function Succ(x)
这里伪码有点不适用是因为我们并没有这个parent指针,当然我们还是有trick方式的,就是我们从root开始走,直到找到这个node p,同时我们记录一路上看到的比p.val大的值,这样最后一个就是它的successor.其中最低的那一个就是他的successor.
+AC代码如下:
-```python
+```
class Solution(object):
def inorderSuccessor(self, root, p):
"""
@@ -89,13 +55,14 @@ class Solution(object):
:type p: TreeNode
:rtype: TreeNode
"""
- def minNode(node):
- while node.left:
- node = node.left
- return node
-
- def searchP(root, p):
- if not root or root.val == p.val:
+ def minNode(root):
+ while root.left!= None:
+ root = root.left
+ return root
+
+
+ def searchP(p, root):
+ if root == None or root.val == p.val:
return None
else:
succ = None
@@ -110,6 +77,5 @@ class Solution(object):
if p.right:
return minNode(p.right)
else:
- return searchP(root, p)
-```
-
+ return searchP(p, root)
+```
\ No newline at end of file
diff --git a/docs/leetcode/python/286._Walls_and_Gates.md b/docs/Leetcode_Solutions/286. Walls and Gates.md
similarity index 100%
rename from docs/leetcode/python/286._Walls_and_Gates.md
rename to docs/Leetcode_Solutions/286. Walls and Gates.md
diff --git a/docs/leetcode/python/289._game_of_life.md b/docs/Leetcode_Solutions/289._game_of_life.md
similarity index 100%
rename from docs/leetcode/python/289._game_of_life.md
rename to docs/Leetcode_Solutions/289._game_of_life.md
diff --git a/docs/leetcode/python/290._word_pattern.md b/docs/Leetcode_Solutions/290._word_pattern.md
similarity index 100%
rename from docs/leetcode/python/290._word_pattern.md
rename to docs/Leetcode_Solutions/290._word_pattern.md
diff --git a/docs/leetcode/python/292._nim_game.md b/docs/Leetcode_Solutions/292._nim_game.md
similarity index 100%
rename from docs/leetcode/python/292._nim_game.md
rename to docs/Leetcode_Solutions/292._nim_game.md
diff --git a/docs/leetcode/python/296._Best_Meeting_Point.md b/docs/Leetcode_Solutions/296. Best Meeting Point.md
similarity index 100%
rename from docs/leetcode/python/296._Best_Meeting_Point.md
rename to docs/Leetcode_Solutions/296. Best Meeting Point.md
diff --git a/docs/leetcode/python/298._Binary_Tree_Longest_Consecutive_Sequence.md b/docs/Leetcode_Solutions/298. Binary Tree Longest Consecutive Sequence.md
similarity index 100%
rename from docs/leetcode/python/298._Binary_Tree_Longest_Consecutive_Sequence.md
rename to docs/Leetcode_Solutions/298. Binary Tree Longest Consecutive Sequence.md
diff --git a/docs/leetcode/python/299._bulls_and_cows.md b/docs/Leetcode_Solutions/299._bulls_and_cows.md
similarity index 98%
rename from docs/leetcode/python/299._bulls_and_cows.md
rename to docs/Leetcode_Solutions/299._bulls_and_cows.md
index 1d6818460..8b6cbe468 100644
--- a/docs/leetcode/python/299._bulls_and_cows.md
+++ b/docs/Leetcode_Solutions/299._bulls_and_cows.md
@@ -13,38 +13,38 @@ Easy
我花了很久时间来AC,因为想了边界条件
-```
-class Solution(object):
- def getHint(self, secret, guess):
- """
- :type secret: str
- :type guess: str
- :rtype: str
- """
- maps = {}
- for i in range(len(secret)):
- if secret[i] not in maps:
- maps[secret[i]] = [i]
- else:
- maps[secret[i]].append(i)
- mapg = {}
- for i in range(len(guess)):
- if guess[i] not in mapg:
- mapg[guess[i]] = [i]
- else:
- mapg[guess[i]].append(i)
-
- print maps, mapg
-
- a,b = 0,0
- for key in maps.keys():
- if key in mapg.keys():
- common = list(set(mapg[key]) & set(maps[key]))
- #check for bull
- a += len(common)
- mapg[key] = [item for item in mapg[key] if item not in common]
- maps[key] = [item for item in maps[key] if item not in common]
- b += min(len(maps[key]), len(mapg[key]))
+```
+class Solution(object):
+ def getHint(self, secret, guess):
+ """
+ :type secret: str
+ :type guess: str
+ :rtype: str
+ """
+ maps = {}
+ for i in range(len(secret)):
+ if secret[i] not in maps:
+ maps[secret[i]] = [i]
+ else:
+ maps[secret[i]].append(i)
+ mapg = {}
+ for i in range(len(guess)):
+ if guess[i] not in mapg:
+ mapg[guess[i]] = [i]
+ else:
+ mapg[guess[i]].append(i)
+
+ print maps, mapg
+
+ a,b = 0,0
+ for key in maps.keys():
+ if key in mapg.keys():
+ common = list(set(mapg[key]) & set(maps[key]))
+ #check for bull
+ a += len(common)
+ mapg[key] = [item for item in mapg[key] if item not in common]
+ maps[key] = [item for item in maps[key] if item not in common]
+ b += min(len(maps[key]), len(mapg[key]))
return str(a) + 'A' + str(b) + 'B'
```
diff --git a/docs/leetcode/python/300._longest_increasing_subsequence.md b/docs/Leetcode_Solutions/300._longest_increasing_subsequence.md
similarity index 60%
rename from docs/leetcode/python/300._longest_increasing_subsequence.md
rename to docs/Leetcode_Solutions/300._longest_increasing_subsequence.md
index 9c59ae194..bd1752b9e 100644
--- a/docs/leetcode/python/300._longest_increasing_subsequence.md
+++ b/docs/Leetcode_Solutions/300._longest_increasing_subsequence.md
@@ -1,4 +1,4 @@
-### 300. Longest Increasing Subsequence
+###300. Longest Increasing Subsequence
题目:
@@ -22,20 +22,21 @@ dp[i] = dp[j] + 1 if num[i] > num[j] else 1
AC 代码
-```python
+```
class Solution(object):
def lengthOfLIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
- if not nums:
- return 0
- dp = [1 for i in range(len(nums))]
- for i in range(1, len(nums)):
- for j in range(i):
- if nums[i] > nums[j]:
- dp[i] = max(dp[j]+1, dp[i])
+ if not nums: return 0
+ n = len(nums)
+ dp = [1 for i in range(n)]
+ for i in range(1,n):
+ for j in range(i):
+ if nums[i] > nums[j] :
+ dp[i] = max(dp[i],dp[j] + 1)
+
return max(dp)
```
diff --git a/docs/leetcode/python/303._range_sum_query_-_immutable.md b/docs/Leetcode_Solutions/303._range_sum_query_-_immutable.md
similarity index 100%
rename from docs/leetcode/python/303._range_sum_query_-_immutable.md
rename to docs/Leetcode_Solutions/303._range_sum_query_-_immutable.md
diff --git a/docs/leetcode/python/316._Remove_Duplicate_Letters.md b/docs/Leetcode_Solutions/316._Remove_Duplicate_Letters.md
similarity index 100%
rename from docs/leetcode/python/316._Remove_Duplicate_Letters.md
rename to docs/Leetcode_Solutions/316._Remove_Duplicate_Letters.md
diff --git a/docs/leetcode/python/319._Bulb_Switcher.md b/docs/Leetcode_Solutions/319._Bulb_Switcher.md
similarity index 100%
rename from docs/leetcode/python/319._Bulb_Switcher.md
rename to docs/Leetcode_Solutions/319._Bulb_Switcher.md
diff --git a/docs/leetcode/python/322._Coin_Change.md b/docs/Leetcode_Solutions/322. Coin Change.md
similarity index 100%
rename from docs/leetcode/python/322._Coin_Change.md
rename to docs/Leetcode_Solutions/322. Coin Change.md
diff --git a/docs/Leetcode_Solutions/323. Number of Connected Components in an Undirected Graph.md b/docs/Leetcode_Solutions/323. Number of Connected Components in an Undirected Graph.md
new file mode 100644
index 000000000..63304b37c
--- /dev/null
+++ b/docs/Leetcode_Solutions/323. Number of Connected Components in an Undirected Graph.md
@@ -0,0 +1,103 @@
+### 323. Number of Connected Components in an Undirected Graph
+
+
+
+
+
+题目:
+
+
+
+
+难度 : Medium
+
+
+
+思路:
+
+
+
+最容易想到的是针对每个节点做dfs?然后发现其已经被mark了就不管了,最后数dfs的次数?
+
+这样尝试,到n =2000 的时候 TLE
+
+```
+class Solution(object):
+ def countComponents(self, n, edges):
+ """
+ :type n: int
+ :type edges: List[List[int]]
+ :rtype: int
+ """
+ def dfs(node):
+ if visited[node] == 1:
+ return
+ else:
+ visited[node] = 1
+ for node1, node2 in edges:
+ if node1 == node:
+ dfs(node2)
+ elif node2 == node:
+ dfs(node1)
+
+ res = 0
+ visited = [ 0 for i in range(n)]
+ for i in range(n):
+ if visited[i] == 0:
+ dfs(i)
+ res += 1
+ return res
+```
+
+
+
+tag是union find,不用是否浪费?
+
+所谓的union find,应当不是每个做dfs,而是每个来看一下是否属于同一个set,一次dfs,然后loop 做union find
+
+[Disjoint-set_data_structure](https://en.wikipedia.org/wiki/Disjoint-set_data_structure)
+
+
+
+这里有一个很棒的[实现](http://python-algorithms.readthedocs.io/en/stable/_modules/python_algorithms/basic/union_find.html)
+
+
+
+AC代码
+
+这里就偷懒了,利用岛是0-n,然后也只做了path compression,没更多的优化
+
+
+
+```
+class Solution(object):
+ def countComponents(self, n, edges):
+ """
+ :type n: int
+ :type edges: List[List[int]]
+ :rtype: int
+ """
+ def find(x):
+ if uf[x] != x:
+ uf[x] = find(uf[x])
+ return uf[x]
+
+ def union(x,y):
+ xRoot = find(x)
+ yRoot = find(y)
+ uf[xRoot] = yRoot
+
+ uf = [i for i in range(n)]
+
+ for node1, node2 in edges:
+ union(node1, node2)
+
+ res = set()
+ for i in range(n):
+ res.add(find(i))
+
+ return len(res)
+```
+
+
+
diff --git a/docs/leetcode/python/324._Wiggle_Sort_II.md b/docs/Leetcode_Solutions/324._Wiggle_Sort_II.md
similarity index 100%
rename from docs/leetcode/python/324._Wiggle_Sort_II.md
rename to docs/Leetcode_Solutions/324._Wiggle_Sort_II.md
diff --git a/docs/leetcode/python/326._power_of_three.md b/docs/Leetcode_Solutions/326._power_of_three.md
similarity index 94%
rename from docs/leetcode/python/326._power_of_three.md
rename to docs/Leetcode_Solutions/326._power_of_three.md
index 0059d10a4..9cd035d9c 100644
--- a/docs/leetcode/python/326._power_of_three.md
+++ b/docs/Leetcode_Solutions/326._power_of_three.md
@@ -28,7 +28,7 @@ class Solution(object):
```
-有一个follow up,可否不用 loop/recursion
+有一个follow up,可否不用 loop/recusion
看到了取巧的办法,因为是Given an integer,是有范围的(<2147483648),存在能输入的最大的3的幂次,即 3^19=1162261467。
diff --git a/docs/leetcode/python/328._odd_even_linked_list.md b/docs/Leetcode_Solutions/328._odd_even_linked_list.md
similarity index 99%
rename from docs/leetcode/python/328._odd_even_linked_list.md
rename to docs/Leetcode_Solutions/328._odd_even_linked_list.md
index 893314630..b628ab241 100644
--- a/docs/leetcode/python/328._odd_even_linked_list.md
+++ b/docs/Leetcode_Solutions/328._odd_even_linked_list.md
@@ -52,26 +52,26 @@ class Solution(object):
看别人的优雅代码
-```
-class Solution(object):
- def oddEvenList(self, head):
- """
- :type head: ListNode
- :rtype: ListNode
- """
- if head == None:
- return head
-
- # odd used to keep track of the tail of odd nodes
- odd = oddHead = head
- # record how many swaps happend
- even = evenHead = head.next
- while even and even.next:
- odd.next = even.next
- odd = odd.next
- even.next = odd.next
- even = even.next
- odd.next = evenHead
+```
+class Solution(object):
+ def oddEvenList(self, head):
+ """
+ :type head: ListNode
+ :rtype: ListNode
+ """
+ if head == None:
+ return head
+
+ # odd used to keep track of the tail of odd nodes
+ odd = oddHead = head
+ # record how many swaps happend
+ even = evenHead = head.next
+ while even and even.next:
+ odd.next = even.next
+ odd = odd.next
+ even.next = odd.next
+ even = even.next
+ odd.next = evenHead
return head
```
diff --git a/docs/leetcode/python/334._increasing_triplet_subsequence.md b/docs/Leetcode_Solutions/334._increasing_triplet_subsequence.md
similarity index 100%
rename from docs/leetcode/python/334._increasing_triplet_subsequence.md
rename to docs/Leetcode_Solutions/334._increasing_triplet_subsequence.md
diff --git a/docs/leetcode/python/337._house_robber_iii.md b/docs/Leetcode_Solutions/337._house_robber_iii.md
similarity index 100%
rename from docs/leetcode/python/337._house_robber_iii.md
rename to docs/Leetcode_Solutions/337._house_robber_iii.md
diff --git a/docs/leetcode/python/338._Counting_Bits.md b/docs/Leetcode_Solutions/338. Counting Bits.md
similarity index 100%
rename from docs/leetcode/python/338._Counting_Bits.md
rename to docs/Leetcode_Solutions/338. Counting Bits.md
diff --git a/docs/leetcode/python/339._Nested_List_Weight_Sum.md b/docs/Leetcode_Solutions/339. Nested List Weight Sum.md
similarity index 100%
rename from docs/leetcode/python/339._Nested_List_Weight_Sum.md
rename to docs/Leetcode_Solutions/339. Nested List Weight Sum.md
diff --git a/docs/leetcode/python/341._Flatten_Nested_List_Iterator.md b/docs/Leetcode_Solutions/341._Flatten_Nested_List_Iterator.md
similarity index 100%
rename from docs/leetcode/python/341._Flatten_Nested_List_Iterator.md
rename to docs/Leetcode_Solutions/341._Flatten_Nested_List_Iterator.md
diff --git a/docs/leetcode/python/342._Power_of_Four.md b/docs/Leetcode_Solutions/342._Power_of_Four.md
similarity index 100%
rename from docs/leetcode/python/342._Power_of_Four.md
rename to docs/Leetcode_Solutions/342._Power_of_Four.md
diff --git a/docs/leetcode/python/344._reverse_string.md b/docs/Leetcode_Solutions/344._reverse_string.md
similarity index 94%
rename from docs/leetcode/python/344._reverse_string.md
rename to docs/Leetcode_Solutions/344._reverse_string.md
index 2346c22e6..0e4c0f4fb 100644
--- a/docs/leetcode/python/344._reverse_string.md
+++ b/docs/Leetcode_Solutions/344._reverse_string.md
@@ -1,47 +1,47 @@
-### 344. Reverse String
-
-
-
-题目:
-
-
-
-难度:
-Easy
-
-思路:
-
-不要脸的python AC code:
-
-
-```python
-class Solution(object):
- def reverseString(self, s):
- """
- :type s: str
- :rtype: str
- """
- return s[::-1]
-```
-
-因为python不支持item assignment
-
-所以如果非要用two pointer来做的话,那么会是这样
-
-```python
-class Solution(object):
- def reverseString(self, s):
- """
- :type s: str
- :rtype: str
- """
- lst = list(s)
- n = len(lst)
- start, end = 0, n - 1
-
- while start < end:
- lst[end], lst[start] = lst[start],lst[end]
- start += 1
- end -= 1
- return ''.join(lst)
-```
+### 344. Reverse String
+
+
+
+题目:
+
+
+
+难度:
+Easy
+
+思路:
+
+不要脸的python AC code:
+
+
+```python
+class Solution(object):
+ def reverseString(self, s):
+ """
+ :type s: str
+ :rtype: str
+ """
+ return s[::-1]
+```
+
+因为python不支持item assignment
+
+所以如果非要用two pointer来做的话,那么会是这样
+
+```python
+class Solution(object):
+ def reverseString(self, s):
+ """
+ :type s: str
+ :rtype: str
+ """
+ lst = list(s)
+ n = len(lst)
+ start, end = 0, n - 1
+
+ while start < end:
+ lst[end], lst[start] = lst[start],lst[end]
+ start += 1
+ end -= 1
+ return ''.join(lst)
+```
diff --git a/docs/leetcode/python/345._Reverse_Vowels_of_a_String.md b/docs/Leetcode_Solutions/345._Reverse_Vowels_of_a_String.md
similarity index 100%
rename from docs/leetcode/python/345._Reverse_Vowels_of_a_String.md
rename to docs/Leetcode_Solutions/345._Reverse_Vowels_of_a_String.md
diff --git a/docs/leetcode/python/349._intersection_of_two_arrays.md b/docs/Leetcode_Solutions/349._intersection_of_two_arrays.md
similarity index 94%
rename from docs/leetcode/python/349._intersection_of_two_arrays.md
rename to docs/Leetcode_Solutions/349._intersection_of_two_arrays.md
index eb4052736..2f79b8dd9 100644
--- a/docs/leetcode/python/349._intersection_of_two_arrays.md
+++ b/docs/Leetcode_Solutions/349._intersection_of_two_arrays.md
@@ -1,25 +1,25 @@
-### 349. Intersection of Two Arrays
-
-题目:
-
-
-
-难度:
-
-Easy
-
-
-
-Python一句话作弊
-
-```python
-class Solution(object):
- def intersection(self, nums1, nums2):
- """
- :type nums1: List[int]
- :type nums2: List[int]
- :rtype: List[int]
- """
- return list(set(nums1).intersection(nums2))
-```
-
+### 349. Intersection of Two Arrays
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+
+Python一句话作弊
+
+```python
+class Solution(object):
+ def intersection(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: List[int]
+ """
+ return list(set(nums1).intersection(nums2))
+```
+
diff --git a/docs/leetcode/python/350._intersection_of_two_arrays_ii.md b/docs/Leetcode_Solutions/350._intersection_of_two_arrays_ii.md
similarity index 94%
rename from docs/leetcode/python/350._intersection_of_two_arrays_ii.md
rename to docs/Leetcode_Solutions/350._intersection_of_two_arrays_ii.md
index b386d9179..d2a444772 100644
--- a/docs/leetcode/python/350._intersection_of_two_arrays_ii.md
+++ b/docs/Leetcode_Solutions/350._intersection_of_two_arrays_ii.md
@@ -1,65 +1,65 @@
-### 350. Intersection of Two Arrays II
-
-题目:
-
-
-
-
-难度:
-
-Easy
-
-
-sort之后用了双指针来走和看
-
-
-```python
-class Solution(object):
- def intersect(self, nums1, nums2):
- """
- :type nums1: List[int]
- :type nums2: List[int]
- :rtype: List[int]
- """
- nums1.sort()
- nums2.sort()
-
- l1 = len(nums1)
- l2 = len(nums2)
-
- p1 = 0
- p2 = 0
-
- res = []
-
- while p1 < l1 and p2 < l2:
- if nums1[p1] < nums2[p2]:
- p1 += 1
- elif nums1[p1] > nums2[p2]:
- p2 += 1
- else:
- res.append(nums1[p1])
- p1 += 1
- p2 += 1
- return res
-```
-
-两行版本
-```python
-class Solution(object):
- def intersect(self, nums1, nums2):
- """
- :type nums1: List[int]
- :type nums2: List[int]
- :rtype: List[int]
- """
- a, b = map(collections.Counter, (nums1, nums2))
- return list((a & b).elements())
-```
-
-
-
-
-
-
-
+### 350. Intersection of Two Arrays II
+
+题目:
+
+
+
+
+难度:
+
+Easy
+
+
+sort之后用了双指针来走和看
+
+
+```python
+class Solution(object):
+ def intersect(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: List[int]
+ """
+ nums1.sort()
+ nums2.sort()
+
+ l1 = len(nums1)
+ l2 = len(nums2)
+
+ p1 = 0
+ p2 = 0
+
+ res = []
+
+ while p1 < l1 and p2 < l2:
+ if nums1[p1] < nums2[p2]:
+ p1 += 1
+ elif nums1[p1] > nums2[p2]:
+ p2 += 1
+ else:
+ res.append(nums1[p1])
+ p1 += 1
+ p2 += 1
+ return res
+```
+
+两行版本
+```python
+class Solution(object):
+ def intersect(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: List[int]
+ """
+ a, b = map(collections.Counter, (nums1, nums2))
+ return list((a & b).elements())
+```
+
+
+
+
+
+
+
diff --git a/docs/leetcode/python/353._Design_Snake_Game.md b/docs/Leetcode_Solutions/353. Design Snake Game.md
similarity index 100%
rename from docs/leetcode/python/353._Design_Snake_Game.md
rename to docs/Leetcode_Solutions/353. Design Snake Game.md
diff --git a/docs/leetcode/python/364._Nested_List_Weight_Sum_II.md b/docs/Leetcode_Solutions/364. Nested List Weight Sum II.md
similarity index 100%
rename from docs/leetcode/python/364._Nested_List_Weight_Sum_II.md
rename to docs/Leetcode_Solutions/364. Nested List Weight Sum II.md
diff --git a/docs/leetcode/python/366._Find_Leaves_of_Binary_Tree.md b/docs/Leetcode_Solutions/366. Find Leaves of Binary Tree.md
similarity index 100%
rename from docs/leetcode/python/366._Find_Leaves_of_Binary_Tree.md
rename to docs/Leetcode_Solutions/366. Find Leaves of Binary Tree.md
diff --git a/docs/leetcode/python/367._valid_perfect_square.md b/docs/Leetcode_Solutions/367._valid_perfect_square.md
similarity index 98%
rename from docs/leetcode/python/367._valid_perfect_square.md
rename to docs/Leetcode_Solutions/367._valid_perfect_square.md
index c51099284..7bb7285d4 100644
--- a/docs/leetcode/python/367._valid_perfect_square.md
+++ b/docs/Leetcode_Solutions/367._valid_perfect_square.md
@@ -14,19 +14,19 @@ Medium
```
-class Solution(object):
- def isPerfectSquare(self, num):
- """
- :type num: int
- :rtype: bool
- """
- if num == 1 or num == 4 : return True
- for i in xrange(num//2):
- if i*i == num:
- return True
- elif i*i > num:
- return False
- return False
+class Solution(object):
+ def isPerfectSquare(self, num):
+ """
+ :type num: int
+ :rtype: bool
+ """
+ if num == 1 or num == 4 : return True
+ for i in xrange(num//2):
+ if i*i == num:
+ return True
+ elif i*i > num:
+ return False
+ return False
```
diff --git a/docs/leetcode/python/369._Plus_One_Linked_List.md b/docs/Leetcode_Solutions/369.Plus One Linked List.md
similarity index 100%
rename from docs/leetcode/python/369._Plus_One_Linked_List.md
rename to docs/Leetcode_Solutions/369.Plus One Linked List.md
diff --git a/docs/leetcode/python/371._sum_of_two_integers.md b/docs/Leetcode_Solutions/371._sum_of_two_integers.md
similarity index 99%
rename from docs/leetcode/python/371._sum_of_two_integers.md
rename to docs/Leetcode_Solutions/371._sum_of_two_integers.md
index f7e949deb..675aa9724 100644
--- a/docs/leetcode/python/371._sum_of_two_integers.md
+++ b/docs/Leetcode_Solutions/371._sum_of_two_integers.md
@@ -44,16 +44,16 @@ x y output
python没有左移,用c++来看
```
-class Solution {
-public:
- int getSum(int a, int b) {
- while (b != 0 ){
- int c = a & b;
- a = a ^ b;
- b = c << 1;
- }
- return a;
- }
+class Solution {
+public:
+ int getSum(int a, int b) {
+ while (b != 0 ){
+ int c = a & b;
+ a = a ^ b;
+ b = c << 1;
+ }
+ return a;
+ }
};
```
diff --git a/docs/leetcode/python/374._Guess_Number_Higher_or_Lower.md b/docs/Leetcode_Solutions/374._Guess_Number_Higher_or_Lower.md
similarity index 100%
rename from docs/leetcode/python/374._Guess_Number_Higher_or_Lower.md
rename to docs/Leetcode_Solutions/374._Guess_Number_Higher_or_Lower.md
diff --git a/docs/leetcode/python/377._combination_sum_iv.md b/docs/Leetcode_Solutions/377._combination_sum_iv.md
similarity index 100%
rename from docs/leetcode/python/377._combination_sum_iv.md
rename to docs/Leetcode_Solutions/377._combination_sum_iv.md
diff --git a/docs/leetcode/python/378._kth_smallest_element_in_a_sorted_matrix.md b/docs/Leetcode_Solutions/378._kth_smallest_element_in_a_sorted_matrix.md
similarity index 100%
rename from docs/leetcode/python/378._kth_smallest_element_in_a_sorted_matrix.md
rename to docs/Leetcode_Solutions/378._kth_smallest_element_in_a_sorted_matrix.md
diff --git a/docs/leetcode/python/380._Insert_Delete_GetRandom_O(1).md b/docs/Leetcode_Solutions/380. Insert Delete GetRandom O(1).md
similarity index 100%
rename from docs/leetcode/python/380._Insert_Delete_GetRandom_O(1).md
rename to docs/Leetcode_Solutions/380. Insert Delete GetRandom O(1).md
diff --git a/docs/leetcode/python/381._Insert_Delete_GetRandom_O(1)_-_Duplicates_allowed.md b/docs/Leetcode_Solutions/381. Insert Delete GetRandom O(1) - Duplicates allowed.md
similarity index 100%
rename from docs/leetcode/python/381._Insert_Delete_GetRandom_O(1)_-_Duplicates_allowed.md
rename to docs/Leetcode_Solutions/381. Insert Delete GetRandom O(1) - Duplicates allowed.md
diff --git a/docs/leetcode/python/382._linked_list_random_node.md b/docs/Leetcode_Solutions/382._linked_list_random_node.md
similarity index 100%
rename from docs/leetcode/python/382._linked_list_random_node.md
rename to docs/Leetcode_Solutions/382._linked_list_random_node.md
diff --git a/docs/leetcode/python/383._ransom_note.md b/docs/Leetcode_Solutions/383._ransom_note.md
similarity index 95%
rename from docs/leetcode/python/383._ransom_note.md
rename to docs/Leetcode_Solutions/383._ransom_note.md
index 82fc223d6..6a6ee16e7 100644
--- a/docs/leetcode/python/383._ransom_note.md
+++ b/docs/Leetcode_Solutions/383._ransom_note.md
@@ -1,53 +1,53 @@
-### 383. Ransom Note
-
-题目:
-
-
-
-难度 : Easy
-
-
-
-略微想了一下,用了一个dictionary来存magazine里面的单字出现的个数,然后来对应check是否可以用来组成ransomNote
-
-
-```python
-class Solution(object):
- def canConstruct(self, ransomNote, magazine):
- """
- :type ransomNote: str
- :type magazine: str
- :rtype: bool
- """
- maps = {}
- for i in magazine:
- if i in maps:
- maps[i] += 1
- else:
- maps[i] = 1
- for i in ransomNote:
- if i not in maps:
- return False
- else:
- maps[i] -= 1
- if maps[i] < 0:
- return False
- return True
-```
-解法2:
-
-```python
-class Solution(object):
- def canConstruct(self, ransomNote, magazine):
- """
- :type ransomNote: str
- :type magazine: str
- :rtype: bool
- """
- magCounter = collections.Counter(magazine)
- ranCounter = collections.Counter(ransomNote)
- for k in ranCounter:
- if ranCounter.get(k) > magCounter.get(k):
- return False
- return True
-```
+### 383. Ransom Note
+
+题目:
+
+
+
+难度 : Easy
+
+
+
+略微想了一下,用了一个dictionary来存magazine里面的单字出现的个数,然后来对应check是否可以用来组成ransomNote
+
+
+```python
+class Solution(object):
+ def canConstruct(self, ransomNote, magazine):
+ """
+ :type ransomNote: str
+ :type magazine: str
+ :rtype: bool
+ """
+ maps = {}
+ for i in magazine:
+ if i in maps:
+ maps[i] += 1
+ else:
+ maps[i] = 1
+ for i in ransomNote:
+ if i not in maps:
+ return False
+ else:
+ maps[i] -= 1
+ if maps[i] < 0:
+ return False
+ return True
+```
+解法2:
+
+```python
+class Solution(object):
+ def canConstruct(self, ransomNote, magazine):
+ """
+ :type ransomNote: str
+ :type magazine: str
+ :rtype: bool
+ """
+ magCounter = collections.Counter(magazine)
+ ranCounter = collections.Counter(ransomNote)
+ for k in ranCounter:
+ if ranCounter.get(k) > magCounter.get(k):
+ return False
+ return True
+```
diff --git a/docs/leetcode/python/384._Shuffle_an_Array.md b/docs/Leetcode_Solutions/384. Shuffle an Array.md
similarity index 100%
rename from docs/leetcode/python/384._Shuffle_an_Array.md
rename to docs/Leetcode_Solutions/384. Shuffle an Array.md
diff --git a/docs/leetcode/python/387._first_unique_character_in_a_string.md b/docs/Leetcode_Solutions/387._first_unique_character_in_a_string.md
similarity index 100%
rename from docs/leetcode/python/387._first_unique_character_in_a_string.md
rename to docs/Leetcode_Solutions/387._first_unique_character_in_a_string.md
diff --git a/docs/leetcode/python/388._Longest_Absolute_File_Path.md b/docs/Leetcode_Solutions/388._Longest_Absolute_File_Path.md
similarity index 100%
rename from docs/leetcode/python/388._Longest_Absolute_File_Path.md
rename to docs/Leetcode_Solutions/388._Longest_Absolute_File_Path.md
diff --git a/docs/Leetcode_Solutions/389._find_the_difference.md b/docs/Leetcode_Solutions/389._find_the_difference.md
new file mode 100644
index 000000000..a26bc73ae
--- /dev/null
+++ b/docs/Leetcode_Solutions/389._find_the_difference.md
@@ -0,0 +1,47 @@
+
+###389. Find the Difference
+
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+思路
+
+用两个hashmap分别来记录 s 和 t 中char的数量,一旦t[key] > s[key], output
+
+注意这个好的写法
+
+
+mapt[char] = mapt.get(char,0) + 1
+
+如果mapt[char]不存在,会默认给1
+
+
+
+```
+class Solution(object):
+ def findTheDifference(self, s, t):
+ """
+ :type s: str
+ :type t: str
+ :rtype: str
+ """
+ maps = {}
+ mapt = {}
+ for char in s:
+ maps[char] = maps.get(char,0) + 1
+ for char in t:
+ mapt[char] = mapt.get(char,0) + 1
+
+ for key in mapt:
+ if mapt[key] - maps.get(key,0) > 0:
+ return key
+```
+
+
diff --git a/docs/Leetcode_Solutions/392._is_subsequence.md b/docs/Leetcode_Solutions/392._is_subsequence.md
new file mode 100644
index 000000000..b7727173b
--- /dev/null
+++ b/docs/Leetcode_Solutions/392._is_subsequence.md
@@ -0,0 +1,69 @@
+
+###392. Is Subsequence
+
+
+题目:
+
+
+
+难度:
+
+Medium
+
+
+思路
+
+
+follow up question很有意思
+
+
+最naive的思路表现形式如下:
+
+超时
+
+```
+class Solution(object):
+ def isSubsequence(self, s, t):
+ """
+ :type s: str
+ :type t: str
+ :rtype: bool
+ """
+ if s == "": return True
+ for i in xrange(len(t)):
+ if t[i] == s[0]:
+ return self.isSubsequence(s[1:],t[i+1:])
+
+ return False
+```
+
+因为直接操作string的昂贵以及递归的昂贵
+
+同样的思路
+
+
+```
+class Solution(object):
+ def isSubsequence(self, s, t):
+ """
+ :type s: str
+ :type t: str
+ :rtype: bool
+ """
+ if s == "" : return True
+
+ ps, pt = 0, 0
+ lens, lent = len(s), len(t)
+ while ps < lens and pt < lent:
+ if s[ps] == t[pt]:
+ ps += 1
+ pt += 1
+ else:
+ pt += 1
+
+ return ps >= lens
+```
+
+AC
+
+
diff --git a/docs/leetcode/python/394._decode_string.md b/docs/Leetcode_Solutions/394._decode_string.md
similarity index 100%
rename from docs/leetcode/python/394._decode_string.md
rename to docs/Leetcode_Solutions/394._decode_string.md
diff --git a/docs/leetcode/python/400._Nth_Digit.md b/docs/Leetcode_Solutions/400. Nth Digit.md
similarity index 100%
rename from docs/leetcode/python/400._Nth_Digit.md
rename to docs/Leetcode_Solutions/400. Nth Digit.md
diff --git a/docs/leetcode/python/401._binary_watch.md b/docs/Leetcode_Solutions/401._binary_watch.md
similarity index 100%
rename from docs/leetcode/python/401._binary_watch.md
rename to docs/Leetcode_Solutions/401._binary_watch.md
diff --git a/docs/leetcode/python/404._sum_of_left_leaves.md b/docs/Leetcode_Solutions/404._sum_of_left_leaves.md
similarity index 100%
rename from docs/leetcode/python/404._sum_of_left_leaves.md
rename to docs/Leetcode_Solutions/404._sum_of_left_leaves.md
diff --git a/docs/leetcode/python/405._Convert_a_Number_to_Hexadecimal.md b/docs/Leetcode_Solutions/405. Convert a Number to Hexadecimal.md
similarity index 100%
rename from docs/leetcode/python/405._Convert_a_Number_to_Hexadecimal.md
rename to docs/Leetcode_Solutions/405. Convert a Number to Hexadecimal.md
diff --git a/docs/leetcode/python/406._Queue_Reconstruction_by_Height.md b/docs/Leetcode_Solutions/406._Queue_Reconstruction_by_Height.md
similarity index 100%
rename from docs/leetcode/python/406._Queue_Reconstruction_by_Height.md
rename to docs/Leetcode_Solutions/406._Queue_Reconstruction_by_Height.md
diff --git a/docs/leetcode/python/412._fizz_buzz.md b/docs/Leetcode_Solutions/412._fizz_buzz.md
similarity index 100%
rename from docs/leetcode/python/412._fizz_buzz.md
rename to docs/Leetcode_Solutions/412._fizz_buzz.md
diff --git a/docs/leetcode/python/413._Arithmetic_Slices.md b/docs/Leetcode_Solutions/413. Arithmetic Slices.md
similarity index 100%
rename from docs/leetcode/python/413._Arithmetic_Slices.md
rename to docs/Leetcode_Solutions/413. Arithmetic Slices.md
diff --git a/docs/leetcode/python/414._third_maximum_number.md b/docs/Leetcode_Solutions/414._third_maximum_number.md
similarity index 100%
rename from docs/leetcode/python/414._third_maximum_number.md
rename to docs/Leetcode_Solutions/414._third_maximum_number.md
diff --git a/docs/Leetcode_Solutions/415._add_strings.md b/docs/Leetcode_Solutions/415._add_strings.md
new file mode 100644
index 000000000..bfa319cdf
--- /dev/null
+++ b/docs/Leetcode_Solutions/415._add_strings.md
@@ -0,0 +1,61 @@
+###415. Add Strings
+
+题目:
+
+
+
+难度:
+Easy
+
+
+照抄2. Add Two Numbers的代码,超时
+
+```
+class Solution(object):
+ def addStrings(self, num1, num2):
+ """
+ :type num1: str
+ :type num2: str
+ :rtype: str
+ """
+ if num1 == '' or num1 == '0':
+ return num2
+ if num2 == '' or num2 == '0':
+ return num1
+ if int(num1[-1]) + int(num2[-1]) < 10:
+ num3 = str(int(num1[-1]) + int(num2[-1]) )
+ return self.addStrings(num1[:-1] , num2[:-1]) + num3
+ else:
+ num3 = str(int(num1[-1]) + int(num2[-1]) - 10)
+ return self.addStrings(self.addStrings(num1[:-1] , num2[:-1]),'1') + num3
+```
+
+
+
+换成迭代,并非递归再来尝试,看了别人的代码,真是精巧啊
+
+
+```
+class Solution(object):
+ def addStrings(self, num1, num2):
+ """
+ :type num1: str
+ :type num2: str
+ :rtype: str
+ """
+ result = []
+ carry = 0
+ idx1, idx2 = len(num1), len(num2)
+ while idx1 or idx2 or carry:
+ digit = carry
+ if idx1:
+ idx1 -= 1
+ digit += int(num1[idx1])
+ if idx2:
+ idx2 -= 1
+ digit += int(num2[idx2])
+ carry = digit > 9
+ result.append(str(digit % 10))
+ print result
+ return ''.join(result[::-1]) # 这里是reverse一下
+```
\ No newline at end of file
diff --git a/docs/Leetcode_Solutions/416. Partition Equal Subset Sum.md b/docs/Leetcode_Solutions/416. Partition Equal Subset Sum.md
new file mode 100644
index 000000000..1dee2d982
--- /dev/null
+++ b/docs/Leetcode_Solutions/416. Partition Equal Subset Sum.md
@@ -0,0 +1,87 @@
+### 416. Partition Equal Subset Sum
+
+
+
+题目:
+
+
+难度:
+
+Medium
+
+记得算法考试考过证明这个问题是NP的,当时用的是subset sum是NP,然后来证明这个?如果我们能找到一个subset的sum是整个array sum的一半,那么问题解决。subset sum我们又可以继续转化,转成背包问题。
+
+值得注意的是,这是subset sum,并不是subarray sum(这个明显要简单一些,因为subarray是连着的).
+
+subset sum也是有自己的[wikipedia page](https://en.wikipedia.org/wiki/Subset_sum_problem).
+
+
+
+当然,这也是一个subset problem,我们当然也可以用subset,加入和不加入,但是worst case O(2^n).
+
+
+
+对于subset sum的递推方程式:
+
+subset(arr,n,s) = subset(arr,n-1,s) or subset(arr, n-1, s- arrp[n-1])
+
+
+
+画表可以开始,第一列全为1,是因为不选全部可以为0
+
+
+
+```
+ 0 1 2 3 4 5 6 8 9 10 11
+0 1 0 0 0 0 0 0 0 0 0 0
+1 1 1 0 0 0 0 0 0 0 0 0
+5 1 1 0 0 0 1 1 0 0 0 0
+5 1 1 0 0 0 1 1 0 0 0 1
+```
+
+
+
+所以伪多项式算法写出来
+
+AC代码
+
+
+
+```
+class Solution(object):
+ def canPartition(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: bool
+ """
+ def subset(nums, s):
+ dp = [[0 for i in range(s+1) ] for j in range(len(nums)+1)]
+
+ dp[0][0] = 1
+ # init the first col
+ for i in range(len(nums)+1
+ dp[i][0] = 1
+
+ for i in range(1,len(nums)+1):
+ for j in range(1,s+1):
+ if dp[i-1][j] == 1:
+ dp[i][j] = 1
+ elif j >= nums[i-1] and dp[i-1][j-nums[i-1]] ==1:
+ dp[i][j] = 1
+ return dp[-1][-1] == 1
+
+
+
+ total = sum(nums)
+ if total % 2 == 1:
+ return False
+ else:
+ half = total / 2
+ return subset(nums,half) == 1
+
+```
+
+
+
+当然可以小调整,比如一旦发现,提前return等等,但是时间上依旧是后20%,不知道时间上快很多的人是如何做到的|||
+
diff --git a/docs/leetcode/python/421._Maximum_XOR_of_Two_Numbers_in_an_Array.md b/docs/Leetcode_Solutions/421._Maximum_XOR_of_Two_Numbers_in_an_Array.md
similarity index 100%
rename from docs/leetcode/python/421._Maximum_XOR_of_Two_Numbers_in_an_Array.md
rename to docs/Leetcode_Solutions/421._Maximum_XOR_of_Two_Numbers_in_an_Array.md
diff --git a/docs/leetcode/python/422._Valid_Word_Square.md b/docs/Leetcode_Solutions/422. Valid Word Square.md
similarity index 100%
rename from docs/leetcode/python/422._Valid_Word_Square.md
rename to docs/Leetcode_Solutions/422. Valid Word Square.md
diff --git a/docs/leetcode/python/434._number_of_segments_in_a_string.md b/docs/Leetcode_Solutions/434._number_of_segments_in_a_string.md
similarity index 94%
rename from docs/leetcode/python/434._number_of_segments_in_a_string.md
rename to docs/Leetcode_Solutions/434._number_of_segments_in_a_string.md
index a1aa617b2..424472a5a 100644
--- a/docs/leetcode/python/434._number_of_segments_in_a_string.md
+++ b/docs/Leetcode_Solutions/434._number_of_segments_in_a_string.md
@@ -1,27 +1,27 @@
-### 434. Number of Segments in a String
-
-题目:
-
-
-
-难度:
-
-Easy
-
-
-作弊神器Python
-
-
-```python
-class Solution(object):
- def countSegments(self, s):
- """
- :type s: str
- :rtype: int
- """
- return len(s.split())
-```
-
-不过对于比如C++这种语言来说,应该是O(N),扫一圈应该也能得到正确答案
-
-总之拿Python做string的题目就是作弊啊
+### 434. Number of Segments in a String
+
+题目:
+
+
+
+难度:
+
+Easy
+
+
+作弊神器Python
+
+
+```python
+class Solution(object):
+ def countSegments(self, s):
+ """
+ :type s: str
+ :rtype: int
+ """
+ return len(s.split())
+```
+
+不过对于比如C++这种语言来说,应该是O(N),扫一圈应该也能得到正确答案
+
+总之拿Python做string的题目就是作弊啊
diff --git a/docs/leetcode/python/437._path_sum_iii.md b/docs/Leetcode_Solutions/437._path_sum_iii.md
similarity index 100%
rename from docs/leetcode/python/437._path_sum_iii.md
rename to docs/Leetcode_Solutions/437._path_sum_iii.md
diff --git a/docs/leetcode/python/438._Find_All_Anagrams_in_a_String.md b/docs/Leetcode_Solutions/438._Find_All_Anagrams_in_a_String.md
similarity index 100%
rename from docs/leetcode/python/438._Find_All_Anagrams_in_a_String.md
rename to docs/Leetcode_Solutions/438._Find_All_Anagrams_in_a_String.md
diff --git a/docs/leetcode/python/439._Ternary_Expression_Parser.md b/docs/Leetcode_Solutions/439. Ternary Expression Parser.md
similarity index 100%
rename from docs/leetcode/python/439._Ternary_Expression_Parser.md
rename to docs/Leetcode_Solutions/439. Ternary Expression Parser.md
diff --git a/docs/leetcode/python/441._arranging_coins.md b/docs/Leetcode_Solutions/441._arranging_coins.md
similarity index 100%
rename from docs/leetcode/python/441._arranging_coins.md
rename to docs/Leetcode_Solutions/441._arranging_coins.md
diff --git a/docs/leetcode/python/448._Find_All_Numbers_Disappeared_in_an_Array.md b/docs/Leetcode_Solutions/448._Find_All_Numbers_Disappeared_in_an_Array.md
similarity index 100%
rename from docs/leetcode/python/448._Find_All_Numbers_Disappeared_in_an_Array.md
rename to docs/Leetcode_Solutions/448._Find_All_Numbers_Disappeared_in_an_Array.md
diff --git a/docs/leetcode/python/450._Delete_Node_in_a_BST.md b/docs/Leetcode_Solutions/450. Delete Node in a BST.md
similarity index 100%
rename from docs/leetcode/python/450._Delete_Node_in_a_BST.md
rename to docs/Leetcode_Solutions/450. Delete Node in a BST.md
diff --git a/docs/leetcode/python/453._Minimum_Moves_to_Equal_Array_Elements.md b/docs/Leetcode_Solutions/453._Minimum_Moves_to_Equal_Array_Elements.md
similarity index 100%
rename from docs/leetcode/python/453._Minimum_Moves_to_Equal_Array_Elements.md
rename to docs/Leetcode_Solutions/453._Minimum_Moves_to_Equal_Array_Elements.md
diff --git a/docs/leetcode/python/459._Repeated_Substring_Pattern.md b/docs/Leetcode_Solutions/459._Repeated_Substring_Pattern.md
similarity index 100%
rename from docs/leetcode/python/459._Repeated_Substring_Pattern.md
rename to docs/Leetcode_Solutions/459._Repeated_Substring_Pattern.md
diff --git a/docs/leetcode/python/461._Hamming_Distance.md b/docs/Leetcode_Solutions/461._Hamming Distance.md
similarity index 100%
rename from docs/leetcode/python/461._Hamming_Distance.md
rename to docs/Leetcode_Solutions/461._Hamming Distance.md
diff --git a/docs/leetcode/python/463._Island_Perimeter.md b/docs/Leetcode_Solutions/463._Island_Perimeter.md
similarity index 100%
rename from docs/leetcode/python/463._Island_Perimeter.md
rename to docs/Leetcode_Solutions/463._Island_Perimeter.md
diff --git a/docs/leetcode/python/467._Unique_Substrings_in_Wraparound_String.md b/docs/Leetcode_Solutions/467._Unique_Substrings_in_Wraparound_String.md
similarity index 100%
rename from docs/leetcode/python/467._Unique_Substrings_in_Wraparound_String.md
rename to docs/Leetcode_Solutions/467._Unique_Substrings_in_Wraparound_String.md
diff --git a/docs/leetcode/python/469._Convex_Polygon.md b/docs/Leetcode_Solutions/469. Convex Polygon.md
similarity index 100%
rename from docs/leetcode/python/469._Convex_Polygon.md
rename to docs/Leetcode_Solutions/469. Convex Polygon.md
diff --git a/docs/leetcode/python/476._Number_Complement.md b/docs/Leetcode_Solutions/476._Number_Complement.md
similarity index 100%
rename from docs/leetcode/python/476._Number_Complement.md
rename to docs/Leetcode_Solutions/476._Number_Complement.md
diff --git a/docs/leetcode/python/477._Total_Hamming_Distance.md b/docs/Leetcode_Solutions/477._Total_Hamming_Distance.md
similarity index 100%
rename from docs/leetcode/python/477._Total_Hamming_Distance.md
rename to docs/Leetcode_Solutions/477._Total_Hamming_Distance.md
diff --git a/docs/leetcode/python/485._Max_Consecutive_Ones.md b/docs/Leetcode_Solutions/485._Max_Consecutive_Ones.md
similarity index 100%
rename from docs/leetcode/python/485._Max_Consecutive_Ones.md
rename to docs/Leetcode_Solutions/485._Max_Consecutive_Ones.md
diff --git a/docs/leetcode/python/587._Erect_the_Fence.md b/docs/Leetcode_Solutions/587._Erect_the_Fence .md
similarity index 98%
rename from docs/leetcode/python/587._Erect_the_Fence.md
rename to docs/Leetcode_Solutions/587._Erect_the_Fence .md
index 301c1c1b1..f61d75b3c 100644
--- a/docs/leetcode/python/587._Erect_the_Fence.md
+++ b/docs/Leetcode_Solutions/587._Erect_the_Fence .md
@@ -130,4 +130,4 @@ Author: Keqi Huang
If you like it, please spread your support
-
+
diff --git a/docs/leetcode/python/599._Minimum_Index_Sum_of_Two_Lists.md b/docs/Leetcode_Solutions/599._Minimum_Index_Sum_of_Two_Lists.md
similarity index 94%
rename from docs/leetcode/python/599._Minimum_Index_Sum_of_Two_Lists.md
rename to docs/Leetcode_Solutions/599._Minimum_Index_Sum_of_Two_Lists.md
index 819bcff9d..1682fab62 100644
--- a/docs/leetcode/python/599._Minimum_Index_Sum_of_Two_Lists.md
+++ b/docs/Leetcode_Solutions/599._Minimum_Index_Sum_of_Two_Lists.md
@@ -55,4 +55,4 @@ Author: Keqi Huang
If you like it, please spread your support
-
+
diff --git a/docs/leetcode/python/647._Palindromic_Substrings.md b/docs/Leetcode_Solutions/647._Palindromic_Substrings.md
similarity index 95%
rename from docs/leetcode/python/647._Palindromic_Substrings.md
rename to docs/Leetcode_Solutions/647._Palindromic_Substrings.md
index 22791ab64..8ee312ad5 100644
--- a/docs/leetcode/python/647._Palindromic_Substrings.md
+++ b/docs/Leetcode_Solutions/647._Palindromic_Substrings.md
@@ -21,17 +21,17 @@ Manacher算法增加两个辅助变量id和mx,其中id表示最大回文子串
下面,令j = 2*id - i,也就是说j是i关于id的对称点。
- 当 mx - i > P[j] 的时候,以S[j]为中心的回文子串包含在以S[id]为中心的回文子串中,由于i和j对称,以S[i]为中心的回文子串必然包含在以S[id]为中心的回文子串中,所以必有P[i] = P[j];
-
+
- 当 P[j] >= mx - i 的时候,以S[j]为中心的回文子串不一定完全包含于以S[id]为中心的回文子串中,但是基于对称性可知,下图中两个绿框所包围的部分是相同的,也就是说以S[i]为中心的回文子串,其向右至少会扩张到mx的位置,也就是说 P[i] >= mx - i。至于mx之后的部分是否对称,再具体匹配。
-
+
所以P[i] >= Min(P[2 * id - i], mx - i),因为以j为中心的绘回文子串的左边界可能会比mx关于id的对称点要大,此时只能证明P[i]=P[2 * id - i]
- 此外,对于 mx <= i 的情况,因为无法对 P[i]做更多的假设,只能让P[i] = 1,然后再去匹配。
此题还可以借鉴我leetcode第5题的解析,
[thining-in-lc-5](https://github.com/Lisanaaa/thinking_in_lc/blob/master/005._longest_palindromic_substring.md)
这道题的基本思想是将以每一个字符为中心的回文子串个数相加,还是用一个小例子来解释
-
+
其实,以‘#’为中心的回文子串就代表这个子串的长度是偶数,类似于'abba'这种
但是其实这个字符本身也是一个回文子串,所以叠加的形式是count += (P[i]+1)/2,为什么呢,以下是解释:
- 对于每一个以字符‘#’为中心的回文子串,其P值绝对是偶数,所以```(P[i]+1)/2 = P[i]/2```,并不影响
diff --git a/docs/leetcode/python/657._Judge_Route_Circle.md b/docs/Leetcode_Solutions/657._Judge_Route_Circle.md
similarity index 100%
rename from docs/leetcode/python/657._Judge_Route_Circle.md
rename to docs/Leetcode_Solutions/657._Judge_Route_Circle.md
diff --git a/docs/leetcode/python/665._Non-decreasing_Array.md b/docs/Leetcode_Solutions/665._Non-decreasing_Array.md
similarity index 100%
rename from docs/leetcode/python/665._Non-decreasing_Array.md
rename to docs/Leetcode_Solutions/665._Non-decreasing_Array.md
diff --git a/docs/leetcode/python/672._Bulb_Switcher_II.md b/docs/Leetcode_Solutions/672._Bulb_Switcher_II.md
similarity index 100%
rename from docs/leetcode/python/672._Bulb_Switcher_II.md
rename to docs/Leetcode_Solutions/672._Bulb_Switcher_II.md
diff --git a/docs/leetcode/python/681._Next_Closest_Time.md b/docs/Leetcode_Solutions/681._Next_Closest_Time.md
similarity index 100%
rename from docs/leetcode/python/681._Next_Closest_Time.md
rename to docs/Leetcode_Solutions/681._Next_Closest_Time.md
diff --git a/docs/leetcode/python/682._Baseball_Game.md b/docs/Leetcode_Solutions/682._Baseball_Game.md
similarity index 100%
rename from docs/leetcode/python/682._Baseball_Game.md
rename to docs/Leetcode_Solutions/682._Baseball_Game.md
diff --git a/docs/leetcode/python/687._Longest_Univalue_Path.md b/docs/Leetcode_Solutions/687._Longest_Univalue_Path.md
similarity index 100%
rename from docs/leetcode/python/687._Longest_Univalue_Path.md
rename to docs/Leetcode_Solutions/687._Longest_Univalue_Path.md
diff --git a/docs/leetcode/python/740._delete_and_earn.md b/docs/Leetcode_Solutions/740._delete_and_earn.md
similarity index 100%
rename from docs/leetcode/python/740._delete_and_earn.md
rename to docs/Leetcode_Solutions/740._delete_and_earn.md
diff --git a/docs/leetcode/python/760._Find_Anagram_Mappings.md b/docs/Leetcode_Solutions/760._Find_Anagram_Mappings.md
similarity index 100%
rename from docs/leetcode/python/760._Find_Anagram_Mappings.md
rename to docs/Leetcode_Solutions/760._Find_Anagram_Mappings.md
diff --git a/docs/Leetcode_Solutions/README.md b/docs/Leetcode_Solutions/README.md
new file mode 100644
index 000000000..c477b8c84
--- /dev/null
+++ b/docs/Leetcode_Solutions/README.md
@@ -0,0 +1 @@
+# Leetcode solutions and summarizations!
diff --git "a/docs/Leetcode_Solutions/Summarization/Binary Search \344\270\215\346\230\223\345\206\231.md" "b/docs/Leetcode_Solutions/Summarization/Binary Search \344\270\215\346\230\223\345\206\231.md"
new file mode 100644
index 000000000..bd65c3c65
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/Binary Search \344\270\215\346\230\223\345\206\231.md"
@@ -0,0 +1,91 @@
+### Binary Search 不易写
+
+
+
+坊间一直有binary search不容易写对的传言,一写还真是|||
+
+值得注意的是这里的u位置上的元素搜索是不包括的
+
+先献上递归版本伪码:
+
+```
+function Binary_Search(x, A, l, u)
+ if u < l then
+ No found error
+ else
+ m ← l + [ ( u - l ) / 2 ] //避免溢出
+ if A[m] = x then
+ return m
+ if x < A[m] then
+ return Binary-Search(x, A, l, m - 1)
+ else
+ return Binary-Search(x, A, m + 1, u)
+```
+
+
+
+迭代版本伪码:
+
+
+
+```
+function Binary_Search(x, A, l, u)
+ while l < u do
+ m ← l + [ ( u - l ) / 2 ]
+ if A[m] = x then
+ return m
+ if x < A[m] then
+ u ← m - 1
+ else
+ l ← m + 1
+ return NIL
+
+```
+
+
+
+
+
+或者这样,正确代码
+
+```python
+def binarySearch(nums, target):
+ l, r = 0, len(nums) -1
+ while l <= r:
+ mid = l + ((r-l) >> 2)
+ if nums[mid] > target:
+ r = mid - 1
+ elif nums[mid] < target:
+ l = mid + 1
+ else:
+ return mid
+ return -1
+```
+
+
+
+
+
+这样就不对
+
+```
+def binarySearch(nums, target):
+ l, r = 0, len(nums)
+ while l < r:
+ mid = (l+r) / 2
+ if nums[mid] == target:
+ return mid
+ elif nums[mid] > target:
+ r = mid - 1
+ else:
+ l = mid + 1
+ return -1
+
+print binarySearch([1,2,3,4,5,6],1)
+// → -1
+```
+
+
+
+之所以binary Search很容易不对,是因为边界状况,所以觉得一上来应当检查边界状况
+
diff --git a/docs/Leetcode_Solutions/Summarization/Data Structure and Algorthim Review.md b/docs/Leetcode_Solutions/Summarization/Data Structure and Algorthim Review.md
new file mode 100644
index 000000000..61c9c7d68
--- /dev/null
+++ b/docs/Leetcode_Solutions/Summarization/Data Structure and Algorthim Review.md
@@ -0,0 +1,101 @@
+
+
+### Data Structure and Algorthim Review
+
+
+
+- [x] Binary Search Tree
+
+ - [x] 插入
+
+ • 如果树为空,创建一个叶子节点,令该节点的key = k;
+ • 如果k小于根节点的key,将它插入到左子树中;
+ • 如果k大于根节点的key,将它插入到右子树中。
+
+ - [x] 遍历
+
+ • 前序: 根,左,右
+
+ • 中序:左,根,右 **有序**
+
+ • 后序:左,右,根
+
+ - [x] 搜索
+
+ - look up : 是否存在
+
+ • 如果树为空,搜索失败;
+ • 如果根节点的key等于待搜索的值,搜索成功,返回根节点作为结果;
+ • 如果待搜索的值小于根节点的key,继续在左子树中递归搜索;
+ • 否则,待搜索的值大于根节点的key,继续在右子树中递归搜索。
+
+ - 最大元素和最小元素
+
+ • 最右和最左
+
+ - 前驱(Successor)和后继(predecessor)
+
+ 给定元素x,它的后继元素y是满足y > x的最小值
+
+ • 如果x所在的节点有一个非空的右子树,则右子树中的最小值就是答案
+
+ • 否则我们需要向上回溯,找到最近的一个祖先,使得该祖先的左侧孩子,也为x的祖 先。
+
+
+ - [x] 删除
+
+ • 如果x没有子节点,或者只有一个孩子,直接将x“切下”;
+
+ • 否则,x有两个孩子,我们用其右子树中的最小值替换掉x,然后将右子树中的这一最小值“切掉”。
+
+
+
+
+
+
+- [x] 递归
+ - [x] 入门
+
+ - 回文
+ - 阶乘 factorial, 慕指数
+ - 分形
+ - Tower of Hanoi
+
+ - [x] 排列 Permutation
+
+ - [x] 子集 Subsets
+
+ - [ ] backtracking
+
+
+- [x] dynamic programming
+
+ - coin change
+
+ - longest common subsequence
+
+ - edit distance
+
+
+
+
+
+
+-[ ] majority element
+
+
+
+- [ ] 随机
+ - 水塘抽样
+ - 洗牌
+
+
+-[ ] 荷兰旗问题
+
+
+-[ ] quick select
+
+
+-[ ] median of two sorted array
+-[ ] regular expression
+
diff --git a/docs/Leetcode_Solutions/Summarization/Dynamic Programming.md b/docs/Leetcode_Solutions/Summarization/Dynamic Programming.md
new file mode 100644
index 000000000..102d032c3
--- /dev/null
+++ b/docs/Leetcode_Solutions/Summarization/Dynamic Programming.md
@@ -0,0 +1,48 @@
+### Dynamic Programming
+
+
+
+- Fibonacci Numbers
+- Shortest Path (no cycles)
+
+
+
+
+
+
+
+- subproblems
+
+- guessing
+
+- relate subproblems
+
+- recurse & memoize (bulid DP table)
+
+- solve original problem
+
+
+
+
+
+
+
+
+
+
+
+
+感觉DP有几类:
+
+- 容易写出递推公式的
+
+- 画表更容易理解的
+
+
+
+* DP ≈ “controlled brute force”
+
+* DP ≈ recursion + re-use
+
+
+
diff --git "a/docs/Leetcode_Solutions/Summarization/Introduction to String Searching Algorithms \342\200\223 topcoder.pdf" "b/docs/Leetcode_Solutions/Summarization/Introduction to String Searching Algorithms \342\200\223 topcoder.pdf"
new file mode 100644
index 000000000..110950bf9
Binary files /dev/null and "b/docs/Leetcode_Solutions/Summarization/Introduction to String Searching Algorithms \342\200\223 topcoder.pdf" differ
diff --git "a/docs/Leetcode_Solutions/Summarization/Java\345\220\204\347\247\215\347\261\273\345\236\213\347\232\204\350\275\254\346\215\242.md" "b/docs/Leetcode_Solutions/Summarization/Java\345\220\204\347\247\215\347\261\273\345\236\213\347\232\204\350\275\254\346\215\242.md"
new file mode 100644
index 000000000..c1d3e5522
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/Java\345\220\204\347\247\215\347\261\273\345\236\213\347\232\204\350\275\254\346\215\242.md"
@@ -0,0 +1,239 @@
+之前在写java程序的时候,经常会遇到很多的需要需要转换基础数据类型的情况,然后我就一直去记录这些情况,今天做了一下总结,当然转换的方法肯定不止我写的这些,有的我可能只会写其中的一种,以后再遇到其他的情况的话,我会慢慢来补充,希望这篇文章会对大家能有所帮助。
+
+------
+
+# String的转换
+
+首先介绍一下String类型的转换,一般遇到的情况可能会有以下几种:Strng转int,String转long,String转byte数组,String转float,下面主要介绍这四种情况。
+
+## String转int
+
+把String类型转换为int类型,常用的有以下三种方法:
+
+```
+public class StringToInt {
+ public static void main(String[] args) {
+ String number = "123456";
+ int num1 = Integer.parseInt(number);//使用Integer的parseInt方法
+ int num2 = new Integer(number);//强制转换
+ int num3 = Integer.valueOf(number).intValue();//先转Integer类型,再调用intValue()转为int
+ }
+}
+```
+
+## String转long
+
+把String类型转换为long类型的方法跟上面的方法类似。
+
+```
+public class StringToLong {
+ public static void main(String[] args) {
+ String number = "1234567890";
+ long num1 = Long.parseLong(number);//调用Long类型的parseLong方法
+ long num2 = new Long(number);//强制转换
+ long num3 = Long.valueOf(number).longValue();//先转换Long类型,再使用longValue方法转为long
+ }
+}
+```
+
+## String转float
+
+把String类型转换为float类型的方法也跟上面的类似。
+
+```
+public class StringToFloat {
+ public static void main(String[] args) {
+ String number = "1234.202";
+ float num1 = Float.parseFloat(number);//调用Float的parseFloat方法
+ float num2 = new Float(number);//强制转换
+ float num3 = Float.valueOf(number).floatValue();//先转为Float类型再使用floatValue转为float
+ }
+}
+```
+
+## String转byte[]
+
+String类型转byte数组方法一般使用String类自带的`getBytes()`方法。
+
+```
+public class StringToByte {
+ public static void main(String[] args) {
+ byte[] num = new byte[200];
+ String number = "1234567890";
+ num = number.getBytes();
+ }
+}
+```
+
+这里补充一个path类型转换为String类型的方法:
+
+```
+String fileName=path.getFileName().toString();
+```
+
+------
+
+# long类型转换
+
+long类型的转换,这一部分用的情况也很多,下面介绍几种常见的情况。
+
+## long转String
+
+long类型转String类型,这里主要介绍三种方法:
+
+```
+public class LongToString {
+ public static void main(String[] args) {
+ long number = 1234567890l;
+ String num1 = Long.toString(number);//Long的tostring方法
+ String num2 = String.valueOf(number);//使用String的valueOf方法
+ String num3 = "" + number;//这个应该属于强制转换吧
+ }
+}
+```
+
+## long转int
+
+long类型转换为int类型,这里也主要介绍三种方法:
+
+```
+public class LongToInt {
+ public static void main(String[] args) {
+ long number = 121121121l;
+ int num1 = (int) number;// 强制类型转换
+ int num2 = new Long(number).intValue();// 调用intValue方法
+ int num3 = Integer.parseInt(String.valueOf(number));// 先把long转换位字符串String,然后转换为Integer
+ }
+}
+```
+
+## long与byte数组的相互转换
+
+一直都感觉byte数组转换比较繁琐,这里也不再叙述,我就给出一篇别人的博客让大家作为参考吧,这里面byte数组与多种数据类型的转换——[ java Byte和各数据类型(short,int,long,float,double)之间的转换](http://blog.csdn.net/cshichao/article/details/9813973)
+
+------
+
+# int类型的转换
+
+int类型的转换也是我们经常使用的情况,下面也主要介绍几种常见的情况。
+
+## int转String
+
+int类型转换为String类型与long转String的类似,一般也有以下三种方法。
+
+```
+public class IntToString {
+ public static void main(String[] args) {
+ int number = 121121;
+ String num1 = Integer.toString(number);//使用Integer的toString方法
+ String num2 = String.valueOf(number);//使用String的valueOf方法
+ String num3 = "" + number;//也是强制转换吧
+ }
+}
+```
+
+## int与Byte的相互转换
+
+关于int类型与byte[]数组的转换,一般情况下,我们使用条件都是在这里转换过来,在另外一个地方就要转换回来,这里介绍两种int与byte数组互相转换的方式。
+
+```
+//int类型转换为byte[]数组
+public static byte[] intToByteArray(int i) {
+ byte[] result = new byte[4];
+ // 由高位到低位
+ result[0] = (byte) ((i >> 24) & 0xFF);
+ result[1] = (byte) ((i >> 16) & 0xFF);
+ result[2] = (byte) ((i >> 8) & 0xFF);
+ result[3] = (byte) (i & 0xFF);
+ return result;
+}
+
+//byte数组转换为int类型
+public static int byteArrayToInt(byte[] bytes) {
+ int value = 0;
+ // 由高位到低位
+ for (int i = 0; i < 4; i++) {
+ int shift = (4 - 1 - i) * 8;
+ value += (bytes[i] & 0x000000FF) << shift;// 往高位游
+ }
+ return value;
+}
+```
+
+还有一种为:
+
+```
+//int类型转换为byte[]数组
+public static byte[] intToByteArray(int x) {
+ byte[] bb = new byte[4];
+ bb[3] = (byte) (x >> 24);
+ bb[2] = (byte) (x >> 16);
+ bb[1] = (byte) (x >> 8);
+ bb[0] = (byte) (x >> 0);
+ return bb;
+}
+
+//byte数组转换为int类型
+public static int byteArrayToInt(byte[] bb) {
+ return (int) ((((bb[3] & 0xff) << 24) | ((bb[2] & 0xff) << 16) | ((bb[1] & 0xff) << 8) | ((bb[0] & 0xff) << 0)));
+}
+```
+
+## int转long
+
+int类型转换为long类型的情况并不是大多,这里主要接收几种转换方法:
+
+```
+public class IntToLong {
+ public static void main(String[] args) {
+ int number = 123111;
+ long num1 = (long) number;//强制
+ long num2 = Long.parseLong(new Integer(number).toString());//先转String再进行转换
+ long num3 = Long.valueOf(number);
+ }
+}
+```
+
+## int转Interger
+
+int类型转换为Interger类型的情况,我是基本上每怎么遇到过,在这里也上网查询一些资料找到了两种方法。
+
+```
+public class IntToInterge {
+ public static void main(String[] args) {
+ int number = 123456;
+ Integer num1 = Integer.valueOf(number);
+ Integer num2 = new Integer(number);
+ }
+}
+```
+
+------
+
+# byte数组的转换
+
+关于byte数组的转换,上面有几个都是它们只见相互转换的,所以这里就不再介绍那么多,只介绍一个byte数组转换String类型的方法,其他的类型可以通过String类型再进行转换。
+
+byte数组转String类型的方法经常用的可能就是下面这种方法。
+
+```
+public class ByteToString {
+ public static void main(String[] args) {
+ byte[] number = "121121".getBytes();
+ String num1 = new String(number);
+ }
+}
+```
+
+------
+
+最后简单补充以下Java基本数据类型的一些知识:
+
+| 类型 | 字节数 | 类名称 | 范围 |
+| ------ | ---- | -------- | ---------------------------------------- |
+| int | 4字节 | Interger | -2147483648 ~ 2147483647 |
+| short | 2字节 | Short | -32768 ~ 32767 |
+| long | 8字节 | Long | -9223372036854775808 ~ 9223372036854775807 |
+| byte | 1字节 | Byte | -128 ~ 127 |
+| float | 4字节 | Float | |
+| double | 8字节 | Double | |
\ No newline at end of file
diff --git "a/docs/Leetcode_Solutions/Summarization/LinkedList\346\212\200\345\267\247.md" "b/docs/Leetcode_Solutions/Summarization/LinkedList\346\212\200\345\267\247.md"
new file mode 100644
index 000000000..677a083a2
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/LinkedList\346\212\200\345\267\247.md"
@@ -0,0 +1,118 @@
+# LinkedList
+
+结点定义如下:
+
+ class ListNode(object):
+ def __init__(self, x):
+ self.val = x
+ self.next = None
+
+
+可以使用的技巧包括:
+
+
+## Dummy head
+
+有的时候因为边界条件,需要判定是否是list的head,因为处理起来会有些不同,而创造一个dummy head则可以极大的解决一些问题。
+
+```
+ dummy = ListNode(-1)
+ dummy.next = head
+```
+
+## 双指针
+
+- 19. Remove Nth Node From End of List
+
+两个指针p,q, q先走n步,然后p和q一起走,直到q走到结点,删除p.next解决。
+
+理解: 先走了n步,q始终在p前方n个,这样q走到末尾,p的下一个则是距离尾端n个的,画个图还是容易理解。
+
+
+- 160. Intersection of Two Linked Lists
+
+如果两个linkedlist有intersection的话,可以看到,其实如果一开始我们就走到b2的话,那么我们就可以两个pointer一个一个的对比,到哪一个地址一样,接下来就是intersection部分。
+
+就一开始把长的那条list走掉多余部分。
+还有这里保证了是无环的状况
+
+
+
+```
+A: a1 → a2
+ ↘
+ c1 → c2 → c3
+ ↗
+B: b1 → b2 → b3
+```
+
+
+## 快慢指针
+
+- 141. Linked List Cycle
+
+用两个指针,一个每次走两步,一个每次走一步,如果慢的最终和快的相遇,那么说明有环,否则没有环,直观的理解是如果两个跑的速度不一的人进操场跑步,那么最终慢的会追上快的.
+
+
+
+## Reverse Linked List
+
+- 206. Reverse Linked List
+
+loop版本用prev, cur ,nxt 三个指针过一遍,recursion版本如下,可以再消化消化
+
+```
+class Solution(object):
+ def reverseList(self, head):
+ """
+ :type head: ListNode
+ :rtype: ListNode
+ """
+ return self.doReverse(head, None)
+
+
+ def doReverse(self, head, newHead):
+ if head == None:
+ return newHead
+ nxt = head.next
+ head.next = newHead
+ return self.doReverse(nxt, head)
+```
+
+
+## 寻找LinkedList中间项
+
+依旧使用双指针,快慢指针:快指针每次走两步,慢指针每次走一步,快指针如果到头了,那么慢指针也会在中间了,这个中间可以考量,如果是奇数的话必然是中间。
+
+如果是偶数则是偏前面的中间一项
+
+```
+1 -> 2 -> 3 -> 4: 2
+1 -> 2 -> 3 -> 4 -> 5 -> 6 : 3
+1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 : 4
+
+```
+
+算法:
+
+```
+
+def findMid(head):
+ if head == None or head.next == None:
+ return head
+
+ slow = head
+ fast = head
+
+ while fast.next and fast.next.next:
+ slow = slow.next
+ fast = fast.next.next
+
+ return slow
+```
+
+
+
+
+
+
diff --git a/docs/Leetcode_Solutions/Summarization/Maximal Square.pdf b/docs/Leetcode_Solutions/Summarization/Maximal Square.pdf
new file mode 100644
index 000000000..235cd3b86
Binary files /dev/null and b/docs/Leetcode_Solutions/Summarization/Maximal Square.pdf differ
diff --git "a/docs/Leetcode_Solutions/Summarization/Python\345\210\267\351\242\230\346\212\200\345\267\247\347\254\224\350\256\260.py" "b/docs/Leetcode_Solutions/Summarization/Python\345\210\267\351\242\230\346\212\200\345\267\247\347\254\224\350\256\260.py"
new file mode 100644
index 000000000..69fed8912
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/Python\345\210\267\351\242\230\346\212\200\345\267\247\347\254\224\350\256\260.py"
@@ -0,0 +1,91 @@
+# python有无数奇技淫巧和许多人不知道的秘密,这里用简洁的语言一条条表述出来,不断更新, 大家一起贡献!
+
+# 1. python 排序
+# 用lst.sort() 而不是nlst = sorted(lst), 区别在于lst.sort()是 in-place sort,改变lst, sorted会创建新list,成本比较高。
+
+# 2. xrange和range的区别
+# range会产生list存在memory中,xrange更像是生成器,generate on demand所以有的时候xrange会更快
+
+# 3. python处理矩阵
+row = len(matrix)
+col = len(matrix[0]) if row else 0
+# 这样写通用的原因是, 当matrix = [], row = 0, col = 0
+
+# 4. python列表生成式
+lst = [0 for i in range(3)] # lst = [0,0,0]
+lst = [[0 for i in range(3)] for j in range(2)] # lst = [[0, 0, 0], [0, 0, 0]]
+# 下面这种写法危险:
+# lst1 = [ 0, 0, 0 ]
+# lst2 = [lst1] * 2 # lst2 = [ [0,0,0] , [0,0,0] ]
+# lst2[0][0] = 1 # lst2 = [ [1,0,0], [1,0,0]]
+# 因为lst1是object,改一个相当于全改, 这样写会踩坑
+
+# 5. D.get(key, default)
+# 如果这个key 没有在dict里面,给它一个默认值:
+D = {}
+if 1 in D:
+ val = D[1]
+else :
+ val = 0
+# 等同于这样写:
+val = D.get(1, 0)
+
+# 6. 字典赋值
+if key in D:
+ D[key].append(1)
+else :
+ D[key] = []
+
+# 7. 字符串反转
+# python字符串没有reverse函数,只能str[::-1]
+string[::-1]
+# python的list可以直接reverse(),因此也可以借用这个特性
+"".join([string].reverse())
+
+# 8. 快速统计
+import collections
+lst = [1, 1, 1, 2, 3, 4, 5, 5]
+collections.Counter(lst) # Counter({1: 3, 5: 2, 2: 1, 3: 1, 4: 1})
+
+# 9. python自带小顶堆heapq
+# Python有built-in heap, 默认min heap.
+heapq.heappush(heap, item) # 把item添加到heap中(heap是一个列表)
+
+heapq.heappop(heap) # 把堆顶元素弹出,返回的就是堆顶
+
+heapq.heappushpop(heap, item) # 先把item加入到堆中,然后再pop,比heappush()再heappop()要快得多
+
+heapq.heapreplace(heap, item) # 先pop,然后再把item加入到堆中,比heappop()再heappush()要快得多
+
+heapq.heapify(x) # 将列表x进行堆调整,默认的是小顶堆
+
+heapq.merge(*iterables) # 将多个列表合并,并进行堆调整,返回的是合并后的列表的迭代器
+
+heapq.nlargest(n, iterable, key=None) # 返回最大的n个元素(Top-K问题)
+
+heapq.nsmallest(n, iterable, key=None) # 返回最小的n个元素(Top-K问题)
+
+# 如何来用它实现max heap呢,看到过一个有意思的方法是把key取负,比如把100变成-100,5变成-5
+
+import heapq
+mylist = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]
+largest = heapq.nlargest(3, mylist) # [10, 9, 8]
+smallest = heapq.nsmallest(3, mylist) # [1, 2, 3]
+
+# 10. 双端队列deque [http://stackoverflow.com/questions/4098179/anyone-know-this-python-data-structure]
+# 可以很简单的.popleft(), .popright(), .appendleft(), .appendright(),最关键的是时间是O(1), 而用list来模拟队列是O(n)的时间复杂度
+# 还有很好用的rotate函数,
+# 一个简单的跑马灯程序
+import sys
+import time
+from collections import deque
+
+fancy_loading = deque('>--------------------')
+
+while True:
+ print('\r%s' % ''.join(fancy_loading))
+ fancy_loading.rotate(1)
+ sys.stdout.flush()
+ time.sleep(0.08)
+
+# 11. 用yield 不用return,可以返回一个generator
diff --git a/docs/Leetcode_Solutions/Summarization/Range Sum Query 2D - Immutable.pdf b/docs/Leetcode_Solutions/Summarization/Range Sum Query 2D - Immutable.pdf
new file mode 100644
index 000000000..09410e209
Binary files /dev/null and b/docs/Leetcode_Solutions/Summarization/Range Sum Query 2D - Immutable.pdf differ
diff --git a/docs/Leetcode_Solutions/Summarization/Recusrion & BackTracking.md b/docs/Leetcode_Solutions/Summarization/Recusrion & BackTracking.md
new file mode 100644
index 000000000..16e0f9279
--- /dev/null
+++ b/docs/Leetcode_Solutions/Summarization/Recusrion & BackTracking.md
@@ -0,0 +1,237 @@
+#Recusrion & BackTracking
+
+##Recusrion
+
+### DrawFractal
+
+```
+void DrawFractal(double x, double y, double w, double h)
+{
+ DrawTriangel(x, y, w, h);
+ if(w < .2 || h < .2) return ;
+ double halfH = h/2;
+ double halfw = w/2;
+ DrawFractal(x, y, halfW, halfH);
+ DrawFractal(x + halfW/2, y + halfH, halfW, halfH);
+ DrawFractal(x + halfW, y, halfW, halfH);
+}
+```
+
+
+Sierpinski triangle更伪码的写法:
+
+```
+void DrawFractal (x, y, w, h){
+ if (too small) return ;
+ DrawTriangle(x, y, w, h);
+ DrawFractal(.left);
+ DrawFractal(.top);
+ DrawFractal(.right);
+}
+```
+
+实际上老师故意调了里面几句代码的顺序,让来看到虽然结果相同,但是画的过程是不一样的。
+
+然后老师还在黑板上画了过程树,分枝是怎样的,实际上当学到DFS的preOrder, inOrder 和 postOrder的时候会更印象深刻。
+
+一个分支走完之后再回去走另一些。
+
+
+### DrawMondrian
+
+
+
+```
+void DrawMondrian(double x, double y, double w, double h){
+
+ if(w < 1 || h < 1) return ;// base case
+
+ FillRectangle(x,y,w,h,RandomColor()); // fill background
+
+ switch(RandomInteger(0, 2)){
+ case 0: // do nothing
+ break;
+ case 1: // bisect vertically
+ double midX = RandomReal(0,w);
+ DrawBlackLine( x + midX, y, h);
+ DrawMondrian(x, y, midX, h);
+ DrawMondrian(x + midx, y, w- midX, h);
+ break;
+ case 2: // bisect horizontally
+ double midY = RandomReal(0,h);
+ DrawBlackLine( x, y+ midY, h);
+ DrawMondrian(x, y, w, midY);
+ DrawMondrian(x, y+midY,w, midY);
+ break;
+ }
+}
+```
+
+
+### The tower of Hanoi
+
+
+```
+void MoveTower(int n, char src, char dst, char tmp){
+ if (n > 0){
+ MoveTower(n - 1, src, tmp, dst );
+ MoveSingleDisk(src, dst);
+ MoveTower(n -1, tmp, dst, src);
+ }
+}
+
+```
+
+
+### Permutation
+
+老师说permutation 和 subset 是 mother problems of all recursion.
+
+
+given a string, print out its all permutations
+
+思路如下:
+
+- 使用了的string sofar,以及还未使用的string rest
+- 一开始rest就是给的string本身,然后sofar是空
+- 每次挑一个rest里面的char,然后递归的再把rest剩下的拿来permutation,这样每次都会有一个char从rest shuffle到sofar
+- n 次之后 rest为空,制造了一个permutation
+
+
+```
+void RecPermute(string sofar, string rest){
+ if(rest = ""){
+ cout << soFar << endl;
+ } else {
+ for(int i = 0 ; i < rest.length(); i++){
+ string next = soFar + rest[i];
+ string remaining = rest.substr(0,i) + rest.substr(i+1);
+ RecPermute(next, remaining);
+ }
+ }
+}
+
+
+// "wrapper" function
+void ListPermutations(string s)
+{
+ RecPermute("",s);
+}
+```
+
+
+老师的黑板图真的是击中要害。
+
+因为老师强调的是,也要用mind来trace它是如何操作的。
+
+
+
+### Subsets
+
+
+```
+void RecSubsets(string soFar, string rest)
+{
+ if(rest = "")
+ cout << soFar << endl;
+ else {
+ // add to subset, remove from rest, recur
+ RecSubsets(soFar + rest[0],rest.substr(1));
+ //don't add to substr, remove from rest, recur
+ RecSubsets(soFar, rest.substr(1));
+ }
+}
+
+
+void ListSubsets(string str)
+{
+ RecSubsets("",str);
+}
+
+```
+
+代码非常容易理解
+
+
+比较一下:两个都是有关选择,permutation是每次选哪一个char,而subsets是选择这个char 是否in.
+
+两个recursion tree都是有branching 和 depth的, depth都是n,每次选一个,知道n个选完.
+
+branching是how many recusive calls 每次made,subset每次都是两个,in/out,而permutation则是n,n-1.......grows very quickly.
+
+因为permutation是n!,subsets是2^n,跟树对应。这些都是比较intractable的问题,并不是因为recursion,而是问题本身的复杂度。
+
+
+这两个问题都是exhaustive的,然而,我们会更多碰到一些问题,有着
+
+similar exhaustive structure,但是遇到'satisfactory' outcome就会stop的 -> 也就是backtracking了.
+
+##BackTracking
+
+
+
+### pseudocode
+
+把问题转成decision problem,然后开始make choice.
+
+```
+bool Solve(configuration conf)
+{
+ if (no more choices) // BASE CASE
+ return (conf is goal state);
+
+ for (all available choices){
+ try one choice c;
+ // sove from here, it works out. you're done.
+ if (Solve(conf with choice c made)) return true;
+ unmake choice c;
+ }
+ return false; //tried all choices, no soln found
+}
+```
+
+
+###IsAnagram
+
+
+```
+bool IsAnagram(string soFar, string rest, Lexicon & lex)
+{
+ if(rest == ""){
+ if(lex.contains(soFar)){
+ cout << soFar << endl;
+ return true;
+ }
+ } else {
+ for(int i = 0; i < rest.length() ; i++ ){
+ string next = soFar + rest[i];
+ string remaining = rest.substr(0,i) + rest.substr(i+1);
+ if(IsAnagram(next, remaining, lex)) return true;
+ }
+ }
+ return false;
+}
+```
+
+
+### 8 Queens
+
+
+```
+
+bool Solve(Grid &board, int col)
+{
+ if(col > = board.numCols()) return true;
+
+ for(int rowToTry = 0; rowToTry < board.numRows(); rowToTry++){
+ if (IsSafe(board,rowToTry, col)){
+ PlaceQueen(board,rowToTry,col);
+ if (Solve(board,col+1)) return true;
+ RemoveQueen(board,rowToTry, col);
+ }
+ }
+ return false;
+}
+
+```
+
diff --git "a/docs/Leetcode_Solutions/Summarization/backtracking\346\200\235\350\267\257.md" "b/docs/Leetcode_Solutions/Summarization/backtracking\346\200\235\350\267\257.md"
new file mode 100644
index 000000000..dbb7e8cf1
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/backtracking\346\200\235\350\267\257.md"
@@ -0,0 +1,295 @@
+## backtracking 全集
+
+### 回溯是啥
+用爬山来比喻回溯,好比从山脚下找一条爬上山顶的路,起初有好几条道可走,当选择一条道走到某处时,又有几条岔道可供选择,只能选择其中一条道往前走,若能这样子顺利爬上山顶则罢了,否则走到一条绝路上时,只好返回到最近的一个路口,重新选择另一条没走过的道往前走。如果该路口的所有路都走不通,只得从该路口继续回返。照此规则走下去,要么找到一条到达山顶的路,要么最终试过所有可能的道,无法到达山顶。
+回溯是一种穷举,但与brute force有一些区别,回溯带了两点脑子的,并不多,brute force一点也没带。
+第一点脑子是回溯知道回头;相反如果是brute force,发现走不通立刻跳下山摔死,换第二条命从头换一条路走。
+第二点脑子是回溯知道剪枝;如果有一条岔路上放了一坨屎,那这条路我们不走,就可以少走很多不必要走的路。
+
+还有一些爱混淆的概念:递归,回溯,DFS。
+回溯是一种找路方法,搜索的时候走不通就回头换路接着走,直到走通了或者发现此山根本不通。
+DFS是一种开路策略,就是一条道先走到头,再往回走一步换一条路走到头,这也是回溯用到的策略。在树和图上回溯时人们叫它DFS。
+递归是一种行为,回溯和递归如出一辙,都是一言不合就回到来时的路,所以一般回溯用递归实现;当然也可以不用,用栈。
+以下以回溯统称,因为这个词听上去很文雅。
+
+### 识别回溯
+判断回溯很简单,拿到一个问题,你感觉如果不穷举一下就没法知道答案,那就可以开始回溯了。
+一般回溯的问题有三种:
+
+1. Find a path to success 有没有解
+2. Find all paths to success 求所有解
+ - 2.1 求所有解的个数,
+ - 2.2 求所有解的具体信息
+3. Find the best path to success 求最优解
+
+理解回溯:给一堆选择, 必须从里面选一个. 选完之后我又有了新的一组选择. ```This procedure is repeated over and over until you reach a final state. If you made a good sequence of choices, your final state is a goal state; if you didn't, it isn't.```
+
+回溯可以抽象为一棵树,我们的目标可以是找这个树有没有good leaf,也可以是问有多少个good leaf,也可以是找这些good leaf都在哪,也可以问哪个good leaf最好,分别对应上面所说回溯的问题分类。
+good leaf都在leaf上。good leaf是我们的goal state,leaf node是final state,是解空间的边界。
+
+对于第一类问题(问有没有解),基本都是长着个样子的,理解了它,其他类别迎刃而解:
+```java
+boolean solve(Node n) {
+ if n is a leaf node {
+ if the leaf is a goal node, return true
+ else return false
+ } else {
+ for each child c of n {
+ if solve(c) succeeds, return true
+ }
+ return false
+ }
+}
+```
+请读以下这段话以加深理解:
+```Notice that the algorithm is expressed as a boolean function. This is essential to understanding the algorithm. If solve(n) is true, that means node n is part of a solution--that is, node n is one of the nodes on a path from the root to some goal node. We say that n is solvable. If solve(n) is false, then there is no path that includes n to any goal node.```
+
+还不懂的话请通读全文吧:[Backtracking - David Matuszek](https://www.cis.upenn.edu/~matuszek/cit594-2012/Pages/backtracking.html)
+
+关于回溯的三种问题,模板略有不同,
+第一种,返回值是true/false。
+第二种,求个数,设全局counter,返回值是void;求所有解信息,设result,返回值void。
+第三种,设个全局变量best,返回值是void。
+
+第一种:
+```java
+boolean solve(Node n) {
+ if n is a leaf node {
+ if the leaf is a goal node, return true
+ else return false
+ } else {
+ for each child c of n {
+ if solve(c) succeeds, return true
+ }
+ return false
+ }
+}
+```
+第二种:
+```java
+void solve(Node n) {
+ if n is a leaf node {
+ if the leaf is a goal node, count++, return;
+ else return
+ } else {
+ for each child c of n {
+ solve(c)
+ }
+ }
+}
+```
+第三种:
+```java
+void solve(Node n) {
+ if n is a leaf node {
+ if the leaf is a goal node, update best result, return;
+ else return
+ } else {
+ for each child c of n {
+ solve(c)
+ }
+ }
+}
+```
+题目
+
+八皇后 N-Queens
+
+问题
+
+1. 给个n,问有没有解;
+2. 给个n,有几种解;(Leetcode N-Queens II)
+3. 给个n,给出所有解;(Leetcode N-Queens I)
+
+解答
+
+1.有没有解
+
+怎么做:一行一行的放queen,每行尝试n个可能,有一个可达,返回true;都不可达,返回false.
+
+边界条件leaf:放完第n行 或者 该放第n+1行(出界,返回)
+
+目标条件goal:n行放满且isValid,即目标一定在leaf上
+
+helper函数:
+boolean solve(int i, int[][] matrix)
+在进来的一瞬间,满足property:第i行还没有被放置,前i-1行放置完毕且valid
+solve要在给定的matrix上试图给第i行每个位置放queen。
+```java
+public static boolean solve1(int i, List matrix, int n) {
+ if (i == n) {
+ if (isValid(matrix))
+ return true;
+ return false;
+ } else {
+ for (int j = 0; j < n; j++) {
+ matrix.add(j);
+ if (isValid(matrix)) { //剪枝
+ if (solve1(i + 1, matrix, n))
+ return true;
+ }
+ matrix.remove(matrix.size() - 1);
+ }
+ return false;
+ }
+}
+```
+2.求解的个数
+
+怎么做:一行一行的放queen,每行尝试n个可能。这回因为要找所有,返回值就没有了意义,用void即可。在搜索时,如果有一个可达,仍要继续尝试;每个子选项都试完了,返回.
+
+边界条件leaf:放完第n行 或者 该放第n+1行(出界,返回)
+
+目标条件goal:n行放满且isValid,即目标一定在leaf上
+
+helper函数:
+void solve(int i, int[][] matrix)
+在进来的一瞬间,满足property:第i行还没有被放置,前i-1行放置完毕且valid
+solve要在给定的matrix上试图给第i行每个位置放queen。
+这里为了记录解的个数,设置一个全局变量(static)int是比较efficient的做法。
+```java
+public static void solve2(int i, List matrix, int n) {
+ if (i == n) {
+ if (isValid(matrix))
+ count++;
+ return;
+ } else {
+ for (int j = 0; j < n; j++) {
+ matrix.add(j);
+ if (isValid(matrix)) { //剪枝
+ solve2(i + 1, matrix, n);
+ }
+ matrix.remove(matrix.size() - 1);
+ }
+ }
+}
+```
+3.求所有解的具体信息
+
+怎么做:一行一行的放queen,每行尝试n个可能。返回值同样用void即可。在搜索时,如果有一个可达,仍要继续尝试;每个子选项都试完了,返回.
+
+边界条件leaf:放完第n行 或者 该放第n+1行(出界,返回)
+
+目标条件goal:n行放满且isValid,即目标一定在leaf上
+
+helper函数:
+void solve(int i, int[][] matrix)
+在进来的一瞬间,满足property:第i行还没有被放置,前i-1行放置完毕且valid
+solve要在给定的matrix上试图给第i行每个位置放queen。
+这里为了记录解的具体情况,设置一个全局变量(static)集合是比较efficient的做法。
+当然也可以把结果集合作为参数传来传去。
+```java
+public static void solve3(int i, List matrix, int n) {
+ if (i == n) {
+ if (isValid(matrix))
+ result.add(new ArrayList(matrix));
+ return;
+ } else {
+ for (int j = 0; j < n; j++) {
+ matrix.add(j);
+ if (isValid(matrix)) { //剪枝
+ solve3(i + 1, matrix, n);
+ }
+ matrix.remove(matrix.size() - 1);
+ }
+ }
+}
+```
+优化
+
+上面的例子用了省空间的方法。
+由于每行只能放一个,一共n行的话,用一个大小为n的数组,数组的第i个元素表示第i行放在了第几列上。
+
+Utility(给一个list判断他的最后一行是否和前面冲突):
+```java
+public static boolean isValid(List list){
+ int row = list.size() - 1;
+ int col = list.get(row);
+ for (int i = 0; i <= row - 1; i++) {
+ int row1 = i;
+ int col1 = list.get(i);
+ if (col == col1)
+ return false;
+ if (row1 - row == col1 - col)
+ return false;
+ if (row1 - row == col - col1)
+ return false;
+ }
+ return true;
+
+}
+```
+
+参考[Backtracking回溯法(又称DFS,递归)全解](https://segmentfault.com/a/1190000006121957)
+以及 [Python Patterns - Implementing Graphs](https://www.python.org/doc/essays/graphs/)
+
+
+
+## 以Generate Parentheses为例,backtrack的题到底该怎么去思考?
+
+
+所谓Backtracking都是这样的思路:在当前局面下,你有若干种选择。那么尝试每一种选择。如果已经发现某种选择肯定不行(因为违反了某些限定条件),就返回;如果某种选择试到最后发现是正确解,就将其加入解集
+
+所以你思考递归题时,只要明确三点就行:选择 (Options),限制 (Restraints),结束条件 (Termination)。即“ORT原则”(这个是我自己编的)
+
+
+
+
+对于这道题,在任何时刻,你都有两种选择:
+1. 加左括号。
+2. 加右括号。
+
+同时有以下限制:
+1. 如果左括号已经用完了,则不能再加左括号了。
+2. 如果已经出现的右括号和左括号一样多,则不能再加右括号了。因为那样的话新加入的右括号一定无法匹配。
+
+结束条件是:
+左右括号都已经用完。
+
+结束后的正确性:
+左右括号用完以后,一定是正确解。因为1. 左右括号一样多,2. 每个右括号都一定有与之配对的左括号。因此一旦结束就可以加入解集(有时也可能出现结束以后不一定是正确解的情况,这时要多一步判断)。
+
+递归函数传入参数:
+限制和结束条件中有“用完”和“一样多”字样,因此你需要知道左右括号的数目。
+当然你还需要知道当前局面sublist和解集res。
+
+因此,把上面的思路拼起来就是代码:
+
+ if (左右括号都已用完) {
+ 加入解集,返回
+ }
+ //否则开始试各种选择
+ if (还有左括号可以用) {
+ 加一个左括号,继续递归
+ }
+ if (右括号小于左括号) {
+ 加一个右括号,继续递归
+ }
+
+
+
+你帖的那段代码逻辑中加了一条限制:“3. 是否还有右括号剩余。如有才加右括号”。这是合理的。不过对于这道题,如果满足限制1、2时,3一定自动满足,所以可以不判断3。
+
+这题其实是最好的backtracking初学练习之一,因为ORT三者都非常简单明显。你不妨按上述思路再梳理一遍,还有问题的话再说。
+
+
+
+以上文字来自 1point3arces的牛人解答
+
+
+
+Backtracking 伪码
+
+
+```
+Pick a starting point.
+while(Problem is not solved)
+ For each path from the starting point.
+ check if selected path is safe, if yes select it
+ and make recursive call to rest of the problem
+ If recursive calls returns true, then return true.
+ else undo the current move and return false.
+ End For
+ If none of the move works out, return false, NO SOLUTON.
+
+```
diff --git "a/docs/Leetcode_Solutions/Summarization/delete_node_in_a_linked_list\351\227\256\351\242\230.md" "b/docs/Leetcode_Solutions/Summarization/delete_node_in_a_linked_list\351\227\256\351\242\230.md"
new file mode 100644
index 000000000..e148bb218
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/delete_node_in_a_linked_list\351\227\256\351\242\230.md"
@@ -0,0 +1,69 @@
+##Delete Node in a Linked List问题
+
+
+This is a LeetCode question, I knew its solution, but wondering about why my code not work.
+
+
+>Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
+
+>Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function
+
+
+At first glance, my intution is delete like an array:
+
+shift all the node values one front, then delete the tail, here's my implementation and test case:
+
+
+
+ class ListNode(object):
+ def __init__(self, x):
+ self.val = x
+ self.next = None
+
+ node1 = ListNode(1)
+ node2 = ListNode(2)
+ node3 = ListNode(3)
+ node4 = ListNode(4)
+ node5 = ListNode(5)
+
+ node1.next = node2
+ node2.next = node3
+ node3.next = node4
+ node4.next = node5
+
+
+
+ def deleteNode(node):
+ """
+ :type node: ListNode
+ :rtype: void Do not return anything, modify node in-place instead.
+ """
+ while node.next:
+ node.val = node.next.val
+ node = node.next
+ node = None
+
+
+ deleteNode(node4)
+
+But After deletion, it has two 5 value nodes, the tail was still kept, can anyone please explain to me what's wrong here?
+
+ deleteNode(node4)
+
+ node1.val
+ Out[162]: 1
+
+ node1.next.val
+ Out[163]: 2
+
+ node1.next.next.val
+ Out[164]: 3
+
+ node1.next.next.next.val
+ Out[165]: 5
+
+ node1.next.next.next.next.val
+ Out[166]: 5
+
+
+Really appreciate any help.
\ No newline at end of file
diff --git "a/docs/Leetcode_Solutions/Summarization/local_search\357\274\214_\344\270\200\344\272\233\346\226\260\347\232\204\346\200\235\350\267\257.md" "b/docs/Leetcode_Solutions/Summarization/local_search\357\274\214_\344\270\200\344\272\233\346\226\260\347\232\204\346\200\235\350\267\257.md"
new file mode 100644
index 000000000..864326ec7
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/local_search\357\274\214_\344\270\200\344\272\233\346\226\260\347\232\204\346\200\235\350\267\257.md"
@@ -0,0 +1,14 @@
+# Local Search, 一些新的思路
+
+当一个问题我们只关心解法,而不是其达到解的顺序,那么考虑使用local search,比如八皇后问题,我们只关心哪个皇后放哪,根本不关心加入皇后的顺序。
+
+local search还能用来解一类问题,求最优。
+
+
+
+> A complete local search algorithm always finds a goal if one exists; an optimal algorithm always finds a global minimum/maximum.
+
+
+一个解八皇后的新思路是我们根本就random来放皇后,然后如果state 合法,就get解答一枚,否则可以Move only to neighboring states,当然,选之剑attack数量最少的state.
+
+这种方法叫 hill - climbing,很多问题,可能被卡,然后random restart
\ No newline at end of file
diff --git "a/docs/Leetcode_Solutions/Summarization/python\347\232\204\345\220\204\347\247\215pass.md" "b/docs/Leetcode_Solutions/Summarization/python\347\232\204\345\220\204\347\247\215pass.md"
new file mode 100644
index 000000000..c1ac085a8
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/python\347\232\204\345\220\204\347\247\215pass.md"
@@ -0,0 +1,123 @@
+#Python的各种Pass
+
+感觉最近对于pass by reference 和 pass by value又有了一点/一些认识
+
+
+1. python不允许程序员选择采用传值还是传引用。Python参数传递采用的肯定是“传对象引用”的方式。实际上,这种方式相当于传值和传引用的一种综合。如果函数收到的是一个可变对象(比如字典或者列表)的引用,就能修改对象的原始值——相当于通过“传引用”来传递对象。如果函数收到的是一个不可变对象(比如数字、字符或者元组)的引用,就不能直接修改原始对象——相当于通过“传值'来传递对象。
+2. 当人们复制列表或字典时,就复制了对象列表的引用同,如果改变引用的值,则修改了原始的参数。
+3. 为了简化内存管理,Python通过引用计数机制实现自动垃圾回收功能,Python中的每个对象都有一个引用计数,用来计数该对象在不同场所分别被引用了多少次。每当引用一次Python对象,相应的引用计数就增1,每当消毁一次Python对象,则相应的引用就减1,只有当引用计数为零时,才真正从内存中删除Python对象。
+
+
+##### Linked List的例子
+
+
+
+```
+class ListNode(object):
+ def __init__(self, x):
+ self.val = x
+ self.next = None
+
+node1 = ListNode(1)
+node2 = ListNode(2)
+node3 = ListNode(3)
+node4 = ListNode(4)
+node5 = ListNode(5)
+
+node1.next = node2
+node2.next = node3
+node3.next = node4
+node4.next = node5
+
+```
+
+
+
+来改变head
+
+```
+def testWithPointers1(head):
+ head.next = None
+```
+
+
+
+运行 testWithPointers1(node1)
+
+然后node1.next 为None了
+
+// 可以理解,因为传进去的是head这个可变对象。
+
+
+
+```
+def testWithPointers2(head):
+ cur = head
+ cur.next = None
+```
+
+
+
+运行 testWithPointers2(node1)
+// node1.next 同样为None了
+
+Python的object,list都是pass by reference,所以是改变的
+
+看另外一个例子:
+
+```
+def printLinkedList(head):
+ while head:
+ print(head)
+ head = head.next
+```
+
+
+输出
+
+```
+ printLinkedList(head)
+
+<__main__.ListNode object at 0x1044c0e10>
+
+1
+
+<__main__.ListNode object at 0x1044c0fd0>
+
+2
+
+<__main__.ListNode object at 0x1044c0c88>
+
+3
+
+<__main__.ListNode object at 0x1044c0be0>
+
+4
+
+<__main__.ListNode object at 0x1044c0780>
+
+5
+
+head
+
+Out[39]: <__main__.ListNode at 0x1044c0e10>
+
+```
+
+其实这里的head为什么没有改变有点疑惑
+
+
+
+##### String看一下
+
+
+ a = "abc"
+
+ def changeA(s):
+ s = ""
+ changeA(a)
+
+
+a 并不会改变,依旧为'abc'
+
+
\ No newline at end of file
diff --git a/docs/Leetcode_Solutions/Summarization/slide_windows_template.md b/docs/Leetcode_Solutions/Summarization/slide_windows_template.md
new file mode 100644
index 000000000..919d1c0f9
--- /dev/null
+++ b/docs/Leetcode_Solutions/Summarization/slide_windows_template.md
@@ -0,0 +1,185 @@
+能用此模板解决的题目目前有如下:
+[leetcode 003](https://github.com/Lisanaaa/thinking_in_lc/blob/master/003._longest_substring_without_repeating_characters.md),
+[leetcode 030](https://github.com/Lisanaaa/thinking_in_lc/edit/master/30._Substring_with_Concatenation_of_All_Words.md),
+[leetcode 076](https://github.com/Lisanaaa/thinking_in_lc/blob/master/076._Minimum_Window_Substring.md),
+[leetcode 159](https://github.com/Lisanaaa/thinking_in_lc/blob/master/159._Longest_Substring_with_At_Most_Two_Distinct_Characters.md),
+[leetcode 438](https://github.com/Lisanaaa/thinking_in_lc/blob/master/438._Find_All_Anagrams_in_a_String.md)
+
+
+
+带注释python版本
+```python
+class Solution(object):
+ def slideWindowTemplateByLisanaaa(self, s, t):
+ """
+ :type s: str
+ :type t: str
+ :rtype: 具体题目具体分析
+ """
+ # init a collection or int value to save the result according the question.
+ res = []
+ if len(t) > len(s):
+ return res
+
+ # create a hashmap to save the Characters of the target substring.
+ # (K, V) = (Character, Frequence of the Characters)
+ maps = collections.Counter(t)
+
+ # maintain a counter to check whether match the target string.
+ # must be the map size, NOT the string size because the char may be duplicate.
+ counter = len(maps.keys())
+
+ # Two Pointers: begin - left pointer of the window; end - right pointer of the window
+ begin, end = 0, 0
+
+ # the length of the substring which match the target string.
+ length = sys.maxint
+
+ # loop at the begining of the source string
+ while end < len(s):
+ if s[end] in maps:
+ maps[s[end]] -= 1 # plus or minus one
+ if maps[s[end]] == 0:
+ counter -= 1 # modify the counter according the requirement(different condition).
+ end += 1
+
+ # increase begin pointer to make it invalid/valid again
+ while counter == 0: # counter condition. different question may have different condition
+ if s[begin] in maps:
+ maps[s[begin]] += 1 # plus or minus one
+ if maps[s[begin]] > 0:
+ counter += 1 # modify the counter according the requirement(different condition).
+ begin += 1
+
+ '''
+ type your code here according to the question
+ 1. save / update(min/max) the result if find a target
+ 2. result: collections or int value
+ '''
+ return res
+```
+
+无注释python版本:
+```python
+class Solution(object):
+ def slideWindowTemplateByLisanaaa(self, s, t):
+ res = []
+ if len(t) > len(s):
+ return res
+ maps = collections.Counter(t)
+ counter = len(maps.keys())
+ begin, end = 0, 0
+ length = sys.maxint
+ while end < len(s):
+ if s[end] in maps:
+ maps[s[end]] -= 1
+ if maps[s[end]] == 0:
+ counter -= 1
+ end += 1
+ while counter == 0:
+ if s[begin] in maps:
+ maps[s[begin]] += 1
+ if maps[s[begin]] > 0:
+ counter += 1
+ begin += 1
+
+ '''
+ 1. save / update(min/max) the result if find a target
+ 2. result: collections or int value
+ '''
+ return res
+```
+带注释java版本
+```java
+public class Solution {
+ public List slidingWindowTemplateByHarryChaoyangHe(String s, String t) {
+ //init a collection or int value to save the result according the question.
+ List result = new LinkedList<>();
+ if(t.length()> s.length()) return result;
+
+ //create a hashmap to save the Characters of the target substring.
+ //(K, V) = (Character, Frequence of the Characters)
+ Map map = new HashMap<>();
+ for(char c : t.toCharArray()){
+ map.put(c, map.getOrDefault(c, 0) + 1);
+ }
+ //maintain a counter to check whether match the target string.
+ int counter = map.size();//must be the map size, NOT the string size because the char may be duplicate.
+
+ //Two Pointers: begin - left pointer of the window; end - right pointer of the window
+ int begin = 0, end = 0;
+
+ //the length of the substring which match the target string.
+ int len = Integer.MAX_VALUE;
+
+ //loop at the begining of the source string
+ while(end < s.length()){
+
+ char c = s.charAt(end);//get a character
+
+ if( map.containsKey(c) ){
+ map.put(c, map.get(c)-1);// plus or minus one
+ if(map.get(c) == 0) counter--;//modify the counter according the requirement(different condition).
+ }
+ end++;
+
+ //increase begin pointer to make it invalid/valid again
+ while(counter == 0 /* counter condition. different question may have different condition */){
+
+ char tempc = s.charAt(begin);//***be careful here: choose the char at begin pointer, NOT the end pointer
+ if(map.containsKey(tempc)){
+ map.put(tempc, map.get(tempc) + 1);//plus or minus one
+ if(map.get(tempc) > 0) counter++;//modify the counter according the requirement(different condition).
+ }
+
+ /* save / update(min/max) the result if find a target*/
+ // result collections or result int value
+
+ begin++;
+ }
+ }
+ return result;
+ }
+}
+```
+
+无注释java版本:
+```java
+public class Solution {
+ public List slidingWindowTemplateByHarryChaoyangHe(String s, String t) {
+ List result = new LinkedList<>();
+ if(t.length()> s.length()) return result;
+ Map map = new HashMap<>();
+ for(char c : t.toCharArray()){
+ map.put(c, map.getOrDefault(c, 0) + 1);
+ }
+ int counter = map.size();
+ int begin = 0, end = 0;
+ int len = Integer.MAX_VALUE;
+ while(end < s.length()){
+ char c = s.charAt(end);
+ if( map.containsKey(c) ){
+ map.put(c, map.get(c)-1);
+ if(map.get(c) == 0) counter--;
+ }
+ end++;
+ while(counter == 0){
+ char tempc = s.charAt(begin);
+ if(map.containsKey(tempc)){
+ map.put(tempc, map.get(tempc) + 1);
+ if(map.get(tempc) > 0) counter++;
+ }
+
+ /*
+ save / update(min/max) the result if find a target
+ result collections or result int value
+ */
+
+ begin++;
+ }
+ }
+ return result;
+ }
+}
+```
+
diff --git "a/docs/Leetcode_Solutions/Summarization/tree_search\357\274\214_graph_search\357\274\214_dfs,_bfs.md" "b/docs/Leetcode_Solutions/Summarization/tree_search\357\274\214_graph_search\357\274\214_dfs,_bfs.md"
new file mode 100644
index 000000000..656ec8a1f
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/tree_search\357\274\214_graph_search\357\274\214_dfs,_bfs.md"
@@ -0,0 +1,156 @@
+# Tree Search, Graph Search, DFS, BFS
+
+
+其实原本是根本不知道还有tree search的,只知道graph search,原来graph search就是一般我看到的dfs,bfs,有一个结构来记录visited node,这样在寻找邻居的时候,防止已经visit的node再被visit.
+
+
+## Tree Search
+
+general tree search pseudocode
+
+
+```
+function TREE_SEARCH(problem, strategy) returns a solution, or failure
+ initialize the search tree using the initial state of problem
+ loop do
+ if there are no candidates for expansion then return failure
+ choose a leaf node for expansion according to strategy
+ if the node contains a goal state then return the corresponding solution
+ else expand the node and add the resulting nodes to the search tree
+ end
+```
+
+
+## DFS/BFS
+
+可以让stack/queue记录更多一些的东西,因为反正stack/queue更像通用结构
+
+```
+ A
+ / \
+ C B
+ \ / \
+ \ D E
+ \ /
+ F
+
+
+graph = {'A': set(['B', 'C']),
+ 'B': set(['A', 'D', 'E']),
+ 'C': set(['A', 'F']),
+ 'D': set(['B']),
+ 'E': set(['B', 'F']),
+ 'F': set(['C', 'E'])}
+```
+### DFS
+The implementation below uses the stack data-structure to build-up and return a set of vertices that are accessible within the subjects connected component. Using Python’s overloading of the subtraction operator to remove items from a set, we are able to add only the unvisited adjacent vertices.
+```python
+def dfs(graph, start): # iterative
+ visited, stack = [], [start]
+ while stack:
+ vertex = stack.pop()
+ if vertex not in visited:
+ visited.append(vertex)
+ stack.extend(graph[vertex] - set(visited))
+ return visited
+print(dfs(graph, 'A')) # ['A', 'C', 'F', 'E', 'B', 'D'] 这只是其中一种答案
+```
+The second implementation provides the same functionality as the first, however, this time we are using the more succinct recursive form. Due to a common Python gotcha with default parameter values being created only once, we are required to create a new visited set on each user invocation. Another Python language detail is that function variables are passed by reference, resulting in the visited mutable set not having to reassigned upon each recursive call.
+```python
+def dfs(graph, start, visited=None): # recursive
+ if visited is None:
+ visited = []
+ print('visiting', start)
+ visited.append(start)
+ for next in graph[start]:
+ if next not in visited:
+ dfs(graph, next, visited)
+ return visited
+print(dfs(graph, 'A')) # ['A', 'C', 'F', 'E', 'B', 'D'] 这只是其中一种答案
+```
+We are able to tweak both of the previous implementations to return all possible paths between a start and goal vertex. The implementation below uses the stack data-structure again to iteratively solve the problem, yielding each possible path when we locate the goal. Using a generator allows the user to only compute the desired amount of alternative paths.
+```python
+def dfs_paths(graph, start, goal): # iterative
+ stack = [(start, [start])]
+ while stack:
+ (vertex, path) = stack.pop()
+ for next in graph[vertex] - set(path):
+ if next == goal:
+ yield path + [next]
+ else:
+ stack.append((next, path + [next]))
+print(list(dfs_paths(graph, 'A', 'F'))) # [['A', 'C', 'F'], ['A', 'B', 'E', 'F']]
+```
+The implementation below uses the recursive approach calling the ‘yield from’ PEP380 addition to return the invoked located paths. Unfortunately the version of Pygments installed on the server at this time does not include the updated keyword combination.
+```python
+def dfs_paths(graph, start, goal, path=None): # recursive
+ if path is None:
+ path = [start]
+ if start == goal:
+ yield path
+ for next in graph[start] - set(path):
+ yield from dfs_paths(graph, next, goal, path + [next])
+print(list(dfs_paths(graph, 'C', 'F'))) # [['C', 'A', 'B', 'E', 'F'], ['C', 'F']]
+```
+
+### BFS
+
+Similar to the iterative DFS implementation the only alteration required is to remove the next item from the beginning of the list structure instead of the stacks last.
+```python
+def bfs(graph, start): # iterative
+ visited, queue = [], [start]
+ while queue:
+ vertex = queue.pop(0)
+ if vertex not in visited:
+ visited.append(vertex)
+ queue.extend(graph[vertex] - set(visited))
+ return visited
+print(bfs(graph, 'A')) # ['A', 'C', 'B', 'F', 'D', 'E']
+```
+This implementation can again be altered slightly to instead return all possible paths between two vertices, the first of which being one of the shortest such path.
+```python
+def bfs_paths(graph, start, goal):
+ queue = [(start, [start])]
+ while queue:
+ (vertex, path) = queue.pop(0)
+ for next in graph[vertex] - set(path):
+ if next == goal:
+ yield path + [next]
+ else:
+ queue.append((next, path + [next]))
+print(list(bfs_paths(graph, 'A', 'F'))) # [['A', 'C', 'F'], ['A', 'B', 'E', 'F']]
+```
+Knowing that the shortest path will be returned first from the BFS path generator method we can create a useful method which simply returns the shortest path found or ‘None’ if no path exists. As we are using a generator this in theory should provide similar performance results as just breaking out and returning the first matching path in the BFS implementation.
+```python
+def bfs_paths(graph, start, goal):
+ queue = [(start, [start])]
+ while queue:
+ (vertex, path) = queue.pop(0)
+ for next in graph[vertex] - set(path):
+ if next == goal:
+ yield path + [next]
+ else:
+ queue.append((next, path + [next]))
+def shortest_path(graph, start, goal):
+ try:
+ return next(bfs_paths(graph, start, goal))
+ except StopIteration:
+ return None
+print(shortest_path(graph, 'A', 'F')) # ['A', 'C', 'F']
+```
+
+#### Improvement/Follow up
+
+1. 一旦BFS/DFS与更具体的,更有特性的data structure结合起来,比如binary search tree,那么BFS/DFS会针对这个tree traversal显得更有特性。
+2. it's worth mentioning that there is an optimized queue object in the collections module called [deque](https://docs.python.org/2/library/collections.html#collections.deque)) for which removing items from the beginning ( or popleft ) takes constant time as opposed to O(n) time for lists.
+
+
+
+### Resources
+
+1. [Depth-and Breadth-First Search](https://jeremykun.com/2013/01/22/depth-and-breadth-first-search/)
+2. [Edd Mann](http://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/)
+3. [graph - Depth-first search in Python](https://codereview.stackexchange.com/questions/78577/depth-first-search-in-python)
+
+
+
diff --git "a/docs/Leetcode_Solutions/Summarization/\344\275\215\350\277\220\347\256\227.md" "b/docs/Leetcode_Solutions/Summarization/\344\275\215\350\277\220\347\256\227.md"
new file mode 100644
index 000000000..aeaa44c4d
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\344\275\215\350\277\220\347\256\227.md"
@@ -0,0 +1,38 @@
+### 位运算
+
+位运算包括: 加 减 乘 取反 and 异或
+
+- 0110 + 0110 = 0110 * 2 ,也就是0110左移1位
+
+- 0011 * 0100 0100 = 4, 一个数乘以 2^n 即是将这个数左移n
+
+- a ^(~a) = 0
+
+- x & (~0 << n ) 这样来看,0取反全部为1,然后将其右移n位,后面的全是0,x & (~0 <>:右移
+
+
+
+Bit Facts and Tricks
+
+```
+x ^ 0s = x x & 0s = 0 x | 0s = x
+x ^ 1s = ~x x & 1s = x x | 1s = 1s
+x ^ x = 0 x & x = x x | x = x
+```
+
diff --git "a/docs/Leetcode_Solutions/Summarization/\345\205\250\346\216\222\345\210\227\347\256\227\346\263\225.md" "b/docs/Leetcode_Solutions/Summarization/\345\205\250\346\216\222\345\210\227\347\256\227\346\263\225.md"
new file mode 100644
index 000000000..767617664
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\345\205\250\346\216\222\345\210\227\347\256\227\346\263\225.md"
@@ -0,0 +1,194 @@
+### 全排列算法
+
+
+#### 46. Permutations
+
+
+Given a collection of distinct numbers, return all possible permutations.
+
+For example,
+[1,2,3] have the following permutations:
+
+ [
+ [1,2,3],
+ [1,3,2],
+ [2,1,3],
+ [2,3,1],
+ [3,1,2],
+ [3,2,1]
+ ]
+
+
+#####从空开始加
+
+先跳离开这道题,来看类似的'ABC',我们要求它的全排列
+
+
+```
+def recPermute(sofar, rest):
+ if rest == '':
+ print sofar
+ else:
+ for i in range(len(rest)):
+ nxt = sofar + rest[i]
+ remaining = rest[:i] + rest[i+1:]
+ recPermute(nxt, remaining)
+
+// "wrapper" function
+def listPermute(s):
+ recPermute('',s)
+```
+
+会正确输出`ABC ACB BAC BCA CAB CBA`,题目依靠的是每次我们从余下的字母中选一个,如果画图则会是这样:
+
+
+```
+ A B C
+ B C A C A B
+ C B C A B A
+```
+
+时间复杂度应该是O(n!)
+
+- n choose 1
+- n-1 choose 1
+- ...
+
+
+
+#####另一种市面上常见思路是交换:
+
+思路是这样的,同样看上面的图:
+
+- n个元素的全排列 = (n-1)个元素的全排列 + 另一个元素作为前缀
+- 如果只有一个元素,那么这个元素本身就是它的全排列
+- 不断将每个元素放作第一个元素,然后将这个元素作为前缀,并将其余元素继续全排列,等到出口,出口出去后还需要还原数组
+
+
+这个用数组来测试更容易写代码和直观:
+
+
+```
+def recPermute(nums,begin):
+ n = len(nums)
+ if begin == n:
+ print nums,
+
+ for i in range(begin,n):
+ nums[begin], nums[i] = nums[i],nums[begin]
+ recPermute(nums,begin+1)
+ nums[begin],nums[i] = nums[i],nums[begin]
+
+recPermute(['A','B','C'],0)
+
+```
+
+这样的写法更容易理解:
+
+
+```python
+class Solution:
+ # @param num, a list of integer
+ # @return a list of lists of integers
+ def permute(self, num):
+ if len(num) == 0: return []
+ if len(num) == 1: return [num]
+ res = []
+ for i in range(len(num)):
+ x = num[i]
+ xs = num[:i] + num[i+1:]
+ for j in self.permute(xs):
+ res.append([x] + j)
+ return res
+```
+
+每次用一个没有用过的头元素,然后加上全排列产生的结果.
+
+如果分析复杂度,应该也是O(n!)
+
+
+#### 47. Permutations II
+
+
+最简单的想法:
+
+- 排序
+- 如果碰到重复的就继续处理下一个
+
+```
+class Solution(object):
+ def permuteUnique(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ if len(nums) == 0: return []
+ if len(nums) == 1: return [nums]
+ res = []
+ nums.sort()
+ for i in range(len(nums)):
+ if i > 0 and nums[i] == nums[i-1]: continue
+ for j in self.permuteUnique(nums[:i] + nums[i+1:]):
+ res.append([nums[i]] + j)
+ return res
+
+```
+
+
+
+
+#### 31. Next Permutation
+
+实际上这个题目也就是Generation in lexicographic order,
+
+wikipedia 和 [这里](https://www.nayuki.io/page/next-lexicographical-permutation-algorithm) 有很好,很精妙的算法,也有点two pointer的意思
+
+
+```
+1. Find the highest index i such that s[i] < s[i+1]. If no such index exists, the permutation is the last permutation.
+2. Find the highest index j > i such that s[j] > s[i]. Such a j must exist, since i+1 is such an index.
+3. Swap s[i] with s[j].
+4. Reverse the order of all of the elements after index i till the last element.
+```
+
+
+看例子:
+
+125430
+
+
+- 从末尾开始,找到decreasing subsequence,5430,因为来调5330无论怎么调,都不可能有比它更小的,数也被自然的分成两部分(1,2) 和 (5,4,3,0)
+- 下一步是找这个sequence里面第一个比前面部分,比2大的,3,也很容易理解,因为下一个必定是(1,3)打头
+- 交换 3和2 ,变成 (1,3,5,4,2,0),再把后面的部分reverse,得到后面部分可得到的最小的
+
+这个时候,得到下一个sequence 130245
+
+
+
+```
+class Solution(object):
+ def nextPermutation(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: void Do not return anything, modify nums in-place instead.
+ """
+ m, n = 0, 0
+ for i in range(len(nums) - 2, 0 , -1):
+ if nums[i] < nums[i+1]:
+ m = i
+ break
+
+ for i in range(len(nums) - 1, 0 , -1):
+ if nums[i] > nums[m]:
+ n = i
+ break
+
+ if m < n :
+ nums[m], nums[n] = nums[n], nums[m]
+ nums[m+1:] = nums[len(nums):m:-1]
+ else:
+ nums = nums.reverse()
+```
+
+
+所以可以用这个next permutation来解46/47也可以,然后我兴奋了一下,这个算法很快的!然后我又冷静了,因为permutation的个数是O(n!)个啊|||,所以也不可能有啥大的提升吧
diff --git "a/docs/Leetcode_Solutions/Summarization/\345\205\253\346\216\222\345\272\217.md" "b/docs/Leetcode_Solutions/Summarization/\345\205\253\346\216\222\345\272\217.md"
new file mode 100644
index 000000000..83b327202
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\345\205\253\346\216\222\345\272\217.md"
@@ -0,0 +1,386 @@
+## 前言
+八大排序,三大查找是《数据结构》当中非常基础的知识点,在这里为了复习顺带总结了一下常见的八种排序算法。
+常见的八大排序算法,他们之间关系如下:
+
+
+
+他们的性能比较:
+
+
+
+### 直接插入排序 (Insertion sort)
+
+
+
+直接插入排序的核心思想就是:将数组中的所有元素依次跟前面已经排好的元素相比较,如果选择的元素比已排序的元素小,则交换,直到全部元素都比较过。
+因此,从上面的描述中我们可以发现,直接插入排序可以用两个循环完成:
+
+1. 第一层循环:遍历待比较的所有数组元素
+2. 第二层循环:将本轮选择的元素(selected)与已经排好序的元素(ordered)相比较。
+ - 如果```selected > ordered```,那么将二者交换
+
+```python
+#直接插入排序
+def insert_sort(L):
+ #遍历数组中的所有元素,其中0号索引元素默认已排序,因此从1开始
+ for x in range(1,len(L)):
+ #将该元素与已排序好的前序数组依次比较,如果该元素小,则交换
+ #range(x-1,-1,-1):从x-1倒序循环到0
+ for i in range(x-1,-1,-1):
+ #判断:如果符合条件则交换
+ if L[i] > L[i+1]:
+ L[i], L[i+1] = L[i+1], L[i]
+```
+### 希尔排序 (Shell sort)
+
+
+
+希尔排序的算法思想:将待排序数组按照步长gap进行分组,然后将每组的元素利用直接插入排序的方法进行排序;每次将gap折半减小,循环上述操作;当gap=1时,利用直接插入,完成排序。
+同样的:从上面的描述中我们可以发现:希尔排序的总体实现应该由三个循环完成:
+
+1. 第一层循环:将gap依次折半,对序列进行分组,直到gap=1
+2. 第二、三层循环:也即直接插入排序所需要的两次循环。具体描述见上。
+
+```python
+#希尔排序
+def insert_shell(L):
+ #初始化gap值,此处利用序列长度的一半为其赋值
+ gap = int(len(L)/2)
+ #第一层循环:依次改变gap值对列表进行分组
+ while (gap >= 1):
+ #下面:利用直接插入排序的思想对分组数据进行排序
+ #range(gap,len(L)):从gap开始
+ for x in range(gap,len(L)):
+ #range(x-gap,-1,-gap):从x-gap开始与选定元素开始倒序比较,每个比较元素之间间隔gap
+ for i in range(x-gap,-1,-gap):
+ #如果该组当中两个元素满足交换条件,则进行交换
+ if L[i] > L[i+gap]:
+ L[i], L[i+gap] = L[i+gap], L[i]
+ #while循环条件折半
+ gap = int((gap/2))
+```
+
+### 简单选择排序 (Selection sort)
+
+
+
+简单选择排序的基本思想:比较+交换。
+
+1. 从待排序序列中,找到关键字最小的元素;
+2. 如果最小元素不是待排序序列的第一个元素,将其和第一个元素互换;
+3. 从余下的 N - 1 个元素中,找出关键字最小的元素,重复(1)、(2)步,直到排序结束。
+因此我们可以发现,简单选择排序也是通过两层循环实现。
+ - 第一层循环:依次遍历序列当中的每一个元素
+ - 第二层循环:将遍历得到的当前元素依次与余下的元素进行比较,符合最小元素的条件,则交换。
+
+```python
+# 简单选择排序
+def select_sort(L):
+#依次遍历序列中的每一个元素
+ for x in range(0,len(L)):
+#将当前位置的元素定义此轮循环当中的最小值
+ minimum = L[x]
+#将该元素与剩下的元素依次比较寻找最小元素
+ for i in range(x+1,len(L)):
+ if L[i] < minimum:
+ L[i], minimum = minimum, L[i]
+#将比较后得到的真正的最小值赋值给当前位置
+ L[x] = minimum
+```
+
+### 堆排序 (Heap sort)
+
+#### 堆的概念
+
+堆:本质是一种数组对象。特别重要的一点性质:任意的叶子节点小于(或大于)它所有的父节点 。对此,又分为大顶堆和小顶堆,大顶堆要求节点的元素都要大于其孩子,小顶堆要求节点元素都小于其左右孩子,两者对左右孩子的大小关系不做任何要求。
+利用堆排序,就是基于大顶堆或者小顶堆的一种排序方法。下面,我们通过大顶堆来实现。
+
+基本思想:
+堆排序可以按照以下步骤来完成:
+
+1. 首先将序列构建称为大顶堆;
+
+(这样满足了大顶堆那条性质:位于根节点的元素一定是当前序列的最大值)
+
+
+
+2. 取出当前大顶堆的根节点,将其与序列末尾元素进行交换;
+
+(此时:序列末尾的元素为已排序的最大值;由于交换了元素,当前位于根节点的堆并不一定满足大顶堆的性质)
+
+3. 对交换后的n-1个序列元素进行调整,使其满足大顶堆的性质;
+
+
+
+4. 重复2.3步骤,直至堆中只有1个元素为止
+
+```python
+#-------------------------堆排序--------------------------------
+#**********获取左右叶子节点**********
+def LEFT(i):
+ return 2*i + 1
+def RIGHT(i):
+ return 2*i + 2
+#********** 调整大顶堆 **********
+#L:待调整序列 length: 序列长度 i:需要调整的结点
+def adjust_max_heap(L, length, i):
+#定义一个int值保存当前序列最大值的下标
+ largest = i
+#获得序列左右叶子节点的下标
+ left, right = LEFT(i), RIGHT(i)
+#当左叶子节点的下标小于序列长度 并且 左叶子节点的值大于父节点时,将左叶子节点的下标赋值给largest
+ if (left < length) and (L[left] > L[i]):
+ largest = left
+#当右叶子节点的下标小于序列长度 并且 右叶子节点的值大于父节点时,将右叶子节点的下标值赋值给largest
+ if (right < length) and (L[right] > L[largest]):
+ largest = right
+#如果largest不等于i 说明当前的父节点不是最大值,需要交换值
+ if (largest != i):
+ L[i], L[largest] = L[largest], L[i]
+ # 执行递归操作:两个任务:1 寻找最大值的下标;2.最大值与父节点交换
+ adjust_max_heap(L, length, largest)
+#********** 建立大顶堆 **********
+def build_max_heap(L):
+ length = len(L)
+ for x in range(int((length-1)/2), -1, -1):
+ adjust_max_heap(L, length, x)
+#********** 堆排序 **********
+def heap_sort(L):
+#先建立大顶堆,保证最大值位于根节点;并且父节点的值大于叶子结点
+ build_max_heap(L)
+#i:当前堆中序列的长度.初始化为序列的长度
+ i = len(L)
+#执行循环:1. 每次取出堆顶元素置于序列的最后(len-1,len-2,len-3...)
+# 2. 调整堆,使其继续满足大顶堆的性质,注意实时修改堆中序列的长度
+ while (i > 0):
+ L[i-1], L[0] = L[0], L[i-1]
+#堆中序列长度减1
+ i -= 1
+#调整大顶堆
+ adjust_max_heap(L, i, 0)
+```
+### 冒泡排序 (Bubble sort)
+
+
+
+冒泡排序思路比较简单:
+
+1. 将序列当中的左右元素,依次比较,保证右边的元素始终大于左边的元素;
+( 第一轮结束后,序列最后一个元素一定是当前序列的最大值;)
+2. 对序列当中剩下的n-1个元素再次执行步骤1。
+3. 对于长度为n的序列,一共需要执行n-1轮比较
+(利用while循环可以减少执行次数)
+
+```python
+#冒泡排序
+def bubble_sort(L):
+ length = len(L)
+#序列长度为length,需要执行length-1轮交换
+ for x in range(1, length):
+#对于每一轮交换,都将序列当中的左右元素进行比较
+#每轮交换当中,由于序列最后的元素一定是最大的,因此每轮循环到序列未排序的位置即可
+ for i in range(0, length-x):
+ if L[i] > L[i+1]:
+ L[i], L[i+1] = L[i+1], L[i]
+```
+
+### 快速排序 (Quick sort)
+
+
+
+快速排序的基本思想:挖坑填数+分治法
+
+1. 从序列当中选择一个基准数(pivot)
+在这里我们选择序列当中第一个数作为基准数
+2. 将序列当中的所有数依次遍历,比基准数大的位于其右侧,比基准数小的位于其左侧
+3. 重复步骤1.2,直到所有子集当中只有一个元素为止。
+
+用伪代码描述如下:
+- i =L; j = R; 将基准数挖出形成第一个坑a[i]。
+- j--由后向前找比它小的数,找到后挖出此数填前一个坑a[i]中。
+- i++由前向后找比它大的数,找到后也挖出此数填到前一个坑a[j]中。
+- 再重复执行2,3二步,直到i==j,将基准数填入a[i]中
+
+```python
+#快速排序
+#L:待排序的序列;start排序的开始index,end序列末尾的index
+#对于长度为length的序列:start = 0;end = length-1
+def quick_sort(L, start, end):
+ if start < end:
+ i, j, pivot = start, end, L[start]
+ while i < j:
+#从右开始向左寻找第一个小于pivot的值
+ while (i < j) and (L[j] >= pivot):
+ j -= 1
+#将小于pivot的值移到左边
+ if (i < j):
+ L[i] = L[j]
+ i += 1
+#从左开始向右寻找第一个大于pivot的值
+ while (i < j) and (L[i] <= pivot):
+ i += 1
+#将大于pivot的值移到右边
+ if (i < j):
+ L[j] = L[i]
+ j -= 1
+#循环结束后,说明 i=j,此时左边的值全都小于pivot,右边的值全都大于pivot
+#pivot的位置移动正确,那么此时只需对左右两侧的序列调用此函数进一步排序即可
+#递归调用函数:依次对左侧序列:从0 ~ i-1//右侧序列:从i+1 ~ end
+ L[i] = pivot
+#左侧序列继续排序
+ quick_sort(L, start, i-1)
+#右侧序列继续排序
+ quick_sort(L, i+1, end)
+```
+
+### 归并排序 (Merge sort)
+
+
+
+1. 归并排序是建立在归并操作上的一种有效的排序算法,该算法是采用分治法的一个典型的应用。它的基本操作是:将已有的子序列合并,达到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。
+2. 归并排序其实要做两件事:
+ - 分解----将序列每次折半拆分
+ - 合并----将划分后的序列段两两排序合并
+因此,归并排序实际上就是两个操作,拆分+合并
+3. 如何合并?
+ - L[first...mid]为第一段,L[mid+1...last]为第二段,并且两端已经有序,现在我们要将两端合成达到L[first...last]并且也有序。
+ - 首先依次从第一段与第二段中取出元素比较,将较小的元素赋值给temp[]
+ - 重复执行上一步,当某一段赋值结束,则将另一段剩下的元素赋值给temp[]
+ - 此时将temp[]中的元素复制给L[],则得到的L[first...last]有序
+4. 如何分解?
+ - 在这里,我们采用递归的方法,首先将待排序列分成A,B两组;
+ - 然后重复对A、B序列分组;
+ - 直到分组后组内只有一个元素,此时我们认为组内所有元素有序,则分组结束。
+
+```python
+# 归并排序
+#这是合并的函数
+# 将序列L[first...mid]与序列L[mid+1...last]进行合并
+def mergearray(L, first, mid, last, temp):
+#对i,j,k分别进行赋值
+ i, j, k = first, mid+1, 0
+#当左右两边都有数时进行比较,取较小的数
+ while (i <= mid) and (j <= last):
+ if L[i] <= L[j]:
+ temp[k] = L[i]
+ i += 1
+ k += 1
+ else:
+ temp[k] = L[j]
+ j += 1
+ k += 1
+#如果左边序列还有数
+ while (i <= mid):
+ temp[k] = L[i]
+ i += 1
+ k += 1
+#如果右边序列还有数
+ while (j <= last):
+ temp[k] = L[j]
+ j += 1
+ k += 1
+#将temp当中该段有序元素赋值给L待排序列使之部分有序
+ for x in range(0, k):
+ L[first+x] = temp[x]
+# 这是分组的函数
+def merge_sort(L, first, last, temp):
+ if first < last:
+ mid = int(((first + last) / 2))
+#使左边序列有序
+ merge_sort(L, first, mid, temp)
+#使右边序列有序
+ merge_sort(L, mid+1, last, temp)
+#将两个有序序列合并
+ mergearray(L, first, mid, last, temp)
+# 归并排序的函数
+def merge_sort_array(L):
+#声明一个长度为len(L)的空列表
+ temp = len(L)*[None]
+#调用归并排序
+ merge_sort(L, 0, len(L)-1, temp)
+```
+
+### 基数排序 (Radix sort)
+
+
+
+1. 基数排序:通过序列中各个元素的值,对排序的N个元素进行若干趟的“分配”与“收集”来实现排序。
+ - 分配:我们将L[i]中的元素取出,首先确定其个位上的数字,根据该数字分配到与之序号相同的桶中
+ - 收集:当序列中所有的元素都分配到对应的桶中,再按照顺序依次将桶中的元素收集形成新的一个待排序列L[ ]
+ - 对新形成的序列L[]重复执行分配和收集元素中的十位、百位...直到分配完该序列中的最高位,则排序结束
+2. 根据上述“基数排序”的展示,我们可以清楚的看到整个实现的过程
+
+```python
+#************************基数排序****************************
+#确定排序的次数
+#排序的顺序跟序列中最大数的位数相关
+def radix_sort_nums(L):
+ maxNum = L[0]
+#寻找序列中的最大数
+ for x in L:
+ if maxNum < x:
+ maxNum = x
+#确定序列中的最大元素的位数
+ times = 0
+ while (maxNum > 0):
+ maxNum = int((maxNum/10))
+ times += 1
+ return times
+#找到num从低到高第pos位的数据
+def get_num_pos(num, pos):
+ return (int((num/(10**(pos-1))))) % 10
+#基数排序
+def radix_sort(L):
+ count = 10 * [None] #存放各个桶的数据统计个数
+ bucket = len(L) * [None] #暂时存放排序结果
+#从低位到高位依次执行循环
+ for pos in range(1, radix_sort_nums(L)+1):
+ #置空各个桶的数据统计
+ for x in range(0, 10):
+ count[x] = 0
+ #统计当前该位(个位,十位,百位....)的元素数目
+ for x in range(0, len(L)):
+ #统计各个桶将要装进去的元素个数
+ j = get_num_pos(int(L[x]), pos)
+ count[j] += 1
+ #count[i]表示第i个桶的右边界索引
+ for x in range(1,10):
+ count[x] += count[x-1]
+ #将数据依次装入桶中
+ for x in range(len(L)-1, -1, -1):
+ #求出元素第K位的数字
+ j = get_num_pos(L[x], pos)
+ #放入对应的桶中,count[j]-1是第j个桶的右边界索引
+ bucket[count[j]-1] = L[x]
+ #对应桶的装入数据索引-1
+ count[j] -= 1
+ # 将已分配好的桶中数据再倒出来,此时已是对应当前位数有序的表
+ for x in range(0, len(L)):
+ L[x] = bucket[x]
+```
+
+## 运行时间实测
+
+10w数据
+```
+直接插入排序:1233.581131
+希尔排序:1409.8012320000003
+简单选择排序:466.66974500000015
+堆排序:1.2036720000000969
+冒泡排序:751.274449
+#****************************************************
+快速排序:1.0000003385357559e-06
+#快速排序有误:实际上并未执行
+#RecursionError: maximum recursion depth exceeded in comparison
+#****************************************************
+归并排序:0.8262230000000272
+基数排序:1.1162899999999354
+```
+从运行结果上来看,堆排序、归并排序、基数排序真的快。
+对于快速排序迭代深度超过的问题,可以将考虑将快排通过非递归的方式进行实现。
+
+## Resources
+
+1. [算法导论》笔记汇总](http://mindlee.com/2011/08/21/study-notes-directory/)
+2. [八大排序算法的 Python 实现](http://python.jobbole.com/82270/)
+3. [数据结构常见的八大排序算法(详细整理)](https://www.jianshu.com/p/7d037c332a9d)
diff --git "a/docs/Leetcode_Solutions/Summarization/\345\255\220\351\233\206\345\220\210\351\227\256\351\242\230.md" "b/docs/Leetcode_Solutions/Summarization/\345\255\220\351\233\206\345\220\210\351\227\256\351\242\230.md"
new file mode 100644
index 000000000..0d4afa96a
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\345\255\220\351\233\206\345\220\210\351\227\256\351\242\230.md"
@@ -0,0 +1,114 @@
+###子集合问题
+
+####78. Subsets
+
+子集合是全排列的好朋友,也是combination组合的好朋友,排列·组合·子集,他们三个都是好朋友.
+
+
+#####从空开始加
+
+同样先来看'ABC'
+
+```
+def recsubsets(sofar, rest):
+ if rest == '':
+ print sofar,
+ else:
+ recsubsets(sofar, rest[1:])
+ recsubsets(sofar + rest[0], rest[1:])
+
+def listsubsets(s):
+ recsubsets('',s)
+
+
+listsubsets('ABC')
+```
+
+##### 市面流行思路
+
+市面上流行的思路:
+
+- [[],[1]] 是 [1] 的子集合
+- [[],[1],[2],[1,2]] 是 [1,2] 的子集合,实际上就是1的子集合们加了一个2
+
+
+所以用python写起来也很简单/精美
+
+```
+def subsets(nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ results = [[]]
+ for num in nums:
+ results.extend([result + [num] for result in results])
+ return results
+```
+我在这里犯过错,所以这一句
+
+`results.extend([result + [num] for result in results])` 实际上等于:
+
+
+```
+tmp = []
+for result in results:
+ tmp.append(result + [num])
+results.extend(tmp)
+```
+
+
+
+
+
+#### 90. Subsets II
+
+
+要去重了,比如如果有 [1,2,2],那么解答为:
+
+
+ [
+ [2],
+ [1],
+ [1,2,2],
+ [2,2],
+ [1,2],
+ []
+ ]
+
+
+现在来观察规律,与之前有不同之处是我们需要一个位置来mark,因为不再需要往之前出现过的地方再加了,看这个:
+
+
+```
+[[],[1]] 是 [1] 的子集合
+[[],[1],[2],[1,2]] 是 [1,2] 的子集合,实际上就是1的子集合们加了一个2
+新来的2不能再从头开始加了,它需要从[ .., [2],[1,2] ]加 才是合理的
+```
+
+所以看到非常精妙的代码
+
+
+```
+def subsets(nums):
+ """
+ :type nums: List[int]
+ :rtype: List[List[int]]
+ """
+ nums.sort()
+ result = [[]]
+ temp_size = 0
+
+ for i in range(len(nums)):
+ start = temp_size if i >= 1 and nums[i] == nums[i-1] else 0
+ temp_size = len(result)
+ #print start,temp_size,result
+ for j in range(start, temp_size):
+ result.append(result[j] + [nums[i]])
+ print result
+
+subsets([1,2,2])
+```
+
+这里这个start是来记录了之前一次数组的长度,temp_size记住目前数组的长度,然后用这个来达到去重的目的,非常聪明
+
diff --git "a/docs/Leetcode_Solutions/Summarization/\346\200\273\347\273\223.md" "b/docs/Leetcode_Solutions/Summarization/\346\200\273\347\273\223.md"
new file mode 100644
index 000000000..99fcba752
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\346\200\273\347\273\223.md"
@@ -0,0 +1,120 @@
+# 1
+```solution```下自定义函数```func(self, fargs, *args, **kwargs)```, 调用时使用```self.func()```的格式
+
+# 2
+```not fargs``` 和 ```fargs == None```不一样,前者```fargs```可能为[], '', 0, etc
+
+# 3
+递归问题
+Any problem can be solved using dp. Solving using a greedy strategy is harder though, since you need to prove that greedy will work for that problem. There are some tell-tale signs of a problem where greedy may be applicable, but isn’t immediately apparent. Example:
+
+- Choice of an element depends only on its immediate neighbours (wiggle sort).
+- Answer is monotonically non-decreasing or non-increasing (sorting). This is also applicable for LIS for example.
+- Anything that requires lexicographically largest or smallest of something.
+- Anything where processing the input in sorted order will help.
+- Anything where processing the input in forward or reverse (as given) will help.
+- Anything which requires you to track the minimum or maximum of something (think of sliding window problems).
+
+There’s matroid theory which deal with greedy algorithms, but I don’t really understand it. If someone does, I’ll be super grateful to them to explain it to me in simple language!
+
+In general, try to see if for a problem, the solution doesn’t depend on a lot of history about the solution itself, but the next part of the solution is somewhat independent from the rest of the solution. These are all indicative of the fact that a greedy strategy could be applicable.
+
+# 4
+[Counter.elements()](https://docs.python.org/2/library/collections.html)
+
+# 5
+测试案例写法
+
+```python
+import unittest
+class Solution(object):
+ def isMatch(self, s, p):
+ """
+ :type s: str
+ :type p: str
+ :rtype: bool
+ """
+ m, n = len(s), len(p)
+ dp = [ [0 for i in range(n+1)] for j in range(m+1)]
+
+ dp[0][0] = 1
+
+ # init the first line
+ for i in range(2,n+1):
+ if p[i-1] == '*':
+ dp[0][i] = dp[0][i-2]
+
+ for i in range(1,m+1):
+ for j in range(1,n+1):
+ if p[j-1] == '*':
+ if p[j-2] != s[i-1] and p[j-2] != '.':
+ dp[i][j] = dp[i][j-2]
+ elif p[j-2] == s[i-1] or p[j-2] == '.':
+ dp[i][j] = dp[i-1][j] or dp[i][j-2]
+
+ elif s[i-1] == p[j-1] or p[j-1] == '.':
+ dp[i][j] = dp[i-1][j-1]
+
+ return dp[m][n] == 1
+
+
+class TestSolution(unittest.TestCase):
+ def test_none_0(self):
+ s = ""
+ p = ""
+ self.assertTrue(Solution().isMatch(s, p))
+
+ def test_none_1(self):
+ s = ""
+ p = "a"
+ self.assertFalse(Solution().isMatch(s, p))
+
+ def test_no_symbol_equal(self):
+ s = "abcd"
+ p = "abcd"
+ self.assertTrue(Solution().isMatch(s, p))
+
+ def test_no_symbol_not_equal_0(self):
+ s = "abcd"
+ p = "efgh"
+ self.assertFalse(Solution().isMatch(s, p))
+
+ def test_no_symbol_not_equal_1(self):
+ s = "ab"
+ p = "abb"
+ self.assertFalse(Solution().isMatch(s, p))
+
+ def test_symbol_0(self):
+ s = ""
+ p = "a*"
+ self.assertTrue(Solution().isMatch(s, p))
+
+ def test_symbol_1(self):
+ s = "a"
+ p = "ab*"
+ self.assertTrue(Solution().isMatch(s, p))
+
+ def test_symbol_2(self):
+ # E.g.
+ # s a b b
+ # p 1 0 0 0
+ # a 0 1 0 0
+ # b 0 0 1 0
+ # * 0 1 1 1
+ s = "abb"
+ p = "ab*"
+ self.assertTrue(Solution().isMatch(s, p))
+
+
+if __name__ == "__main__":
+ unittest.main()
+
+
+
+输出:
+........
+
+Ran 8 tests in 0.001s
+
+OK
+```
diff --git "a/docs/Leetcode_Solutions/Summarization/\347\273\204\345\220\210\351\227\256\351\242\230.md" "b/docs/Leetcode_Solutions/Summarization/\347\273\204\345\220\210\351\227\256\351\242\230.md"
new file mode 100644
index 000000000..33f295e82
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\347\273\204\345\220\210\351\227\256\351\242\230.md"
@@ -0,0 +1,84 @@
+### 组合问题
+
+
+#### 77.Combinations
+
+
+##### 会超时的recursion
+
+
+
+```
+class Solution(object):
+ def combine(self, n, k):
+ """
+ :type n: int
+ :type k: int
+ :rtype: List[List[int]]
+ """
+ ans = []
+ self.dfs(n, k, 1, [], ans)
+ return ans
+
+ def dfs(self, n, k ,start, lst, ans):
+ if k == 0 :
+ ans.append(lst)
+ return
+ for i in range(start, n+1):
+ self.dfs(n, k - 1, i + 1,lst +[i], ans)
+```
+
+理解方式
+
+```
+
+ 1 2 3
+ 12 13 14 23 24 34
+```
+
+可以参照这里
+
+
+
+
+
+##### 市面上流行解法
+
+递归的思想: n选k
+
+- 如果 k==n ,则全选。
+- n > k 又可以分成两类:
+ - 选了n, 则在余下的n-1中选k-1
+ - 没有选n, 则在余下的n-1中选k
+
+注意一下会有两个base case,因为k在不断减小和n在不断减小,所以写起来可以这样:
+
+
+```
+def combine(n,k):
+ if k == 1:
+ return [[i+1] for i in range(n)]
+ if n == k:
+ return [range(1, k+1)]
+ # choose n , not choose n
+ return [r + [n] for r in combine(n-1,k-1)] + combine(n-1,k)
+
+
+print combine(20,16)
+```
+
+
+#### 39. Combination Sum
+
+
+使用正常递归思路
+
+
+#### 40. Combination Sum II
+
+重复做跳过处理
+
+#### 216. Combination Sum III
+
+
+#### 377. Combination Sum IV
diff --git "a/docs/Leetcode_Solutions/Summarization/\351\200\222\345\275\222_recursion.md" "b/docs/Leetcode_Solutions/Summarization/\351\200\222\345\275\222_recursion.md"
new file mode 100644
index 000000000..413872965
--- /dev/null
+++ "b/docs/Leetcode_Solutions/Summarization/\351\200\222\345\275\222_recursion.md"
@@ -0,0 +1,39 @@
+#递归 Recursion
+
+### 递归
+
+递归绝对是一个非常重要的概念。比如安利? 不断的delegate,本来想要完成1000个人的销售,找10个人,每人完成100人的,这10个人每人再去找10个人,每人完成10人的销售,这样就完成了1000人的销售(不懂安利是否这样,拿来举例)。
+
+
+递归之所以重要,这里面存在的概念太多了,首先上面这个例子里面就有divide and conquer的意思,把task divide小,然后来解决它。
+
+
+同样有趣的例子 → 吃完一个bowl of chips:
+
+- for loop,知道多少薯片,然后从0开始吃到最后
+- while, while 碗里还有薯片,就吃
+- 递归,吃一片,然后继续吃剩下的 N - 1 片,直到碗里的薯片数量只剩下0片了
+
+
+典型的例子:
+
+- pow(x,n)
+- isPalindrome
+- TowerofHanoi
+- binarySearch
+
+
+
+### 链表, 树, 图
+
+链表(linked list) 是数据结构的基础,而链表本身就是具有递归特性的,看C++中对于linked list node的定义, next指向本身这样的结构,就是再这个node定义还未完成之时,我们已经指向自己。
+
+
+```
+struct node{
+ int data;
+ node* next;
+};
+```
+
+binary tree定义就是靠递归来实现的。
diff --git a/docs/interview/Google/Google.md b/docs/interview/Google/Google.md
new file mode 100644
index 000000000..d14b8fae0
--- /dev/null
+++ b/docs/interview/Google/Google.md
@@ -0,0 +1,59 @@
+### 第一轮:
+1. Talk about the work experience of you
+
+
+2. 算法题:给一个number,例如21200,
+
+
+
+Idx: 0 1 2 3 4
+Number: 2 1 2 0 0
+
+- 0th位置有个2,并且整个number里面有2个0;
+- 1th有个1,所以整个number里面有一个1;
+- 2th有个2,所以整个number里面有两个2;
+- 3th有个0,所以整个number里面有0个3;
+- 4th有个0,所以整个number里面有0个4
+
+满足这个property的number是self_describing的
+叫你写一个函数
+def self_describing(self, number), return 这个number是不是满足self_describing,True or False
+
+
+
+3. 算法题,面试官自己工作中的,写了一串,
+- 问你是```BFS```还是DFS,
+- 问你是```recursive```还是iterative,recursive方法有什么limitation
+- 不管结果,你给他的代码转换成```iterative``` or recursive
+
+
+
+
+### 第二轮:
+1. talk about the most challenging work that you have been worked on
+
+
+2. HashTable 和 BST的比较,你知道什么说什么,时间复杂度,实现,插入,删除,查找
+
+3. HashTable 和 BST 的concurrency对比
+
+
+
+4. 算法题
+
+首先,morse_code = {
+ 'a': '..',
+ 'b': '.-',
+ 'c': '...',
+ ‘d’: '-'
+ ,
+ ,
+ .........
+ }
+给你一串words,
+- 例如['ab','cd'],这时候因为words里面的两个word的对应的morse_code是一样的,所以我们返回他们的morse_code,即['...-']
+- 再例如有很多words,有着相同morse_code的words很多,你要返回所有相同morse_code 的words所对应的那个morse_code,例如['...-', '..']
+
+
+
+
diff --git a/docs/interview/WePay/WePay.jpg b/docs/interview/WePay/WePay.jpg
new file mode 100644
index 000000000..9f5eeadb5
Binary files /dev/null and b/docs/interview/WePay/WePay.jpg differ
diff --git a/docs/interview/WePay/WePay.md b/docs/interview/WePay/WePay.md
new file mode 100644
index 000000000..1ca2679b3
--- /dev/null
+++ b/docs/interview/WePay/WePay.md
@@ -0,0 +1,34 @@
+如图,
+
+就是一个slide windows 的题目
+
+```python
+inputs = [5,1,2,100,2,2]
+def alert(inputs, windowSize, allowedIncrease):
+ b = []
+ tmp = {}
+ for i in range(len(inputs) - windowSize):
+ for j in range(i, i+windowSize+1):
+ if j in tmp.keys():
+ if j > len(inputs) - windowSize-1:
+ tmp.get(j).append(inputs[i+1:i + windowSize+1])
+ else:
+ tmp.get(j).append(inputs[i:i+windowSize])
+ else:
+ print(j,j, i, i+ windowSize)
+ if j > len(inputs) - windowSize -1:
+ tmp[j] = [inputs[i+1:i + windowSize+1]]
+ else:
+ tmp[j] = [inputs[i:i+windowSize]]
+ b = [inputs[i:i+windowSize] for i in range(len(inputs)-windowSize)]
+ print(tmp)
+ for num in tmp.keys():
+ if all(inputs[num] > sum(lis)/windowSize*allowedIncrease for lis in tmp.get(num)):
+ return True
+ b = [sum(i)/windowSize for i in b]
+ for i in range(len(b)):
+ if any(b[i] > b[j]*allowedIncrease for j in range(i)):
+ return True
+ return False
+print(alert(inputs,3,1.5))
+```
diff --git a/docs/interview/WePay/power_number.md b/docs/interview/WePay/power_number.md
new file mode 100644
index 000000000..6b3ae864e
--- /dev/null
+++ b/docs/interview/WePay/power_number.md
@@ -0,0 +1,36 @@
+
+
+
+
+
+```python
+import heapq
+cache = {}
+def power_number(index):
+ if index in cache:
+ return cache[index]
+ tmp = set()
+ for i in range(2, index+3):
+ for j in range(2, 27):
+ tmp.add(pow(i, j))
+ gene = heapsort(tmp)
+ tmp_index = 0
+ for i in range(index+1):
+ if tmp_index not in cache:
+ cache[tmp_index] = next(gene)
+ else:
+ next(gene)
+ if tmp_index == index:
+ return cache[tmp_index]
+ tmp_index += 1
+
+
+def heapsort(iterable):
+ h = []
+ for value in iterable:
+ heapq.heappush(h, value)
+ for i in range(len(h)):
+ yield heapq.heappop(h)
+
+print(power_number(6500))
+```
diff --git a/docs/interview/pocketgems/pocketgems.md b/docs/interview/pocketgems/pocketgems.md
new file mode 100644
index 000000000..0b108c0df
--- /dev/null
+++ b/docs/interview/pocketgems/pocketgems.md
@@ -0,0 +1,121 @@
+## 1. delete and earn
+```python
+class Solution(object):
+ def deleteAndEarn(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ dp = [0] * 10001
+ for num in nums:
+ dp[num] += num
+ for i in range(2, 10001):
+ dp[i] = max(dp[i]+dp[i-2], dp[i-1])
+ return dp[-1]
+```
+
+## 2. movie ratings
+
+```python
+
+cache = {}
+class Solution(object):
+ def movierating(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ if not nums:
+ return 0
+ if len(nums) == 1:
+ return nums[0] if nums[0] > 0 else 0
+ if (1, len(nums)+1) not in cache:
+ cache[(1, len(nums)+1)] = self.movierating(nums[1:])
+ a = self.movierating(nums[1:])
+ else:
+ a = self.movierating(nums[1:])
+ if (2, len(nums)+2) not in cache:
+ cache[(2, len(nums)+2)] = self.movierating(nums[2:])
+ b = self.movierating(nums[2:])
+ else:
+ b = self.movierating(nums[2:])
+ return max(nums[0]+a, nums[1]+b)
+
+
+
+a = Solution()
+res = a.movierating([-1,-2,-3,-4,-5])
+
+print(res)
+
+```
+
+## 3. roman names
+```python
+class Solution(object):
+ def roman2Int(self, s):
+ lookup = {
+ 'M': 1000,
+ 'D': 500,
+ 'C': 100,
+ 'L': 50,
+ 'X': 10,
+ 'V': 5,
+ 'I': 1
+ }
+ res = 0
+ for i in range(len(s)):
+ if i > 0 and lookup[s[i]] > lookup[s[i-1]]:
+ res = res + lookup[s[i]] - 2 * lookup[s[i-1]]
+ else:
+ res += lookup[s[i]]
+ return res
+
+ def royalNames(self, names):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ for x in range(1, len(names)):
+ for i in range(len(names)-x):
+ if names[i].split(' ')[0] > names[i+1].split(' ')[0]:
+ names[i], names[i+1] = names[i+1], names[i]
+ elif names[i].split(' ')[0] == names[i+1].split(' ')[0]:
+ if self.roman2Int(names[i].split(' ')[1]) > self.roman2Int(names[i+1].split(' ')[1]):
+ names[i], names[i + 1] = names[i + 1], names[i]
+ return names
+
+a = Solution()
+res = a.royalNames(['Akk IX', 'Ak VIII', 'Louis IX', 'Louis VIII'])
+print(res)
+```
+
+
+## 4. wealthy sam time
+```python
+class Solution(object):
+ def minMoves(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+ res = 0
+ minVal = min(nums)
+ for num in nums:
+ res += num -minVal
+ return res
+```
+
+## 5. design
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/docs/interview/\345\274\200\345\217\221\345\262\227\344\275\215(Java)\346\200\273\347\273\223.md" "b/docs/interview/\345\274\200\345\217\221\345\262\227\344\275\215(Java)\346\200\273\347\273\223.md"
new file mode 100644
index 000000000..705bc0449
--- /dev/null
+++ "b/docs/interview/\345\274\200\345\217\221\345\262\227\344\275\215(Java)\346\200\273\347\273\223.md"
@@ -0,0 +1,35 @@
+最近正在面试,最开始因为没有这样准备过,所以总是被问的一脸懵逼,相信很多人跟我有过一样的经历,时间长就是忘了嘛,对不对,无奈。
+怒🔥一上来打算好好整理下,面试前过一遍,岂不是美滋滋!
+
+# Java基础
+## 1. 面向对象和面向过程的区别
+- 面向过程强调动作,物体本身只是一个属性或者参数,具体为一件事该怎么做。 ```吃.(狗,屎) 吃.(🐶, 💩)```
+ - 优点:性能比面向对象高,因为类调用时需要实例化,比较消耗资源;较底层的东西比如单片机、嵌入式开发、Linux/Unix等一般采用面向过程开发,性能是最重要的因素。
+ - 缺点:没有面向对象易维护、易复用、易扩展
+- 面向对象强调object,动作只是一个函数,具体为一件事该让谁去做。 ```狗.吃(屎) 🐶.吃(💩)```
+ - 优点:易维护、易复用、易扩展,由于面向对象有封装、继承、多态性的特性,可以设计出低耦合的系统,使系统更加灵活、更加易于维护
+ - 缺点:性能比面向过程低
+
+## 2. Java的四个基本特性(抽象、封装、继承,多态)
+- ***抽象***:就是把现实生活中的某一类东西提取出来,用类或者接口表示。抽象包括两个方面:一个是数据抽象,一个是过程抽象。数据抽象也就是对象的属性。过程抽象是对象的行为特征。
+- ***封装***:把客观事物封装成抽象的类,并且类可以把自己的数据和方法只让可信的类或者对象操作,对不可信的进行封装隐藏。封装分为属性的封装和方法的封装。
+ - 1. 安全
+ - 2. 将内外隔离
+ - 3. 便于使用
+ - 4. 提供重复性,具有模块化
+- ***继承***:父类抽取多类事物的共性,不同子类继承父类根据自身条件不同对父类方法进行重载或重写。
+- ***多态***:从某种角度上来说,封装和继承就是为了多态而做准备的。多态采用的方法是动态绑定(dynamic binding),是指在执行期间判断所引用对象的实际类型,根据其实际的类型调用其相应的方法。多态必须同时满足三个条件:
+ - 1. 要有继承
+ - 2. 要有重写
+ - 3. 父类引用指向子类对象
+
+ 多态其实就是父类提供一个接口,基于同一个接口,使用不同的实例就可以使用不同的功能
+ ```java
+ Father f = new Son();
+ ```
+## 3. 重载和重写的区别
+- 重载:发生在同一个类中,方法名必须相同,参数类型、个数或者顺序不同,方法返回值和访问修饰符可以不同,发生在编译时。
+- 重写:发生在父子类中,方法名、参数列表必须相同,返回值小于等于父类,抛出的异常小于等于父类,访问修饰符大于等于父类;如果父类方法访问修饰符为private则子类中就不是重写。
+
+# 4. 构造器Constructor是否可被override
+构造器不能被重写,不能用static修饰构造器,只能用public,private,protected这三个权限修饰符,且不能有返回语句。
diff --git "a/docs/interview/\346\213\215\346\213\215\350\264\267/paipaidai.md" "b/docs/interview/\346\213\215\346\213\215\350\264\267/paipaidai.md"
new file mode 100644
index 000000000..74b73713d
--- /dev/null
+++ "b/docs/interview/\346\213\215\346\213\215\350\264\267/paipaidai.md"
@@ -0,0 +1,91 @@
+# 第一轮(一个很nice的QA小姐姐)
+### 1. 介绍自己及相关项目
+
+### 2. 一道简单算法热身,2个排好序的数组,如何取出它们中相同的元素
+答:O(N),就是两个数组同时从```index = 0```开始比较,小的往前进一步,如果相同就加入到```res```中,这样```n```步肯定可以走完。所以是```O(N)```
+
+### 3. 类是怎么加载的
+答:五大步骤:加载、验证、准备、解析、初始化,其中解析根据是静态绑定还是动态绑定, 略...
+详见[类加载机制](https://blog.csdn.net/ns_code/article/details/17881581),当时在这里看到的,就记了一下
+
+### 4. GC 的原理
+答:没引用的对象就是可以回收的了,不定时选择回收与否, 略...
+
+### 5. 栈和堆内存的区别
+答:略...
+
+### 6. 永生代是什么,为啥要有这个
+答:略...
+
+### 7. Spring如何实现AOP和IOC
+答:略...
+
+### 8. 平常开发管理代码用什么方法,Git clone 还是 Git branch,解释一下它们的区别
+答:平常用Git branch,就是按照功能,bug修复开分支,不断merge, 略...
+
+### 9. 解释RESTful的好处
+答:根据方法不同判断api的功能,非常方便,略...
+
+### 10. 遇到的困难和如何解决的
+答:略...
+
+### 11. 你有什么问题要问我的
+答:内心。。没啥要问的哈哈哈😂,略...
+
+
+# 第二轮(一个很严谨的后端开发小哥哥)
+### 1. 45分钟做了一套java试题(20单选,2编程,2问答)
+反馈:说我做得还可以
+
+### 1. 介绍自己及相关项目
+
+### 2. 简单解释下面向对象的基本概念:继承、封装和多态
+答:
+- 继承就是说现在有一个类A,我们如果想要有更多的有着相同功能的类,那么只要继承最开始的这个类A,我们就可以拥有跟类A一样的功能,根据自己条件的不同还可以对A的方法进行重写或者重载
+- 封装使得内部功能和外部隔离开来,一来安全,二来可以更加具有模块化
+- 多态就是说,类似于Father f = new Son();这种,这种可以用于任何时候我们想应用更加specific功能的时候,此时多态就产生效果了。嗯,多态其实就是基于同一个接口,使用不同的实例就可以使用不同的功能
+
+### 3. Java应用程序有没有可能内存泄露?具体场景。如果有一个Java应用程序在生产上发现有内存泄漏问题,作为开发人员你打算如何对其进行问题定位?现在就有这么一个程序,代码也给到你,你怎么弄?流程思路?
+答:第一印象是使用测试工具,先进行模块化检测,我一般手动,注释掉一部分然后检查,采用二分法,一般可以定位到,然后仔细检查下代码逻辑,看看会不会有长期不用的对象仍然被引用着。我觉得工业上肯定会有很多高级工具可以检查内存,但是目前我还没有使用过
+
+### 4. 简单讲讲哈希表的数据结构和算法(get/put操作)。
+答:略...小学生题目不会估计就GG了
+
+### 5. 如果有一个100G的大文件(假定文件里头都是一行行的字符串记录、每个记录约100个字符),要求对这个文件进行排序,请给出你的排序算法。
+答:过程讨论持续15分钟,先后给出3种方法不断优化。
+- 我们可以先遍历所有行,根据每行的前3个字符作为键放到一个hash结构中,这样问题已经可以用O(N^2*lgn)解决了。被否决,有可能前三个字符都是一样的,需要对整个字符串进行排序
+- 或者我们可以先搞一个Trie树,然后遍历一遍全部存好,每一最后字符再多存一个数字表示这一字符串出现次数,然后对这个Trie树进行层次遍历,依次append,返回。回复说文件有100G大小,假设你手头电脑只有8g内存。嗯嗯,我可能会采用先把所有的文件分开很多份分别处理,关键在于最后怎么合并起来还是有序的
+- 其实就是外部排序,先将这个大文件分成很多份,把这些子文件依次读入内存,并利用自定义的有效的内部排序方法(也就是我的方法吧)对它们进行排序,再将排序后得到的有序子文件重新写入外存;可以使用多路归并排序。
+
+### 6. 谈谈你对软件研发生命周期过程的理解,如何确保软件的质量。
+答:生命周期主要有问题定义,可行性分析,系统架构设计,编码实现,测试,验收,最后维护。至于确保软件的质量,就是要选用好的,合适的软件生命周期模型。
+大概模型有瀑布模型,螺旋模型,快速原型模型。
+- 需求明确,使用瀑布模型;
+- 需求很不明确,快速原型模型;
+- 项目不确定性太多使用螺旋模型
+
+### 7. 你是如何管理自己的时间的?举一个你设定并达成目标的例子。
+答:略...
+
+### 8. 你如何理解领导力?举一个由你主动牵头推进的事情。
+答:略...
+
+### 9. 谈谈你的强项和弱项,基于对自己的认识,你打算如何规划你的职业道路?
+答:略...
+
+### 10. 你有什么问题要问我的
+答:这次我准备了,哈哈哈哈😂,不告诉你们,略...
+
+
+# 总结:
+1. 两点最重要:1)开放学习成长的心态,2)积极主动
+2. 后端开发的话,一开始协助做好单元和性能测试,做样例sample,先学习,证明有足够能力后,开始自己独立设计和开发小型模块。最重要的内容是打好基本功,写好像模像样的单元测试,养成良好的工程习惯。
+
+
+
+
+
+
+
+
+
diff --git a/docs/jianzhioffer/java/03_01_DuplicationInArray.md b/docs/jianzhioffer/java/03_01_DuplicationInArray.md
deleted file mode 100644
index e8094f1de..000000000
--- a/docs/jianzhioffer/java/03_01_DuplicationInArray.md
+++ /dev/null
@@ -1,72 +0,0 @@
-## 找出数组中重复的数字
-
-### 题目描述
-在一个长度为 `n` 的数组里的所有数字都在 `0` 到 `n-1` 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。例如,如果输入长度为 `7` 的数组 `{2, 3, 1, 0, 2, 5, 3}`,那么对应的输出是重复的数字 `2` 或者 `3`。
-
-
-### 解法
-#### 解法一
-排序后,顺序扫描,判断是否有重复,时间复杂度为 `O(n²)`。
-
-#### 解法二
-利用哈希表,遍历数组,如果哈希表中没有该元素,则存入哈希表中,否则返回重复的元素。时间复杂度为 `O(n)`,空间复杂度为 `O(n)`。
-
-#### 解法三
-长度为 `n`,元素的数值范围也为 `n`,如果没有重复元素,那么数组每个下标对应的值与下标相等。
-
-从头到尾遍历数组,当扫描到下标 `i` 的数字 `nums[i]`:
-- 如果等于 `i`,继续向下扫描;
-- 如果不等于 `i`,拿它与第 `nums[i]` 个数进行比较,如果相等,说明有重复值,返回 `nums[i]`。如果不相等,就把第 `i` 个数 和第 `nums[i]` 个数交换。重复这个比较交换的过程。
-
-此算法时间复杂度为 `O(n)`,因为每个元素最多只要两次交换,就能确定位置。空间复杂度为 `O(1)`。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/10/27
- */
-
-public class Solution {
- /**
- * 查找数组中的重复元素
- * @param numbers 数组
- * @param length 数组长度
- * @param duplication duplication[0]存储重复元素
- * @return boolean
- */
- public boolean duplicate(int[] numbers, int length, int[] duplication) {
- if (numbers == null || length < 1) {
- return false;
- }
- for (int e : numbers) {
- if (e >= length) {
- return false;
- }
- }
-
- for (int i = 0; i < length; ++i) {
- while (numbers[i] != i) {
- if (numbers[i] == numbers[numbers[i]]) {
- duplication[0] = numbers[i];
- return true;
- }
- swap(numbers, i, numbers[i]);
- }
- }
-
- return false;
- }
-
- private void swap(int[] numbers, int i, int j) {
- int t = numbers[i];
- numbers[i] = numbers[j];
- numbers[j] = t;
- }
-}
-```
-
-### 测试用例
-1. 长度为 n 的数组中包含一个或多个重复的数字;
-2. 数组中不包含重复的数字;
-3. 无效测试输入用例(输入空指针;长度为 n 的数组中包含 0~n-1 之外的数字)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/03_02_DuplicationInArrayNoEdit.md b/docs/jianzhioffer/java/03_02_DuplicationInArrayNoEdit.md
deleted file mode 100644
index 5fdac9cdc..000000000
--- a/docs/jianzhioffer/java/03_02_DuplicationInArrayNoEdit.md
+++ /dev/null
@@ -1,86 +0,0 @@
-## 不修改数组找出重复的数字
-
-### 题目描述
-在一个长度为 `n+1` 的数组里的所有数字都在 `1` 到 `n` 的范围内,所以数组中至少有一个数字是重复的。请找出数组中任意一个重复的数字,但不能修改输入的数组。例如,如果输入长度为 `8` 的数组 `{2, 3, 5, 4, 3, 2, 6, 7}`,那么对应的输出是重复的数字 `2` 或者 `3`。
-
-
-### 解法
-#### 解法一
-创建长度为 `n+1` 的辅助数组,把原数组的元素复制到辅助数组中。如果原数组被复制的数是 `m`,则放到辅助数组第 `m` 个位置。这样很容易找出重复元素。空间复杂度为 `O(n)`。
-
-#### 解法二
-数组元素的取值范围是 `[1, n]`,对该范围对半划分,分成 `[1, middle]`, `[middle+1, n]`。计算数组中有多少个(count)元素落在 `[1, middle]` 区间内,如果 count 大于 middle-1+1,那么说明这个范围内有重复元素,否则在另一个范围内。继续对这个范围对半划分,继续统计区间内元素数量。
-
-时间复杂度 `O(n * log n)`,空间复杂度 `O(1)`。
-
-注意,此方法无法找出所有重复的元素。
-
-```java
-/**
- * @author bingo
- * @since 2018/10/27
- */
-
-public class Solution {
- /**
- * 不修改数组查找重复的元素,没有则返回-1
- * @param numbers 数组
- * @return 重复的元素
- */
- public int getDuplication(int[] numbers) {
- if (numbers == null || numbers.length < 1) {
- return -1;
- }
-
- int start = 1;
- int end = numbers.length - 1;
- while (end >= start) {
- int middle = start + ((end - start) >> 1);
-
- // 调用 log n 次
- int count = countRange(numbers, start, middle);
- if (start == end) {
- if (count > 1) {
- return start;
- }
- break;
- } else {
- // 无法找出所有重复的数
- if (count > (middle - start) + 1) {
- end = middle;
- } else {
- start = middle + 1;
- }
- }
- }
- return -1;
- }
-
-
- /**
- * 计算整个数组中有多少个数的取值在[start, end] 之间
- * 时间复杂度 O(n)
- * @param numbers 数组
- * @param start 左边界
- * @param end 右边界
- * @return 数量
- */
- private int countRange(int[] numbers, int start, int end) {
- if (numbers == null) {
- return 0;
- }
- int count = 0;
- for(int e : numbers) {
- if (e >= start && e <= end) {
- ++count;
- }
- }
- return count;
- }
-}
-```
-
-### 测试用例
-1. 长度为 n 的数组中包含一个或多个重复的数字;
-2. 数组中不包含重复的数字;
-3. 无效测试输入用例(输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/04_FindInPartiallySortedMatrix.md b/docs/jianzhioffer/java/04_FindInPartiallySortedMatrix.md
deleted file mode 100644
index 70ab58be7..000000000
--- a/docs/jianzhioffer/java/04_FindInPartiallySortedMatrix.md
+++ /dev/null
@@ -1,57 +0,0 @@
-## 二维数组中的查找
-
-### 题目描述
-在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
-
-
-### 解法
-从二维数组的右上方开始查找:
-- 若元素值等于 `target`,返回 `true`;
-- 若元素值大于 `target`,砍掉这一列,即 `--j`;
-- 若元素值小于 `target`,砍掉这一行,即 `++i`。
-
-也可以从二维数组的左下方开始查找,以下代码使用左下方作为查找的起点。
-
-注意,不能选择左上方或者右下方的数字,因为这样无法缩小查找的范围。
-
-```java
-/**
- * @author bingo
- * @since 2018/10/27
- */
-
-public class Solution {
- /**
- * 二维数组中的查找
- * @param target 目标值
- * @param array 二维数组
- * @return boolean
- */
- public boolean find(int target, int[][] array) {
- if (array == null) {
- return false;
- }
- int rows = array.length;
- int columns = array[0].length;
-
- int i = rows - 1;
- int j = 0;
- while (i >= 0 && j < columns) {
- if (array[i][j] == target) {
- return true;
- }
- if (array[i][j] < target) {
- ++j;
- } else {
- --i;
- }
- }
- return false;
- }
-}
-```
-
-### 测试用例
-1. 二维数组中包含查找的数字(查找的数字是数组中的最大值和最小值;查找的数字介于数组中的最大值和最小值之间);
-2. 二维数组中没有查找的数字(查找的数字大于/小于数组中的最大值;查找的数字在数组的最大值和最小值之间但数组中没有这个数字);
-3. 特殊输入测试(输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/05_ReplaceSpaces.md b/docs/jianzhioffer/java/05_ReplaceSpaces.md
deleted file mode 100644
index eb3e00d3b..000000000
--- a/docs/jianzhioffer/java/05_ReplaceSpaces.md
+++ /dev/null
@@ -1,98 +0,0 @@
-## 替换空格
-
-### 题目描述
-请实现一个函数,将一个字符串中的每个空格替换成 `%20`。例如,当字符串为 `We Are Happy`,则经过替换之后的字符串为 `We%20Are%20Happy`。
-
-
-### 解法
-#### 解法一
-创建 `StringBuilder`,遍历原字符串,遇到非空格,直接 append 到 `StringBuilder` 中,遇到空格则将 `%20` append 到 `StringBuilder` 中。
-```java
-/**
- * @author bingo
- * @since 2018/10/27
- */
-
-public class Solution {
- /**
- * 将字符串中的所有空格替换为%20
- * @param str 字符串
- * @return 替换后的字符串
- */
- public String replaceSpace(StringBuffer str) {
- if (str == null || str.length() == 0) {
- return str.toString();
- }
- StringBuilder sb = new StringBuilder();
- int len = str.length();
- for (int i = 0; i < len; ++i) {
- char ch = str.charAt(i);
- sb.append(ch == ' ' ? "%20" : ch);
- }
-
- return sb.toString();
- }
-}
-```
-
-#### 解法二【推荐】
-先遍历原字符串,遇到空格,则在原字符串末尾 `append` 任意两个字符,如两个空格。
-
-用指针 `p` 指向原字符串末尾,`q` 指向现字符串末尾,`p`, `q` 从后往前遍历,当 `p` 遇到空格,`q` 位置依次要 `append` '02%',若不是空格,直接 `append` `p` 指向的字符。
-
-> 🤔思路扩展:
-在合并两个数组(包括字符串)时,如果从前往后复制每个数字(或字符)需要重复移动数字(或字符)多次,那么我们可以考虑从后往前复制,这样就能减少移动的次数,从而提高效率。
-
-```java
-/**
- * @author bingo
- * @since 2018/10/27
- */
-
-public class Solution {
- /**
- * 将字符串中的所有空格替换为%20
- * @param str 字符串
- * @return 替换后的字符串
- */
- public String replaceSpace(StringBuffer str) {
- if (str == null || str.length() == 0) {
- return str.toString();
- }
-
- int len = str.length();
- for (int i = 0; i < len; ++i) {
- if (str.charAt(i) == ' ') {
- // append 两个空格
- str.append(" ");
- }
- }
-
- // p 指向原字符串末尾
- int p = len - 1;
-
- // q 指向现字符串末尾
- int q = str.length() - 1;
-
- while (p >= 0) {
- char ch = str.charAt(p--);
- if (ch == ' ') {
- str.setCharAt(q--, '0');
- str.setCharAt(q--, '2');
- str.setCharAt(q--, '%');
- } else {
- str.setCharAt(q--, ch);
- }
- }
-
- return str.toString();
-
- }
-}
-```
-
-
-### 测试用例
-1. 输入的字符串包含空格(空格位于字符串的最前面/最后面/中间;字符串有多个连续的空格);
-2. 输入的字符串中没有空格;
-3. 特殊输入测试(字符串是一个空指针;字符串是一个空字符串;字符串只有一个空格字符;字符串中有多个连续空格)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/06_PrintListInReversedOrder.md b/docs/jianzhioffer/java/06_PrintListInReversedOrder.md
deleted file mode 100644
index 60e99a538..000000000
--- a/docs/jianzhioffer/java/06_PrintListInReversedOrder.md
+++ /dev/null
@@ -1,110 +0,0 @@
-## 从尾到头打印链表
-
-### 题目描述
-输入一个链表,按链表值从尾到头的顺序返回一个 `ArrayList`。
-
-
-### 解法
-#### 解法一【推荐】
-遍历链表,每个链表结点值 `push` 进栈,最后将栈中元素依次 `pop` 到 `list` 中。
-```java
-/**
-* public class ListNode {
-* int val;
-* ListNode next = null;
-*
-* ListNode(int val) {
-* this.val = val;
-* }
-* }
-*
-*/
-import java.util.ArrayList;
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/10/28
- */
-public class Solution {
- /**
- * 从尾到头打印链表
- * @param listNode 链表头节点
- * @return list
- */
- public ArrayList printListFromTailToHead(ListNode listNode) {
- ArrayList res = new ArrayList<>();
- if (listNode == null) {
- return res;
- }
- Stack stack = new Stack<>();
- while (listNode != null) {
- stack.push(listNode.val);
- listNode = listNode.next;
- }
- while (!stack.isEmpty()) {
- res.add(stack.pop());
- }
-
- return res;
- }
-}
-```
-
-#### 解法二【不推荐】
-利用递归方式:
-- 若不是链表尾结点,继续递归;
-- 若是,添加到 `list` 中。
-
-这种方式不推荐,当递归层数过多时,容易发生 `Stack Overflow`。
-
-```java
-/**
-* public class ListNode {
-* int val;
-* ListNode next = null;
-*
-* ListNode(int val) {
-* this.val = val;
-* }
-* }
-*
-*/
-import java.util.ArrayList;
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/10/28
- */
-public class Solution {
- /**
- * 从尾到头打印链表
- * @param listNode 链表头结点
- * @return list
- */
- public ArrayList printListFromTailToHead(ListNode listNode) {
- ArrayList res = new ArrayList<>();
- if (listNode == null) {
- return res;
- }
-
- addElement(listNode, res);
- return res;
-
- }
-
- private void addElement(ListNode listNode, ArrayList res) {
- if (listNode.next != null) {
- // 递归调用
- addElement(listNode.next, res);
- }
- res.add(listNode.val);
- }
-}
-```
-
-
-### 测试用例
-1. 功能测试(输入的链表有多个结点;输入的链表只有一个结点);
-2. 特殊输入测试(输入的链表结点指针为空)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/07_ConstructBinaryTree.md b/docs/jianzhioffer/java/07_ConstructBinaryTree.md
deleted file mode 100644
index f8c824a2e..000000000
--- a/docs/jianzhioffer/java/07_ConstructBinaryTree.md
+++ /dev/null
@@ -1,82 +0,0 @@
-## 重建二叉树
-
-### 题目描述
-输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列 `{1,2,4,7,3,5,6,8}` 和中序遍历序列 `{4,7,2,1,5,3,8,6}`,则重建二叉树并返回。
-
-
-### 解法
-在二叉树的前序遍历序列中,第一个数字总是根结点的值。在中序遍历序列中,根结点的值在序列的中间,左子树的结点位于根结点左侧,而右子树的结点位于根结点值的右侧。
-
-遍历中序序列,找到根结点,递归构建左子树与右子树。
-
-注意添加特殊情况的 `if` 判断。
-
-```java
-/**
- * Definition for binary tree
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode(int x) { val = x; }
- * }
- */
-
-/**
- * @author bingo
- * @since 2018/10/28
- */
-
-public class Solution {
- /**
- * 重建二叉树
- *
- * @param pre 先序序列
- * @param in 中序序列
- * @return 二叉树根结点
- */
- public TreeNode reConstructBinaryTree(int[] pre, int[] in) {
- if (pre == null || in == null || pre.length != in.length) {
- return null;
- }
- int n = pre.length;
- return constructBinaryTree(pre, 0, n - 1, in, 0, n - 1);
- }
-
- private TreeNode constructBinaryTree(int[] pre, int startPre, int endPre, int[] in, int startIn, int endIn) {
- TreeNode node = new TreeNode(pre[startPre]);
- if (startPre == endPre) {
- if (startIn == endIn) {
- return node;
- }
- throw new IllegalArgumentException("Invalid input!");
- }
-
- int inOrder = startIn;
- while (in[inOrder] != pre[startPre]) {
- ++inOrder;
- if (inOrder > endIn) {
- new IllegalArgumentException("Invalid input!");
- }
- }
- int len = inOrder - startIn;
- if (len > 0) {
- // 递归构建左子树
- node.left = constructBinaryTree(pre, startPre + 1, startPre + len, in, startIn, inOrder - 1);
- }
-
- if (inOrder < endIn) {
- // 递归构建右子树
- node.right = constructBinaryTree(pre, startPre + len + 1, endPre, in, inOrder + 1, endIn);
- }
- return node;
-
- }
-}
-```
-
-
-### 测试用例
-1. 普通二叉树(完全二叉树;不完全二叉树);
-2. 特殊二叉树(所有结点都没有左/右子结点;只有一个结点的二叉树);
-3. 特殊输入测试(二叉树根结点为空;输入的前序序列和中序序列不匹配)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/08_NextNodeInBinaryTrees.md b/docs/jianzhioffer/java/08_NextNodeInBinaryTrees.md
deleted file mode 100644
index e16037ce7..000000000
--- a/docs/jianzhioffer/java/08_NextNodeInBinaryTrees.md
+++ /dev/null
@@ -1,74 +0,0 @@
-## 二叉树的下一个结点
-
-### 题目描述
-给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。
-
-
-### 解法
-对于结点 `pNode`:
-- 如果它有右子树,则**右子树的最左结点**就是它的下一个结点;
-- 如果它没有右子树,判断它与父结点 `pNode.next` 的位置情况:
- - 如果它是父结点的左孩子,那么父结点 `pNode.next` 就是它的下一个结点;
- - 如果它是父结点的右孩子,一直向上寻找,直到找到某个结点,它是它父结点的左孩子,那么该父结点就是 `pNode` 的下一个结点。
-
-```java
-/*
-public class TreeLinkNode {
- int val;
- TreeLinkNode left = null;
- TreeLinkNode right = null;
- TreeLinkNode next = null;
-
- TreeLinkNode(int val) {
- this.val = val;
- }
-}
-*/
-
-/**
- * @author bingo
- * @since 2018/10/28
- */
-
-public class Solution {
- /**
- * 获取中序遍历结点的下一个结点
- * @param pNode 某个结点
- * @return pNode的下一个结点
- */
- public TreeLinkNode GetNext(TreeLinkNode pNode) {
- if (pNode == null) {
- return null;
- }
-
- if (pNode.right != null) {
- TreeLinkNode t = pNode.right;
- while (t.left != null) {
- t = t.left;
- }
- return t;
- }
-
- // 须保证 pNode.next 不为空,否则会出现 NPE
- if (pNode.next != null && pNode.next.left == pNode) {
- return pNode.next;
- }
-
- while (pNode.next != null) {
- if (pNode.next.left == pNode) {
- return pNode.next;
- }
- pNode = pNode.next;
- }
-
- return null;
-
- }
-}
-```
-
-
-### 测试用例
-1. 普通二叉树(完全二叉树;不完全二叉树);
-2. 特殊二叉树(所有结点都没有左/右子结点;只有一个结点的二叉树;二叉树的根结点为空);
-3. 不同位置的结点的下一个结点(下一个结点为当前结点的右子结点、右子树的最左子结点、父结点、跨层的父结点等;当前结点没有下一个结点)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/09_01_QueueWithTwoStacks.md b/docs/jianzhioffer/java/09_01_QueueWithTwoStacks.md
deleted file mode 100644
index 9dc32d0d2..000000000
--- a/docs/jianzhioffer/java/09_01_QueueWithTwoStacks.md
+++ /dev/null
@@ -1,47 +0,0 @@
-## 用两个栈实现队列
-
-### 题目描述
-用两个栈来实现一个队列,完成队列的 `Push` 和 `Pop` 操作。 队列中的元素为 `int` 类型。
-
-
-### 解法
-`Push` 操作,每次都存入 `stack1`;
-`Pop` 操作,每次从 `stack2` 取:
-- `stack2` 栈不为空时,不能将 `stack1` 元素倒入;
-- `stack2` 栈为空时,需要一次将 `stack1` 元素全部倒入。
-
-```java
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/10/28
- */
-
-public class Solution {
- Stack stack1 = new Stack();
- Stack stack2 = new Stack();
-
- public void push(int node) {
- stack1.push(node);
- }
-
- public int pop() {
- if (stack2.isEmpty()) {
- if (stack1.isEmpty()) {
- return -1;
- }
- while (!stack1.isEmpty()) {
- stack2.push(stack1.pop());
- }
- }
- return stack2.pop();
- }
-}
-```
-
-
-### 测试用例
-1. 往空的队列里添加、删除元素;
-2. 往非空的队列添加、删除元素;
-3. 连续删除元素直至队列为空。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/09_02_StackWithTwoQueues.md b/docs/jianzhioffer/java/09_02_StackWithTwoQueues.md
deleted file mode 100644
index 823b8fa29..000000000
--- a/docs/jianzhioffer/java/09_02_StackWithTwoQueues.md
+++ /dev/null
@@ -1,55 +0,0 @@
-## 用两个队列实现栈
-
-### 题目描述
-用两个队列来实现一个栈,完成栈的 `Push` 和 `Pop` 操作。 栈中的元素为 `int` 类型。
-
-
-### 解法
-`Push` 操作,每次都存入 `queue1`;
-`Pop` 操作,每次从 `queue1` 取:
-- 将 `queue1` 中的元素依次倒入 `queue2`,直到 `queue1` 剩下一个元素,这个元素就是要 `pop` 出去的;
-- 将 `queue1` 与 `queue2` 进行交换,这样保证每次都从 `queue1` 中存取元素,`queue2` 只起到辅助暂存的作用。
-
-```java
-import java.util.LinkedList;
-import java.util.Queue;
-
-/**
- * @author bingo
- * @since 2018/10/29
- */
-
-public class Solution {
-
- private Queue queue1 = new LinkedList<>();
- private Queue queue2 = new LinkedList<>();
-
- public void push(int node) {
- queue1.offer(node);
- }
-
- public int pop() {
- if (queue1.isEmpty()) {
- throw new RuntimeException("Empty stack!");
- }
-
- while (queue1.size() > 1) {
- queue2.offer(queue1.poll());
- }
-
- int val = queue1.poll();
-
- Queue t = queue1;
- queue1 = queue2;
- queue2 = t;
- return val;
-
- }
-}
-```
-
-
-### 测试用例
-1. 往空的栈里添加、删除元素;
-2. 往非空的栈添加、删除元素;
-3. 连续删除元素直至栈为空。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/10_01_Fibonacci.md b/docs/jianzhioffer/java/10_01_Fibonacci.md
deleted file mode 100644
index 31ac8b0ec..000000000
--- a/docs/jianzhioffer/java/10_01_Fibonacci.md
+++ /dev/null
@@ -1,79 +0,0 @@
-## 斐波那契数列
-
-### 题目描述
-大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第 `n` 项(从 `0` 开始,第 `0` 项为 `0`)。`n<=39`
-
-
-### 解法
-#### 解法一
-采用递归方式,简洁明了,但效率很低,存在大量的重复计算。
-```
- f(10)
- / \
- f(9) f(8)
- / \ / \
- f(8) f(7) f(7) f(6)
- / \ / \
- f(7) f(6) f(6) f(5)
-```
-
-```java
-
-/**
- * @author bingo
- * @since 2018/10/29
- */
-
-public class Solution {
- /**
- * 求斐波那契数列的第n项,n从0开始
- * @param n 第n项
- * @return 第n项的值
- */
- public int Fibonacci(int n) {
- if (n < 2) {
- return n;
- }
- // 递归调用
- return Fibonacci(n - 1) + Fibonacci(n - 2);
- }
-}
-```
-
-#### 解法二
-从下往上计算,递推,时间复杂度 `O(n)`。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/10/29
- */
-
-public class Solution {
- /**
- * 求斐波那契数列的第n项,n从0开始
- * @param n 第n项
- * @return 第n项的值
- */
- public int Fibonacci(int n) {
- if (n < 2) {
- return n;
- }
- int[] res = new int[n + 1];
- res[0] = 0;
- res[1] = 1;
- for (int i = 2; i <= n; ++i) {
- res[i] = res[i - 1] + res[i - 2];
- }
- return res[n];
-
- }
-}
-```
-
-
-### 测试用例
-1. 功能测试(如输入 3、5、10 等);
-2. 边界值测试(如输入 0、1、2);
-3. 性能测试(输入较大的数字,如 40、50、100 等)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/10_02_JumpFloor.md b/docs/jianzhioffer/java/10_02_JumpFloor.md
deleted file mode 100644
index 268b7c8af..000000000
--- a/docs/jianzhioffer/java/10_02_JumpFloor.md
+++ /dev/null
@@ -1,42 +0,0 @@
-## 跳台阶
-
-### 题目描述
-一只青蛙一次可以跳上`1`级台阶,也可以跳上`2`级。求该青蛙跳上一个`n`级的台阶总共有多少种跳法(先后次序不同算不同的结果)。
-
-### 解法
-跳上 `n` 级台阶,可以从 `n-1` 级跳 `1` 级上去,也可以从 `n-2` 级跳 `2` 级上去。所以
-```
-f(n) = f(n-1) + f(n-2)
-```
-
-```java
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-public class Solution {
- /**
- * 青蛙跳台阶
- * @param target 跳上的那一级台阶
- * @return 多少种跳法
- */
- public int JumpFloor(int target) {
- if (target < 3) {
- return target;
- }
- int[] res = new int[target + 1];
- res[1] = 1;
- res[2] = 2;
- for (int i = 3; i <= target; ++i) {
- res[i] = res[i - 1] + res[i - 2];
- }
- return res[target];
- }
-}
-```
-
-### 测试用例
-1. 功能测试(如输入 3、5、10 等);
-2. 边界值测试(如输入 0、1、2);
-3. 性能测试(输入较大的数字,如 40、50、100 等)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/10_03_JumpFloorII.md b/docs/jianzhioffer/java/10_03_JumpFloorII.md
deleted file mode 100644
index 91f3ac3ea..000000000
--- a/docs/jianzhioffer/java/10_03_JumpFloorII.md
+++ /dev/null
@@ -1,48 +0,0 @@
-## 变态跳台阶
-
-### 题目描述
-一只青蛙一次可以跳上`1`级台阶,也可以跳上`2`级……它也可以跳上`n`级。求该青蛙跳上一个`n`级的台阶总共有多少种跳法。
-
-### 解法
-跳上 `n-1` 级台阶,可以从 `n-2` 级跳 `1` 级上去,也可以从 `n-3` 级跳 `2` 级上去...也可以从 `0` 级跳上去。那么
-```
-f(n-1) = f(0) + f(1) + ... + f(n-2) ①
-```
-
-跳上 `n` 级台阶,可以从 `n-1` 级跳 `1` 级上去,也可以从 `n-2` 级跳 `2` 级上去...也可以从 `0` 级跳上去。那么
-```
-f(n) = f(0) + f(1) + ... + f(n-2) + f(n-1) ②
-
-②-①:
-f(n) - f(n-1) = f(n-1)
-f(n) = 2f(n-1)
-```
-
-所以 f(n) 是一个等比数列:
-```
-f(n) = 2^(n-1)
-```
-
-
-```java
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-public class Solution {
- /**
- * 青蛙跳台阶II
- * @param target 跳上的那一级台阶
- * @return 多少种跳法
- */
- public int JumpFloorII(int target) {
- return (int) Math.pow(2, target - 1);
- }
-}
-```
-
-### 测试用例
-1. 功能测试(如输入 3、5、10 等);
-2. 边界值测试(如输入 0、1、2);
-3. 性能测试(输入较大的数字,如 40、50、100 等)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/10_04_RectCover.md b/docs/jianzhioffer/java/10_04_RectCover.md
deleted file mode 100644
index 07ddc850c..000000000
--- a/docs/jianzhioffer/java/10_04_RectCover.md
+++ /dev/null
@@ -1,73 +0,0 @@
-## 矩形覆盖
-
-### 题目描述
-我们可以用`2*1`的小矩形横着或者竖着去覆盖更大的矩形。请问用`n`个`2*1`的小矩形无重叠地覆盖一个`2*n`的大矩形,总共有多少种方法?
-
-### 解法
-覆盖 `2*n` 的矩形:
-- 可以先覆盖 `2*n-1` 的矩形,再覆盖一个 `2*1` 的矩形;
-- 也可以先覆盖 `2*(n-2)` 的矩形,再覆盖两个 `1*2` 的矩形。
-
-#### 解法一:利用数组存放结果
-```java
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-public class Solution {
- /**
- * 矩形覆盖
- * @param target 2*target大小的矩形
- * @return 多少种覆盖方法
- */
- public int RectCover(int target) {
- if (target < 3) {
- return target;
- }
- int[] res = new int[target + 1];
- res[1] = 1;
- res[2] = 2;
- for (int i = 3; i <= target; ++i) {
- res[i] = res[i - 1] + res[i - 2];
- }
- return res[target];
- }
-}
-```
-
-#### 解法二:直接用变量存储结果
-```java
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-public class Solution {
- /**
- * 矩形覆盖
- * @param target 2*target大小的矩形
- * @return 多少种覆盖方法
- */
- public int RectCover(int target) {
- if (target < 3) {
- return target;
- }
- int res1 = 1;
- int res2 = 2;
- int res = 0;
- for (int i = 3; i <= target; ++i) {
- res = res1 + res2;
- res1 = res2;
- res2 = res;
- }
- return res;
- }
-}
-```
-
-
-### 测试用例
-1. 功能测试(如输入 3、5、10 等);
-2. 边界值测试(如输入 0、1、2);
-3. 性能测试(输入较大的数字,如 40、50、100 等)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/11_MinNumberInRotatedArray.md b/docs/jianzhioffer/java/11_MinNumberInRotatedArray.md
deleted file mode 100644
index e8fcdad00..000000000
--- a/docs/jianzhioffer/java/11_MinNumberInRotatedArray.md
+++ /dev/null
@@ -1,119 +0,0 @@
-## 旋转数组的最小数字
-
-### 题目描述
-把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组 `{3,4,5,1,2}` 为 `{1,2,3,4,5}` 的一个旋转,该数组的最小值为 `1`。
-
-**NOTE:**给出的所有元素都大于 `0`,若数组大小为 `0`,请返回 `0`。
-
-
-### 解法
-#### 解法一
-直接遍历数组找最小值,时间复杂度 `O(n)`,不推荐。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/10/30
- */
-
-public class Solution {
- /**
- * 获取旋转数组的最小元素
- * @param array 旋转数组
- * @return 数组中的最小值
- */
- public int minNumberInRotateArray(int[] array) {
- if (array == null || array.length == 0) {
- return 0;
- }
-
- int n = array.length;
- if (n == 1 || array[0] < array[n - 1]) {
- return array[0];
- }
-
- int min = array[0];
- for (int i = 1; i < n; ++i) {
- min = array[i] < min ? array[i] : min;
- }
-
- return min;
- }
-
-}
-```
-
-#### 解法二
-利用指针 `p`,`q` 指向数组的首尾,如果 `array[p] < array[q]`,说明数组是递增数组,直接返回 `array[p]`。否则进行如下讨论。
-
-计算中间指针 `mid`:
-- 如果此时 `array[p]`, `array[q]`, `array[mid]` 两两相等,此时无法采用二分方式,只能通过遍历区间 `[p,q]` 获取最小值;
-- 如果此时 `p`,`q` 相邻,说明此时 `q` 指向的元素是最小值,返回 `array[q]`;
-- 如果此时 `array[mid] >= array[p]`,说明 `mid` 位于左边的递增数组中,最小值在右边,因此,把 `p` 指向 `mid`,此时保持了 `p` 指向左边递增子数组;
-- 如果此时 `array[mid] <= array[q]`,说明 `mid` 位于右边的递增数组中,最小值在左边,因此,把 `q` 指向 `mid`,此时保持了 `q` 指向右边递增子数组。
-
-```java
-
-
-/**
- * @author bingo
- * @since 2018/10/30
- */
-
-public class Solution {
- /**
- * 获取旋转数组的最小元素
- * @param array 旋转数组
- * @return 数组中的最小值
- */
- public int minNumberInRotateArray(int[] array) {
- if (array == null || array.length == 0) {
- return 0;
- }
-
- int p = 0;
- // mid初始为p,为了兼容当数组是递增数组(即不满足 array[p] >= array[q])时,返回 array[p]
- int mid = p;
- int q = array.length - 1;
- while (array[p] >= array[q]) {
- if (q - p == 1) {
- // 当p,q相邻时(距离为1),那么q指向的元素就是最小值
- mid = q;
- break;
- }
- mid = p + ((q - p) >> 1);
-
- // 当p,q,mid指向的值相等时,此时只能通过遍历查找最小值
- if (array[p] == array[q] && array[mid] == array[p]) {
- mid = getMinIndex(array, p, q);
- break;
- }
-
- if (array[mid] >= array[p]) {
- p = mid;
- } else if (array[mid] <= array[q]) {
- q = mid;
- }
- }
-
- return array[mid];
-
-
- }
-
- private int getMinIndex(int[] array, int p, int q) {
- int minIndex = p;
- for (int i = p + 1; i <= q; ++i) {
- minIndex = array[i] < array[minIndex] ? i : minIndex;
- }
- return minIndex;
- }
-}
-```
-
-
-### 测试用例
-1. 功能测试(输入的数组是升序排序数组的一个旋转,数组中有重复数字或者没有重复数字);
-2. 边界值测试(输入的数组是一个升序排序的数组,只包含一个数字的数组);
-3. 特殊输入测试(输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/12_StringPathInMatrix.md b/docs/jianzhioffer/java/12_StringPathInMatrix.md
deleted file mode 100644
index 9a87e9e3e..000000000
--- a/docs/jianzhioffer/java/12_StringPathInMatrix.md
+++ /dev/null
@@ -1,66 +0,0 @@
-## 矩阵中的路径
-
-### 题目描述
-请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则之后不能再次进入这个格子。 例如 `a b c e s f c s a d e e` 这样的 `3 X 4` 矩阵中包含一条字符串`"bcced"`的路径,但是矩阵中不包含`"abcb"`路径,因为字符串的第一个字符b占据了矩阵中的第一行第二个格子之后,路径不能再次进入该格子。
-
-### 解法
-回溯法。首先,任选一个格子作为路径起点。假设格子对应的字符为 ch,并且对应路径上的第 i 个字符。若相等,到相邻格子寻找路径上的第 i+1 个字符。重复这一过程。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
- /**
- * 判断矩阵中是否包含某条路径
- * @param matrix 矩阵
- * @param rows 行数
- * @param cols 列数
- * @param str 路径
- * @return bool
- */
- public boolean hasPath(char[] matrix, int rows, int cols, char[] str) {
- if (matrix == null || rows < 1 || cols < 1 || str == null) {
- return false;
- }
- boolean[] visited = new boolean[matrix.length];
- int pathLength = 0;
- for (int i = 0; i < rows; ++i) {
- for (int j = 0; j < cols; ++j) {
- if (hasPath(matrix, rows, cols, str, i, j, pathLength, visited)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean hasPath(char[] matrix, int rows, int cols, char[] str, int i, int j, int pathLength, boolean[] visited) {
- if (pathLength == str.length) {
- return true;
- }
- boolean hasPath = false;
- if (i >= 0 && i < rows && j >= 0 && j < cols && matrix[i * cols + j] == str[pathLength] && !visited[i * cols + j]) {
- ++pathLength;
- visited[i * cols + j] = true;
- hasPath = hasPath(matrix, rows, cols, str, i - 1, j, pathLength, visited)
- || hasPath(matrix, rows, cols, str, i + 1, j, pathLength, visited)
- || hasPath(matrix, rows, cols, str, i, j - 1, pathLength, visited)
- || hasPath(matrix, rows, cols, str, i, j + 1, pathLength, visited);
- if (!hasPath) {
- --pathLength;
- visited[i * cols + j] = false;
- }
- }
- return hasPath;
- }
-}
-
-```
-
-### 测试用例
-1. 功能测试(在多行多列的矩阵中存在或者不存在路径);
-2. 边界值测试(矩阵只有一行或者一列;矩阵和路径中的所有字母都是相同的);
-3. 特殊输入测试(输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/13_RobotMove.md b/docs/jianzhioffer/java/13_RobotMove.md
deleted file mode 100644
index 7a4e8d5ed..000000000
--- a/docs/jianzhioffer/java/13_RobotMove.md
+++ /dev/null
@@ -1,66 +0,0 @@
-## 机器人的移动范围
-
-### 题目描述
-地上有一个`m`行和`n`列的方格。一个机器人从坐标`0,0`的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于`k`的格子。 例如,当`k`为`18`时,机器人能够进入方格`(35,37)`,因为`3+5+3+7 = 18`。但是,它不能进入方格`(35,38)`,因为`3+5+3+8 = 19`。请问该机器人能够达到多少个格子?
-
-### 解法
-从坐标(0, 0) 开始移动,当它准备进入坐标(i, j),判断是否能进入,如果能,再判断它能否进入 4 个相邻的格子 (i-1, j), (i+1, j), (i, j-1), (i, j+1)。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
- /**
- * 计算能到达的格子数
- * @param threshold 限定的数字
- * @param rows 行数
- * @param cols 列数
- * @return 格子数
- */
- public int movingCount(int threshold, int rows, int cols) {
- if (threshold < 0 || rows < 1 || cols < 1) {
- return 0;
- }
- boolean[] visited = new boolean[rows * cols];
- return getCount(threshold, 0, 0, rows, cols, visited);
- }
-
- private int getCount(int threshold, int i, int j, int rows, int cols, boolean[] visited) {
- if (check(threshold, i, j, rows, cols, visited)) {
- visited[i * cols + j] = true;
- return 1
- + getCount(threshold, i - 1, j, rows, cols, visited)
- + getCount(threshold, i + 1, j, rows, cols, visited)
- + getCount(threshold, i, j - 1, rows, cols, visited)
- + getCount(threshold, i, j + 1, rows, cols, visited);
- }
- return 0;
- }
-
- private boolean check(int threshold, int i, int j, int rows, int cols, boolean[] visited) {
- return i >= 0
- && i < rows
- && j >= 0
- && j < cols
- && !visited[i * cols + j]
- && getDigitSum(i) + getDigitSum(j) <= threshold;
- }
-
- private int getDigitSum(int i) {
- int res = 0;
- while (i > 0) {
- res += i % 10;
- i /= 10;
- }
- return res;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(方格为多行多列;k 为正数);
-2. 边界值测试(方格只有一行或者一列;k = 0);
-3. 特殊输入测试(k < 0)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/14_CuttingRope.md b/docs/jianzhioffer/java/14_CuttingRope.md
deleted file mode 100644
index c120a5b78..000000000
--- a/docs/jianzhioffer/java/14_CuttingRope.md
+++ /dev/null
@@ -1,102 +0,0 @@
-## 剪绳子
-
-### 题目描述
-给你一根长度为`n`绳子,请把绳子剪成`m`段(`m`、`n`都是整数,`n>1`并且`m≥1`)。每段的绳子的长度记为k[0]、k[1]、……、k[m]。k[0]*k[1]*…*k[m]可能的最大乘积是多少?例如当绳子的长度是 8 时,我们把它剪成长度分别为 `2、3、3` 的三段,此时得到最大的乘积`18`。
-
-### 解法
-#### 解法一:动态规划法
-时间复杂度`O(n²)`,空间复杂度`O(n)`。
-
-- 长度为 2,只可能剪成长度为 1 的两段,因此 f(2)=1
-- 长度为 3,剪成长度分别为 1 和 2 的两段,乘积比较大,因此 f(3) = 2
-- 长度为 n,在剪第一刀的时候,有 n-1 种可能的选择,剪出来的绳子又可以继续剪,可以看出,原问题可以划分为子问题,子问题又有重复子问题。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
-
- /**
- * 剪绳子求最大乘积
- * @param length 绳子长度
- * @return 乘积最大值
- */
- public int maxProductAfterCutting(int length) {
- if (length < 2) {
- return 0;
- }
- if (length < 4) {
- return length - 1;
- }
-
- // res[i] 表示当长度为i时的最大乘积
- int[] res = new int[length + 1];
- res[1] = 1;
- res[2] = 2;
- res[3] = 3;
- // 从长度为4开始计算
- for (int i = 4; i <= length; ++i) {
- int max = 0;
- for (int j = 1; j <= i / 2; ++j) {
- max = Math.max(max, res[j] * res[i - j]);
- }
- res[i] = max;
- }
-
- return res[length];
-
- }
-}
-
-```
-
-#### 贪心算法
-时间复杂度`O(1)`,空间复杂度`O(1)`。
-
-贪心策略:
-- 当 n>=5 时,尽可能多地剪长度为 3 的绳子
-- 当剩下的绳子长度为 4 时,就把绳子剪成两段长度为 2 的绳子。
-
-**证明:**
-- 当 n>=5 时,可以证明 2(n-2)>n,并且 3(n-3)>n。也就是说,当绳子剩下长度大于或者等于 5 的时候,可以把它剪成长度为 3 或者 2 的绳子段。
-- 当 n>=5 时,3(n-3)>=2(n-2),因此,应该尽可能多地剪长度为 3 的绳子段。
-- 当 n=4 时,剪成两根长度为 2 的绳子,其实没必要剪,只是题目的要求是至少要剪一刀。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
-
- /**
- * 剪绳子求最大乘积
- * @param length 绳子长度
- * @return 乘积最大值
- */
- public int maxProductAfterCutting(int length) {
- if (length < 2) {
- return 0;
- }
- if (length < 4) {
- return length - 1;
- }
-
- int timesOf3 = length / 3;
- if (length % 3 == 1) {
- --timesOf3;
- }
- int timesOf2 = (length - timesOf3 * 3) >> 1;
- return (int) (Math.pow(3, timesOf3) * Math.pow(2, timesOf2));
- }
-}
-
-```
-
-### 测试用例
-1. 功能测试(绳子的初始长度大于 5);
-2. 边界值测试(绳子的初始长度分别为 0、1、2、3、4)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/15_NumberOf1InBinary.md b/docs/jianzhioffer/java/15_NumberOf1InBinary.md
deleted file mode 100644
index 23bf9351a..000000000
--- a/docs/jianzhioffer/java/15_NumberOf1InBinary.md
+++ /dev/null
@@ -1,73 +0,0 @@
-## 二进制中 1 的个数
-
-### 题目描述
-输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。
-
-### 解法
-#### 解法一
-利用整数 1,依次左移每次与 n 进行与运算,若结果不为0,说明这一位上数字为 1,++cnt。
-
-此解法 i 需要左移 32 次。
-
-不要用 n 去右移并与 1 进行与运算,因为n 可能为负数,右移时会陷入死循环。
-
-```java
-public class Solution {
- public int NumberOf1(int n) {
- int cnt = 0;
- int i = 1;
- while (i != 0) {
- if ((n & i) != 0) {
- ++cnt;
- }
- i <<= 1;
- }
- return cnt;
- }
-}
-```
-
-#### 解法二(推荐)
-- 运算 (n - 1) & n,直至 n 为 0。运算的次数即为 n 的二进制中 1 的个数。
-
-因为 n-1 会将 n 的最右边一位 1 改为 0,如果右边还有 0,则所有 0 都会变成 1。结果与 n 进行与运算,会去除掉最右边的一个1。
-
-举个栗子:
-```
-若 n = 1100,
-n - 1 = 1011
-n & (n - 1) = 1000
-
-即:把最右边的 1 变成了 0。
-```
-
-> 把一个整数减去 1 之后再和原来的整数做位与运算,得到的结果相当于把整数的二进制表示中最右边的 1 变成 0。很多二进制的问题都可以用这种思路解决。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
- /**
- * 计算整数的二进制表示里1的个数
- * @param n 整数
- * @return 1的个数
- */
- public int NumberOf1(int n) {
- int cnt = 0;
- while (n != 0) {
- n = (n - 1 ) & n;
- ++cnt;
- }
- return cnt;
- }
-}
-
-```
-
-### 测试用例
-1. 正数(包括边界值 1、0x7FFFFFFF);
-2. 负数(包括边界值 0x80000000、0xFFFFFFFF);
-3. 0。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/16_Power.md b/docs/jianzhioffer/java/16_Power.md
deleted file mode 100644
index f1bbc09c8..000000000
--- a/docs/jianzhioffer/java/16_Power.md
+++ /dev/null
@@ -1,36 +0,0 @@
-## 数值的整数次方
-
-### 题目描述
-给定一个 `double` 类型的浮点数 `base` 和 `int` 类型的整数 `exponent`。求 `base`的 `exponent` 次方。
-
-### 解法
-注意判断值数是否小于 0。另外 0 的 0 次方没有意义,也需要考虑一下,看具体题目要求。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
- /**
- * 计算数值的整数次方
- * @param base 底数
- * @param exponent 指数
- * @return 数值的整数次方
- */
- public double Power(double base, int exponent) {
- double result = 1.0;
- int n = Math.abs(exponent);
- for (int i = 0; i < n; ++i) {
- result *= base;
- }
-
- return exponent < 0 ? 1.0 / result : result;
- }
-}
-
-```
-
-### 测试用例
-1. 把底数和指数分别设为正数、负数和零。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/17_Print1ToMaxOfNDigits.md b/docs/jianzhioffer/java/17_Print1ToMaxOfNDigits.md
deleted file mode 100644
index 86b8e8fa3..000000000
--- a/docs/jianzhioffer/java/17_Print1ToMaxOfNDigits.md
+++ /dev/null
@@ -1,90 +0,0 @@
-## 打印从 1 到最大的 n 位数
-
-### 题目描述
-输入数字 `n`,按顺序打印出从 `1` 最大的 `n` 位十进制数。比如输入 `3`,则打印出 `1、2、3` 一直到最大的 3 位数即 999。
-
-### 解法
-此题需要注意 n 位数构成的数字可能超出最大的 int 或者 long long 能表示的范围。因此,采用字符数组来存储数字。
-
-关键是:
-- 对字符数组表示的数进行递增操作
-- 输出数字(0开头的需要把0去除)
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
-
- /**
- * 打印从1到最大的n位数
- * @param n n位
- */
- public void print1ToMaxOfNDigits(int n) {
- if (n < 1) {
- return;
- }
-
- char[] chars = new char[n];
- for (int i = 0; i < n; ++i) {
- chars[i] = '0';
- }
-
- while (!increment(chars)) {
- printNumber(chars);
- }
- }
-
- /**
- * 打印数字(去除前面的0)
- * @param chars 数字数组
- */
- private void printNumber(char[] chars) {
- int index = 0;
- int n = chars.length;
- for (char ch : chars) {
- if (ch != '0') {
- break;
- }
- ++index;
- }
- StringBuilder sb = new StringBuilder();
- for (int i = index; i < n; ++i) {
- sb.append(chars[i]);
- }
- System.out.println(sb.toString());
- }
-
- /**
- * 数字加1
- * @param chars 数字数组
- * @return 是否溢出
- */
- private boolean increment(char[] chars) {
- boolean flag = false;
- int n = chars.length;
- int carry = 1;
- for (int i = n - 1; i >= 0; --i) {
-
- int num = chars[i] - '0' + carry;
- if (num > 9) {
- if (i == 0) {
- flag = true;
- break;
- }
- chars[i] = '0';
- } else {
- ++chars[i];
- break;
- }
- }
- return flag;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入 1、2、3......);
-2. 特殊输入测试(输入 -1、0)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/18_01_DeleteNodeInList.md b/docs/jianzhioffer/java/18_01_DeleteNodeInList.md
deleted file mode 100644
index fdebe01dc..000000000
--- a/docs/jianzhioffer/java/18_01_DeleteNodeInList.md
+++ /dev/null
@@ -1,59 +0,0 @@
-## 在O(1)时间内删除链表节点
-
-### 题目描述
-给定单向链表的头指针和一个节点指针,定义一个函数在 O(1) 时间内删除该节点。
-
-### 解法
-判断要删除的节点是否是尾节点,若是,直接删除;若不是,把要删除节点的下一个节点赋给要删除的节点即可。
-
-### ```进行n次操作,平均时间复杂度为:( (n-1) * O(1) + O(n) ) / n = O(1),所以符合题目上说的O(1)```
-
-```java
-/**
- * @author bingo
- * @since 2018/11/20
- */
-
-public class Solution {
-
- class ListNode {
- int val;
- ListNode next;
- }
-
- /**
- * 删除链表的节点
- * @param head 链表头节点
- * @param tobeDelete 要删除的节点
- */
- public ListNode deleteNode(ListNode head, ListNode tobeDelete) {
- if (head == null || tobeDelete == null) {
- return head;
- }
-
- // 删除的不是尾节点
- if (tobeDelete.next != null) {
- tobeDelete.val = tobeDelete.next.val;
- tobeDelete.next = tobeDelete.next.next;
- }
- // 链表中仅有一个节点
- else if (head == tobeDelete) {
- head = null;
- }
- // 删除的是尾节点
- else {
- ListNode ptr = head;
- while (ptr.next != tobeDelete) {
- ptr = ptr.next;
- }
- ptr.next = null;
- }
-
- return head;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(从有多个节点的链表的中间/头部/尾部删除一个节点;从只有一个节点的链表中删除唯一的节点);
-2. 特殊输入测试(指向链表头节点的为空指针;指向要删除节点的为空指针)。
diff --git a/docs/jianzhioffer/java/18_02_DeleteDuplicatedNode.md b/docs/jianzhioffer/java/18_02_DeleteDuplicatedNode.md
deleted file mode 100644
index 054e6e341..000000000
--- a/docs/jianzhioffer/java/18_02_DeleteDuplicatedNode.md
+++ /dev/null
@@ -1,94 +0,0 @@
-## 删除链表中重复的节点
-
-### 题目描述
-在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表`1->2->3->3->4->4->5` 处理后为 `1->2->5`。
-
-### 解法
-#### 解法一:递归
-
-```java
-/**
- * @author bingo
- * @since 2018/11/21
- */
-
-/*
- public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}
-*/
-public class Solution {
- /**
- * 删除链表重复的节点
- * @param pHead 链表头节点
- * @return 删除节点后的链表
- */
- public ListNode deleteDuplication(ListNode pHead) {
- if (pHead == null || pHead.next == null) {
- return pHead;
- }
-
- if (pHead.val == pHead.next.val) {
- if (pHead.next.next == null) {
- return null;
- }
- if (pHead.next.next.val == pHead.val) {
- return deleteDuplication(pHead.next);
- }
- return deleteDuplication(pHead.next.next);
- }
- pHead.next = deleteDuplication(pHead.next);
- return pHead;
- }
-}
-```
-
-#### 解法二
-```java
-/*
- public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}
-*/
-public class Solution {
- public ListNode deleteDuplication(ListNode pHead) {
- if (pHead == null || pHead.next == null) {
- return pHead;
- }
-
- ListNode pre = null;
- ListNode cur = pHead;
- while (cur != null) {
- if (cur.next != null && cur.next.val == cur.val) {
- int val = cur.val;
- while (cur.next != null && cur.next.val == val) {
- cur = cur.next;
- }
- if (pre == null) {
- pHead = cur.next;
- } else {
- pre.next = cur.next;
- }
- } else {
- pre = cur;
- }
- cur = cur.next;
- }
- return pHead;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(重复的节点位于链表的头部/中间/尾部;链表中没有重复的节点);
-2. 特殊输入测试(指向链表头节点的为空指针;链表中所有节点都是重复的)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/19_RegularExpressionsMatching.md b/docs/jianzhioffer/java/19_RegularExpressionsMatching.md
deleted file mode 100644
index 5cd4833bb..000000000
--- a/docs/jianzhioffer/java/19_RegularExpressionsMatching.md
+++ /dev/null
@@ -1,68 +0,0 @@
-## 正则表达式匹配
-
-### 题目描述
-请实现一个函数用来匹配包括`.`和`*`的正则表达式。模式中的字符`.`表示任意一个字符,而`*`表示它前面的字符可以出现任意次(包含`0`次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。例如,字符串`aaa`与模式`a.a`和`ab*ac*a`匹配,但是与`aa.a`和`ab*a`均不匹配。
-
-### 解法
-判断模式中第二个字符是否是 `*`:
-- 若是,看如果模式串第一个字符与字符串第一个字符是否匹配:
- - 1. 若不匹配,在模式串上向右移动两个字符`j+2`,相当于 a* 被忽略
- - 2. 若匹配,字符串后移`i+1`。此时模式串可以移动两个字符`j+2`,也可以不移动`j`。
-- 若不是,看当前字符与模式串的当前字符是否匹配,即 str[i] == pattern[j] || pattern[j] == '.':
- - 1. 若匹配,则字符串与模式串都向右移动一位,`i+1`,`j+1`。
- - 2. 若不匹配,返回 fasle。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/21
- */
-
-public class Solution {
- /**
- * 判断字符串是否与模式串匹配
- * @param str 字符串
- * @param pattern 模式串
- * @return 是否匹配
- */
- public boolean match(char[] str, char[] pattern) {
- if (str == null || pattern == null) {
- return false;
- }
- return match(str, 0, str.length, pattern, 0, pattern.length);
- }
-
- private boolean match(char[] str, int i, int len1,
- char[] pattern, int j, int len2) {
- if (i == len1 && j == len2) {
- return true;
- }
-
- // "",".*"
- if (i != len1 && j == len2) {
- return false;
- }
-
- if (j + 1 < len2 && pattern[j + 1] == '*') {
- if (i < len1 && (str[i] == pattern[j] || pattern[j] == '.')) {
- return match(str, i, len1, pattern, j + 2, len2)
- || match(str, i + 1, len1, pattern, j, len2)
- || match(str, i + 1, len1, pattern,j + 2, len2);
- }
-
- // "",".*"
- return match(str, i, len1, pattern, j + 2, len2);
-
- }
- if (i < len1 && (str[i] == pattern[j] || pattern[j] == '.')) {
- return match(str, i + 1, len1, pattern, j + 1, len2);
- }
- return false;
-
- }
-}
-```
-
-### 测试用例
-1. 功能测试(模式字符串里包含普通字符、`.`、`*`;模式字符串和输入字符串匹配/不匹配);
-2. 特殊输入测试(输入字符串和模式字符串是空指针、空字符串)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/20_NumericStrings.md b/docs/jianzhioffer/java/20_NumericStrings.md
deleted file mode 100644
index 55fa620c8..000000000
--- a/docs/jianzhioffer/java/20_NumericStrings.md
+++ /dev/null
@@ -1,115 +0,0 @@
-## 表示数值的字符串
-
-### 题目描述
-请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。例如,字符串"+100","5e2","-123","3.1416"和"-1E-16"都表示数值。 但是"12e","1a3.14","1.2.3","+-5"和"12e+4.3"都不是。
-
-### 解法
-
-#### 解法一
-
-利用正则表达式匹配即可。
-```
-[] : 字符集合
-() : 分组
-? : 重复 0 ~ 1
-+ : 重复 1 ~ n
-* : 重复 0 ~ n
-. : 任意字符
-\\. : 转义后的 .
-\\d : 数字
-```
-
-```java
-/**
- * @author bingo
- * @since 2018/11/21
- */
-
-public class Solution {
- /**
- * 判断是否是数字
- * @param str
- * @return
- */
- public boolean isNumeric(char[] str) {
- return str != null
- && str.length != 0
- && new String(str).matches("[+-]?\\d*(\\.\\d+)?([eE][+-]?\\d+)?");
- }
-}
-```
-
-#### 解法二【剑指offer解法】
-
-表示数值的字符串遵循模式`A[.[B]][e|EC]`或者`.B[e|EC]`,其中A为数值的整数部分,B紧跟小数点为数值的小数部分,C紧跟着e或者E为数值的指数部分。上述A和C都有可能以 `+` 或者 `-` 开头的0~9的数位串,B也是0~9的数位串,但前面不能有正负号。
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2018/12/29
- * @description
- */
-public class Solution {
-
- private int index = 0;
-
- /**
- * 判断是否是数值
- * @param str
- * @return
- */
- public boolean isNumeric(char[] str) {
- if (str == null || str.length < 1) {
- return false;
- }
-
- // 判断是否存在整数
- boolean flag = scanInteger(str);
-
- // 小数部分
- if (index < str.length && str[index] == '.') {
- index++;
- // 小数部分可以有整数或者没有整数
- // 所以使用 ||
- flag = scanUnsignedInteger(str) || flag;
- }
-
- if (index < str.length && (str[index] == 'e' || str[index] == 'E')) {
- index++;
- // e或E前面必须有数字
- // e或者E后面必须有整数
- // 所以使用 &&
- flag = scanInteger(str) && flag;
- }
-
- return flag && index == str.length;
-
- }
-
- private boolean scanInteger(char[] str) {
- // 去除符号
- while (index < str.length && (str[index] == '+' || str[index] == '-')) {
- index++;
- }
-
- return scanUnsignedInteger(str);
- }
-
- private boolean scanUnsignedInteger(char[] str) {
- int start = index;
- while (index < str.length && str[index] >= '0' && str[index] <= '9') {
- index++;
- }
- // 判断是否存在整数
- return index > start;
- }
-}
-```
-
-
-
-### 测试用例
-
-1. 功能测试(正数或者负数;包含或者不包含整数部分的数值;包含或者不包含效数部分的值;包含或者不包含指数部分的值;各种不能表达有效数值的字符串);
-2. 特殊输入测试(输入字符串和模式字符串是空指针、空字符串)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/21_ReorderArray.md b/docs/jianzhioffer/java/21_ReorderArray.md
deleted file mode 100644
index a4730a321..000000000
--- a/docs/jianzhioffer/java/21_ReorderArray.md
+++ /dev/null
@@ -1,68 +0,0 @@
-## 调整数组顺序使奇数位于偶数前面
-
-### 题目描述
-输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。
-
-### 解法
-#### 解法一
-计算出奇数的个数,就很容易写出来了。
-
-```java
-import java.util.Arrays;
-
-/**
- * @author bingo
- * @since 2018/11/21
- */
-
-public class Solution {
- /**
- * 调整数组元素顺序,使得奇数元素位于偶数元素前面,且保证奇数和奇数,偶数和偶数之间的相对位置不变。
- * @param array 数组
- */
- public void reOrderArray(int [] array) {
- if (array == null || array.length < 2) {
- return;
- }
-
- int numsOfOdd = 0;
- for (int val : array) {
- if (val % 2 == 1) {
- ++numsOfOdd;
- }
- }
- int[] bak = Arrays.copyOf(array, array.length);
- int i = 0, j = numsOfOdd;
- for (int val : bak) {
- if (val % 2 == 1) {
- array[i++] = val;
- } else {
- array[j++] = val;
- }
- }
- }
-
-}
-```
-
-#### 解法二
-```java
-import java.util.Arrays;
-
-public class Solution {
- public void reOrderArray(int [] array) {
- if (array == null || array.length < 2) {
- return;
- }
- Integer[] bak = new Integer[array.length];
- Arrays.setAll(bak, i -> array[i]);
- Arrays.sort(bak, (x, y) -> (y & 1) - (x & 1));
- Arrays.setAll(array, i -> bak[i]);
- }
-
-}
-```
-
-### 测试用例
-1. 功能测试(输入数组中的奇数、偶数交替出现;输入的数组中所有偶数都出现在奇数的前面;输入的数组中所有偶数都出现在奇数的前面;输入的数组中所有奇数都出现在偶数的前面);
-2. 特殊输入测试(输入空指针;输入的数组只包含一个数字)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/22_KthNodeFromEnd.md b/docs/jianzhioffer/java/22_KthNodeFromEnd.md
deleted file mode 100644
index 2e54c99e4..000000000
--- a/docs/jianzhioffer/java/22_KthNodeFromEnd.md
+++ /dev/null
@@ -1,61 +0,0 @@
-## 链表中倒数第k个结点
-
-### 题目描述
-输入一个链表,输出该链表中倒数第k个结点。
-
-### 解法
-pre 指针走 `k-1` 步。之后 cur 指针指向 phead,然后两个指针同时走,直至 pre 指针到达尾结点。
-
-> 当用一个指针遍历链表不能解决问题的时候,可以尝试用两个指针来遍历链表。可以让其中一个指针遍历的速度快一些。
-
-此题需要考虑一些特殊情况。比如 k 的值小于 0 或者大于链表长度。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/21
- */
-
-/*
-public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}*/
-public class Solution {
- /**
- * 找出链表倒数第k个节点,k从1开始
- * @param head 链表头部
- * @param k 第k个节点
- * @return 倒数第k个节点
- */
- public ListNode FindKthToTail(ListNode head,int k) {
- if (head == null || k < 1) {
- return null;
- }
-
- ListNode pre = head;
- for (int i = 0; i < k - 1; ++i) {
- if (pre.next != null) {
- pre = pre.next;
- } else {
- return null;
- }
- }
-
- ListNode cur = head;
- while (pre.next != null) {
- pre = pre.next;
- cur = cur.next;
- }
- return cur;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(第 k 个节点在链表的中间/头部/尾部);
-2. 特殊输入测试(输入空指针;链表的节点总数小于 k;k=0)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/23_EntryNodeInListLoop.md b/docs/jianzhioffer/java/23_EntryNodeInListLoop.md
deleted file mode 100644
index 262cd9f58..000000000
--- a/docs/jianzhioffer/java/23_EntryNodeInListLoop.md
+++ /dev/null
@@ -1,83 +0,0 @@
-## 链表中环的入口结点
-
-### 题目描述
-给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出`null`。
-
-### 解法
-- 先利用快慢指针。若能相遇,说明存在环,且相遇点一定是在环上;若没有相遇,说明不存在环,返回 `null`。
-- 固定当前相遇点,用一个指针继续走,同时累积结点数。计算出环的结点个数 `cnt`。
-- 指针 p1 先走 `cnt` 步,p2 指向链表头部,之后 `p1`,`p2` 同时走,相遇时,相遇点一定是在环的入口处。因为 `p1` 比 `p2` 多走了环的一圈。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-/*
- public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}
-*/
-public class Solution {
-
- /**
- * 求链表环的入口,若没有环,返回null
- * @param pHead 链表头
- * @return 环的入口点
- */
- public ListNode EntryNodeOfLoop(ListNode pHead) {
- if (pHead == null || pHead.next == null) {
- return null;
- }
- ListNode fast = pHead;
- ListNode slow = pHead;
- boolean flag = false;
- while (fast != null && fast.next != null) {
- slow = slow.next;
- fast = fast.next.next;
- if (fast == slow) {
- flag = true;
- break;
- }
- }
-
- // 快指针与慢指针没有相遇,说明无环,返回 null
- if (!flag) {
- return null;
- }
-
- ListNode cur = slow.next;
- // 求出环中结点个数
- int cnt = 1;
- while (cur != slow) {
- cur = cur.next;
- ++cnt;
- }
-
- // 指针p1先走cnt步
- ListNode p1 = pHead;
- for (int i = 0; i < cnt; ++i) {
- p1 = p1.next;
- }
-
- // p2指向链表头,然后p1/p2同时走,首次相遇的地方就是环的入口
- ListNode p2 = pHead;
- while (p1 != p2) {
- p1 = p1.next;
- p2 = p2.next;
- }
- return p1;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(链表中包含/不包含环;链表中有多个或者只有一个节点);
-2. 特殊输入测试(链表头节点为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/24_ReverseList.md b/docs/jianzhioffer/java/24_ReverseList.md
deleted file mode 100644
index 118d65874..000000000
--- a/docs/jianzhioffer/java/24_ReverseList.md
+++ /dev/null
@@ -1,94 +0,0 @@
-## 反转链表
-
-### 题目描述
-输入一个链表,反转链表后,输出新链表的表头。
-
-### 解法
-#### 解法一
-利用头插法解决。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-/*
-public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}*/
-public class Solution {
- /**
- * 反转链表
- * @param head 链表头部
- * @return 反转后的链表
- */
- public ListNode ReverseList(ListNode head) {
- if (head == null || head.next == null) {
- return head;
- }
-
- ListNode dummy = new ListNode(-1);
- dummy.next = null;
- ListNode p1 = head;
- ListNode p2 = p1.next;
- while (p1 != null) {
- p1.next = dummy.next;
- dummy.next = p1;
- p1 = p2;
- if (p1 == null) {
- break;
- }
- p2 = p1.next;
- }
-
- return dummy.next;
- }
-}
-```
-
-#### 解法二:递归
-
-```java
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-
-/*
-public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}*/
-public class Solution {
- public ListNode ReverseList(ListNode head) {
- if (head == null || head.next == null) {
- return head;
- }
-
- ListNode next = ReverseList(head.next);
- ListNode cur = next;
- while (cur.next != null) {
- cur = cur.next;
- }
- cur.next = head;
- head.next = null;
- return next;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(链表中有多个结点/只有一个节点);
-2. 特殊输入测试(链表头节点为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/25_MergeSortedLists.md b/docs/jianzhioffer/java/25_MergeSortedLists.md
deleted file mode 100644
index 9bcc3c7b0..000000000
--- a/docs/jianzhioffer/java/25_MergeSortedLists.md
+++ /dev/null
@@ -1,112 +0,0 @@
-## 合并两个排序的链表
-
-### 题目描述
-输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。
-
-### 解法
-#### 解法一
-同时遍历两链表进行 `merge`。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-/*
-public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}*/
-public class Solution {
- /**
- * 合并两个排序链表
- * @param list1 链表1
- * @param list2 链表2
- * @return 合并后的单调不递减链表
- */
- public ListNode Merge(ListNode list1, ListNode list2) {
- if (list1 == null) {
- return list2;
- }
- if (list2 == null) {
- return list1;
- }
-
- ListNode dummy = new ListNode(-1);
- ListNode cur = dummy;
- ListNode p1 = list1;
- ListNode p2 = list2;
- while (p1 != null && p2 != null) {
- if (p1.val < p2.val) {
- ListNode t = p1.next;
- cur.next = p1;
- p1.next = null;
- p1 = t;
- } else {
- ListNode t = p2.next;
- cur.next = p2;
- p2.next = null;
- p2 = t;
- }
- cur = cur.next;
- }
-
- cur.next = p1 == null ? p2 : p1;
- return dummy.next;
-
- }
-}
-```
-
-#### 解法二:递归
-```java
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-/*
-public class ListNode {
- int val;
- ListNode next = null;
-
- ListNode(int val) {
- this.val = val;
- }
-}*/
-public class Solution {
- /**
- * 合并两个排序链表
- * @param list1 链表1
- * @param list2 链表2
- * @return 合并后的单调不递减链表
- */
- public ListNode Merge(ListNode list1, ListNode list2) {
- if (list1 == null) {
- return list2;
- }
- if (list2 == null) {
- return list1;
- }
-
- if (list1.val < list2.val) {
- list1.next = Merge(list1.next, list2);
- return list1;
- }
-
- list2.next = Merge(list1, list2.next);
- return list2;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的两个链表有多个节点;节点的值互不相同或者存在值相等的多个节点);
-2. 特殊输入测试(两个链表的一个或者两个头节点为空指针;两个链表中只有一个节点)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/26_SubstructureInTree.md b/docs/jianzhioffer/java/26_SubstructureInTree.md
deleted file mode 100644
index 24b852e96..000000000
--- a/docs/jianzhioffer/java/26_SubstructureInTree.md
+++ /dev/null
@@ -1,69 +0,0 @@
-## 树的子结构
-
-### 题目描述
-输入两棵二叉树`A`,`B`,判断`B`是不是`A`的子结构。(ps:我们约定空树不是任意一个树的子结构)
-
-### 解法
-递归方式遍历:
-
-- 在树A中找到和树B的根结点值一样的结点R
-- 判断树A以R为根结点的子树是否包含与树B一样的结构
-
-这道题的time complexity应该为O(n * m),其中n为root1的节点数,m为root2的节点数。
-
-```java
-/**
-public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-}
-*/
-
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/01/01
- * @description
- */
-public class Solution {
-
- public boolean HasSubtree(TreeNode root1, TreeNode root2) {
-
- if (root1 == null || root2 == null) {
- return false;
- }
-
- return isSame(root1, root2) ||
- HasSubtree(root1.left, root2) || HasSubtree(root1.right, root2);
- }
-
- private boolean isSame(TreeNode root1, TreeNode root2) {
-
- if (root2 == null) {
- return true;
- }
-
- // 在root2,root1遍历完成后,仍未找到符合的结构,返回false
- if (root1 == null) {
- return false;
- }
-
- if (root1.val != root2.val) {
- return false;
- }
-
- return isSame(root1.left, root2.left) && isSame(root1.right, root2.right);
- }
-
-}
-```
-
-### 测试用例
-1. 功能测试(树A和树B都是普通的二叉树;树B是/不是树A的子结构);
-2. 特殊输入测试(两棵二叉树的一个或者两个根结点为空指针,二叉树的所有结点都没有左/右子树)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/27_MirrorOfBinaryTree.md b/docs/jianzhioffer/java/27_MirrorOfBinaryTree.md
deleted file mode 100644
index 8e036d5c2..000000000
--- a/docs/jianzhioffer/java/27_MirrorOfBinaryTree.md
+++ /dev/null
@@ -1,70 +0,0 @@
-## 二叉树的镜像
-
-### 题目描述
-操作给定的二叉树,将其变换为源二叉树的镜像。
-
-```
-源二叉树
- 8
- / \
- 6 10
- / \ / \
- 5 7 9 11
-
-镜像二叉树
- 8
- / \
- 10 6
- / \ / \
- 11 9 7 5
-```
-
-### 解法
-将根结点的左右孩子互换,之后递归左右孩子。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-/*
- public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
- }
- */
-public class Solution {
- /**
- * 将二叉树转换为它的镜像
- * @param root 二叉树的根结点
- */
- public void Mirror(TreeNode root) {
- if (root == null || !hasChild(root)) {
- return;
- }
-
- TreeNode t = root.left;
- root.left = root.right;
- root.right = t;
- Mirror(root.left);
- Mirror(root.right);
- }
-
- private boolean hasChild(TreeNode root) {
- return root.left != null || root.right != null;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(普通的二叉树;二叉树的所有结点都没有左/右子树;只有一个结点的二叉树);
-2. 特殊输入测试(二叉树的根结点为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/28_SymmetricalBinaryTree.md b/docs/jianzhioffer/java/28_SymmetricalBinaryTree.md
deleted file mode 100644
index 6b13edefe..000000000
--- a/docs/jianzhioffer/java/28_SymmetricalBinaryTree.md
+++ /dev/null
@@ -1,58 +0,0 @@
-## 对称的二叉树
-
-### 题目描述
-请实现一个函数,用来判断一颗二叉树是不是对称的。注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的。
-
-### 解法
-比较二叉树的前序遍历序列和对称前序遍历序列是否一样,若是,说明是对称的。
-
-```java
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-/*
-public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
-}
-*/
-public class Solution {
- /**
- * 判断是否是对称二叉树
- * @param pRoot 二叉树的根结点
- * @return 是否为对称二叉树
- */
- boolean isSymmetrical(TreeNode pRoot) {
- return isSymmetrical(pRoot, pRoot);
- }
-
- private boolean isSymmetrical(TreeNode pRoot1, TreeNode pRoot2) {
- if (pRoot1 == null && pRoot2 == null) {
- return true;
- }
- if (pRoot1 == null || pRoot2 == null) {
- return false;
- }
- if (pRoot1.val != pRoot2.val) {
- return false;
- }
-
- return isSymmetrical(pRoot1.left, pRoot2.right) && isSymmetrical(pRoot1.right, pRoot2.left);
-
- }
-}
-```
-
-### 测试用例
-1. 功能测试(对称的二叉树;因结构而不对称的二叉树;结构对称但节点的值不对称的二叉树);
-2. 特殊输入测试(二叉树的根结点为空指针;只有一个节点的二叉树;所有节点的值都相同的二叉树)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/29_PrintMatrix.md b/docs/jianzhioffer/java/29_PrintMatrix.md
deleted file mode 100644
index e47e18c89..000000000
--- a/docs/jianzhioffer/java/29_PrintMatrix.md
+++ /dev/null
@@ -1,103 +0,0 @@
-## 顺时针打印矩阵
-
-### 题目描述
-输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下 `4 X 4` 矩阵:
-```
-1 2 3 4
-5 6 7 8
-9 10 11 12
-13 14 15 16
-```
-
-则依次打印出数字:
-```
-1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.
-```
-### 解法
-剑指offer上的思路有点复杂,需要考虑坐标变换太多,考虑用另一种思路来解决。
-
-在矩阵中,使用左上角坐标(tR,tC)和右下角的坐标(dR,dC)就可以表示一个矩阵。比如题目中的矩阵,当(tR,tC) = (0,0)和(dR,dC) = (3,3)时,表示的子矩阵就是整个矩阵:
-
-```java
-1 2 3 4
-5 8
-9 12
-13 14 15 16
-```
-
-当外层循环遍历后,可以令tR和tC加1,dR和dC减1,执行内层循环。当左上角的坐标跑到右下角坐标的右方或者下方,则整个过程就终止。
-
-```java
-/**
- * @author mcrwayfun
- * @version 1.0
- * @description
- * @date Created in 2019/1/2
- */
-public class Solution {
- /**
- * 转圈打印矩阵
- * @param matrix 矩阵
- * @return 存放结果的list
- */
- public ArrayList printMatrix(int[][] matrix) {
- ArrayList reList = new ArrayList<>();
- if (matrix == null) {
- return reList;
- }
-
- int tR = 0;
- int tC = 0;
- int dR = matrix.length - 1;
- int dC = matrix[0].length - 1;
-
- while (tR <= dR && tC <= dC) {
- printMatrix(matrix, tR++, tC++, dR--, dC--, reList);
- }
-
- return reList;
- }
-
- public void printMatrix(int[][] matrix, int tR, int tC, int dR, int dC, ArrayList reList) {
- // 只有一行
- if (tR == dR) {
- for (int i = tC; i <= dC; i++) {
- reList.add(matrix[tR][i]);
- }
- }
- // 只有一列
- else if (tC == dC) {
- for (int i = tR; i <= dR; i++) {
- reList.add(matrix[i][tC]);
- }
- } else {
- int curR = tR;
- int curC = tC;
- // 从左到右
- while (curC != dC) {
- reList.add(matrix[tR][curC]);
- curC++;
- }
- // 从上到下
- while (curR != dR) {
- reList.add(matrix[curR][dC]);
- curR++;
- }
- // 从右到左
- while (curC != tC) {
- reList.add(matrix[dR][curC]);
- curC--;
- }
- // 从下到上
- while (curR != tR) {
- reList.add(matrix[curR][tC]);
- curR--;
- }
- }
-
- }
-}
-```
-
-### 测试用例
-1. 数组中有多行多列;数组中只有一行;数组中只有一列;数组中只有一行一列。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/30_MinInStack.md b/docs/jianzhioffer/java/30_MinInStack.md
deleted file mode 100644
index 38353b273..000000000
--- a/docs/jianzhioffer/java/30_MinInStack.md
+++ /dev/null
@@ -1,63 +0,0 @@
-## 包含min函数的栈
-
-### 题目描述
-定义栈的数据结构,请在该类型中实现一个能够得到栈中所含最小元素的min函数(时间复杂度应为`O(1)`)。
-
-### 解法
-定义两个`stack`。
-
-压栈时,先将元素`node`压入`stack1`。然后判断`stack2`的情况:
-- `stack2`栈为空或者栈顶元素大于`node`,则将`node`压入`stack2`中。
-- `stack2`栈不为空且栈定元素小于`node`,则重复压入栈顶元素。
-
-获取最小元素时,从`stack2`中获取栈顶元素即可。
-
-```java
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-
-public class Solution {
-
- private Stack stack1 = new Stack<>();
- private Stack stack2 = new Stack<>();
-
- /**
- * 压栈
- * @param node 待压入的元素
- */
- public void push(int node) {
- stack1.push(node);
- if (stack2.isEmpty() || stack2.peek() >= node) {
- stack2.push(node);
- } else {
- stack2.push(stack2.peek());
- }
- }
-
- public void pop() {
- stack1.pop();
- stack2.pop();
- }
-
- public int top() {
- return stack2.peek();
- }
-
- /**
- * O(1)获取栈中最小值
- * @return 最小值
- */
- public int min() {
- return stack2.peek();
- }
-}
-```
-
-### 测试用例
-1. 新压入栈的数字比之前的最小值大/小。
-2. 弹出栈的数字是/不是最小元素。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/31_StackPushPopOrder.md b/docs/jianzhioffer/java/31_StackPushPopOrder.md
deleted file mode 100644
index 3b2a5e590..000000000
--- a/docs/jianzhioffer/java/31_StackPushPopOrder.md
+++ /dev/null
@@ -1,58 +0,0 @@
-## 栈的压入、弹出序列
-
-### 题目描述
-输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否可能为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列`1,2,3,4,5`是某栈的压入顺序,序列`4,5,3,2,1`是该压栈序列对应的一个弹出序列,但`4,3,5,1,2`就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)
-
-### 解法
-判断下一个要弹出的元素:
-- 如果刚好是栈顶元素,直接弹出。
-- 如果不在栈顶,则把压栈序列中还没有入栈的数字压入栈,直到待弹出的数字压入栈顶。
-- 如果所有数字都压入栈顶后依然没有后找到下一个弹出的数字,则不可能是弹出序列。
-
-```java
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/11/22
- */
-
-
-public class Solution {
- /**
- * 判断是否是弹出序列
- * @param pushA 压栈序列
- * @param popA 弹栈序列
- * @return 是否是弹出序列
- */
- public boolean IsPopOrder(int[] pushA,int[] popA) {
- if (pushA == null || popA == null || pushA.length != popA.length) {
- return false;
- }
-
- Stack stack = new Stack<>();
- int i = 0;
- int n = pushA.length;
- boolean flag = false;
- for (int val : popA) {
- while (stack.isEmpty() || stack.peek() != val) {
- if (i >= n) {
- flag = true;
- break;
- }
- stack.push(pushA[i++]);
- }
- if (flag) {
- break;
- }
- stack.pop();
- }
-
- return stack.isEmpty();
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的两个数组含有多个数字或者只有一个数字:第二个数组是/不是第一个数组表示的压入序列对应的栈的弹出序列);
-2. 特殊输入测试(输入两个空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/32_01_PrintTreeFromTopToBottom.md b/docs/jianzhioffer/java/32_01_PrintTreeFromTopToBottom.md
deleted file mode 100644
index c93a997e5..000000000
--- a/docs/jianzhioffer/java/32_01_PrintTreeFromTopToBottom.md
+++ /dev/null
@@ -1,64 +0,0 @@
-## 不分行从上到下打印二叉树
-
-### 题目描述
-从上往下打印出二叉树的每个节点,同层节点从左至右打印。
-
-### 解法
-先将根节点进入队列。
-
-队头元素出队,将值存入 list,判断该元素是否有左/右子树,有的话依次进入队列中。队列为空时结束。
-
-```java
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.Queue;
-
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-/**
- public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
- }
- */
-public class Solution {
- /**
- * 从上到下打印二叉树
- * @param root 二叉树根节点
- * @return 结果list
- */
- public ArrayList PrintFromTopToBottom(TreeNode root) {
- ArrayList list = new ArrayList<>();
- if (root == null) {
- return list;
- }
- Queue queue = new LinkedList<>();
- queue.offer(root);
- while (!queue.isEmpty()) {
- TreeNode node = queue.poll();
- if (node.left != null) {
- queue.offer(node.left);
- }
- if (node.right != null) {
- queue.offer(node.right);
- }
- list.add(node.val);
- }
- return list;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(完全二叉树;所有节点只有左/右子树);
-2. 特殊输入测试(二叉树根节点为空指针;只有一个节点的二叉树)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/32_02_PrintTreesInLines.md b/docs/jianzhioffer/java/32_02_PrintTreesInLines.md
deleted file mode 100644
index 4904948ff..000000000
--- a/docs/jianzhioffer/java/32_02_PrintTreesInLines.md
+++ /dev/null
@@ -1,73 +0,0 @@
-## 把二叉树打印成多行
-
-### 题目描述
-从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。
-
-### 解法
-与上一题类似,只不过需要用变量记录每一层要打印多少个节点。
-
-```java
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.Queue;
-
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-/*
-public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
-}
-*/
-public class Solution {
- /**
- * 把二叉树打印成多行
- * @param pRoot 二叉树根节点
- * @return 结果list
- */
- ArrayList > Print(TreeNode pRoot) {
- ArrayList> list = new ArrayList<>();
- if (pRoot == null) {
- return list;
- }
-
- Queue queue = new LinkedList<>();
- queue.offer(pRoot);
- int cnt = 1;
- while (cnt > 0) {
- int num = cnt;
- cnt = 0;
- ArrayList res = new ArrayList<>();
- for (int i = 0; i < num; ++i) {
- TreeNode node = queue.poll();
- if (node.left != null) {
- queue.offer(node.left);
- ++cnt;
- }
- if (node.right != null) {
- queue.offer(node.right);
- ++cnt;
- }
- res.add(node.val);
- }
- list.add(res);
- }
- return list;
- }
-
-}
-```
-
-### 测试用例
-1. 功能测试(完全二叉树;所有节点只有左/右子树);
-2. 特殊输入测试(二叉树根节点为空指针;只有一个节点的二叉树)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/32_03_PrintTreesInZigzag.md b/docs/jianzhioffer/java/32_03_PrintTreesInZigzag.md
deleted file mode 100644
index 538f10c0a..000000000
--- a/docs/jianzhioffer/java/32_03_PrintTreesInZigzag.md
+++ /dev/null
@@ -1,104 +0,0 @@
-## 按之字形打印二叉树
-
-### 题目描述
-请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推。
-
-如二叉树:
-```
- 1
- / \
- 2 3
- / \ / \
- 4 5 6 7
-```
-
-打印结果为:
-```
-1
-3 2
-4 5 6 7
-```
-
-### 解法
-对于上述二叉树:
-
-首先访问根结点,之后把2、3存入某结构。打印的时候,先打印3、2。这不就是栈?
-
-依次弹出栈元素,分别是3、2。弹出时需要把3、2的子结点存入结构。由于访问时顺序是`4 5 6 7`。所以也需要用栈来存放。而且,此时需要先存放右孩子,再存放左孩子。(奇数层/偶数层存放左右孩子的顺序不同)
-
-这里需要用两个栈来实现。如果只用一个栈,那么当弹出3、2 时,先将 3 的孩子节点压入栈。之后弹栈的时候不是先弹出 2,而是弹出了 3 的 孩子节点,就错了。
-
-
-```java
-import java.util.ArrayList;
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-/*
-public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
-}
-*/
-public class Solution {
- /**
- * 按之字形打印二叉树
- * @param pRoot 二叉树的根节点
- * @return 结果list
- */
- public ArrayList> Print(TreeNode pRoot) {
- ArrayList> res = new ArrayList<>();
- if (pRoot == null) {
- return res;
- }
- Stack stack1 = new Stack<>();
- Stack stack2 = new Stack<>();
- stack1.push(pRoot);
- int i = 1;
- Stack stack = stack1;
- while (!stack.isEmpty()) {
- ArrayList list = new ArrayList<>();
- while (!stack.isEmpty()) {
- TreeNode node = stack.pop();
- list.add(node.val);
- if (i % 2 == 1) {
- if (node.left != null) {
- stack2.push(node.left);
- }
- if (node.right != null) {
- stack2.push(node.right);
- }
- } else {
- if (node.right != null) {
- stack1.push(node.right);
- }
- if (node.left != null) {
- stack1.push(node.left);
- }
- }
- }
- res.add(list);
- ++i;
- stack = stack1.isEmpty() ? stack2 : stack1;
- }
-
- return res;
- }
-
-}
-```
-
-### 测试用例
-1. 功能测试(完全二叉树;所有节点只有左/右子树);
-2. 特殊输入测试(二叉树根节点为空指针;只有一个节点的二叉树)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/33_SquenceOfBST.md b/docs/jianzhioffer/java/33_SquenceOfBST.md
deleted file mode 100644
index 4d99624f8..000000000
--- a/docs/jianzhioffer/java/33_SquenceOfBST.md
+++ /dev/null
@@ -1,60 +0,0 @@
-## 二叉搜索树的后序遍历序列
-
-### 题目描述
-输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则输出`Yes`,否则输出`No`。假设输入的数组的任意两个数字都互不相同。
-
-### 解法
-序列的最后一个元素是二叉搜索树的根节点。
-
-在序列中从左到右找到根节点的左子树(比根节点小)、右子树(比根节点大)。
-- 如果右子树中出现比根节点小的元素,那么为 false。
-- 否则递归左右子树。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-public class Solution {
- /**
- * 判断数组是否是某个二叉搜索树的后序遍历序列
- *
- * @param sequence 数组
- * @return 是否属于某二叉搜索树的后序遍历序列
- */
- public boolean VerifySquenceOfBST(int[] sequence) {
- if (sequence == null || sequence.length < 1) {
- return false;
- }
- return verify(sequence, 0, sequence.length - 1);
- }
-
- private boolean verify(int[] sequence, int start, int end) {
- if (start >= end) {
- return true;
- }
- int val = sequence[end];
- int i = start;
- for (; i <= end; ++i) {
- if (sequence[i] >= val) {
- break;
- }
- }
-
- for (int j = i; j < end; ++j) {
- if (sequence[j] < val) {
- return false;
- }
- }
-
- return verify(sequence, start, i - 1) && verify(sequence, i, end - 1);
-
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的后序遍历序列对应一棵二叉树,包括完全二叉树、所有节点都没有左/右子树的二叉树、只有一个节点的二叉树;输入的后续遍历序列没有对应一棵二叉树);
-2. 特殊输入测试(后序遍历序列为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/34_PathInTree.md b/docs/jianzhioffer/java/34_PathInTree.md
deleted file mode 100644
index d4dfc62a6..000000000
--- a/docs/jianzhioffer/java/34_PathInTree.md
+++ /dev/null
@@ -1,64 +0,0 @@
-## 二叉树中和为某一值的路径
-
-### 题目描述
-输入一颗二叉树的根节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。(注意: 在返回值的`list`中,数组长度大的数组靠前)
-
-### 解法
-
-```java
-import java.util.ArrayList;
-
-/**
- * @author bingo
- * @since 2018/11/23
- */
-
-/**
- public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
- }
- */
-public class Solution {
-
- private ArrayList> res = new ArrayList<>();
-
- /**
- * 找出二叉树中和为某一值的路径(必须从根节点到叶节点)
- *
- * @param root 二叉树的根结点
- * @param target 目标值
- * @return 结果list
- */
- public ArrayList> FindPath(TreeNode root, int target) {
- findPath(root, target, new ArrayList<>());
- return res;
- }
-
- private void findPath(TreeNode root, int target, ArrayList list) {
- if (root == null) {
- return;
- }
- list.add(root.val);
- target -= root.val;
- if (target == 0 && root.left == null && root.right == null) {
- res.add(new ArrayList<>(list));
- } else {
- findPath(root.left, target, list);
- findPath(root.right, target, list);
- }
- list.remove(list.size() - 1);
- }
-}
-```
-
-### 测试用例
-1. 功能测试(二叉树中有一条、多条符合要求的路径;二叉树中没有符合要求的路径);
-2. 特殊输入测试(指向二叉树根节点的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/35_CopyComplexList.md b/docs/jianzhioffer/java/35_CopyComplexList.md
deleted file mode 100644
index 762e595c8..000000000
--- a/docs/jianzhioffer/java/35_CopyComplexList.md
+++ /dev/null
@@ -1,73 +0,0 @@
-## 复杂链表的复制
-
-### 题目描述
-输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的 `head`。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空)
-
-### 解法
-可以分为3步:
-
-1. 复制每个节点,并插入到被复制节点的后面。比如1->2->3 clone 1->1->2->2->3->3
-2. 复制随机节点。当遍历到的当前节点存在随机节点时,则其复制节点也应该存在随机节点。比如当前节点`cur.random != null`,则`RandomListNode clone = cur.next;clone.random = cur.random.next;`
-3. 分离两个链表。其中奇数链表为原链表,偶数链表为复制的链表
-
-这道题的time complexity为O(n)。
-
-```java
-/**
- * @author bingo
- * @since 2018/11/24
- */
-
-/*
-public class RandomListNode {
- int label;
- RandomListNode next = null;
- RandomListNode random = null;
-
- RandomListNode(int label) {
- this.label = label;
- }
-}
-*/
-public class Solution {
- /**
- * 复杂链表的复制
- * @param pHead 链表头结点
- * @return 复制的链表
- */
- public RandomListNode Clone(RandomListNode pHead) {
- if (pHead == null) {
- return null;
- }
- RandomListNode cur = pHead;
- while (cur != null) {
- RandomListNode node = new RandomListNode(cur.label);
- node.next = cur.next;
- cur.next = node;
- cur = node.next;
- }
-
- cur = pHead;
- while (cur != null) {
- RandomListNode clone = cur.next;
- if (cur.random != null) {
- clone.random = cur.random.next;
- }
- cur = clone.next;
- }
-
- cur = pHead;
- RandomListNode cloneHead = pHead.next;
- while (cur.next != null) {
- RandomListNode clone = cur.next;
- cur.next = clone.next;
- cur = clone;
- }
- return cloneHead;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(结点中的 random 指针指向结点自身;两个结点的 random 形成环状结构;链表中只有一个结点);
-2. 特殊输入测试(指向链表头结点的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/36_ConvertBinarySearchTree.md b/docs/jianzhioffer/java/36_ConvertBinarySearchTree.md
deleted file mode 100644
index d80076e29..000000000
--- a/docs/jianzhioffer/java/36_ConvertBinarySearchTree.md
+++ /dev/null
@@ -1,76 +0,0 @@
-## 二叉搜索树与双向链表
-
-### 题目描述
-输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。
-
-### 解法
-由于是二叉搜索树,因此中序遍历的结果就是排序的。
-
-中序遍历利用栈来实现。遍历时,前一个结点的 right 指向后一个结点,后一个结点的 left 指向前一个结点。
-```java
-pre.right = cur
-cur.left = pre
-```
-
-```java
-import java.util.Stack;
-
-/**
- * @author bingo
- * @since 2018/11/24
- */
-
-/**
- public class TreeNode {
- int val = 0;
- TreeNode left = null;
- TreeNode right = null;
-
- public TreeNode(int val) {
- this.val = val;
-
- }
-
- }
- */
-public class Solution {
- /**
- * 将二叉搜索树转换为双向链表
- *
- * @param pRootOfTree
- * @return
- */
- public TreeNode Convert(TreeNode pRootOfTree) {
- if (pRootOfTree == null) {
- return null;
- }
- Stack stack = new Stack<>();
- TreeNode cur = pRootOfTree;
- TreeNode res = null;
- TreeNode pre = null;
- while (cur != null || !stack.isEmpty()) {
- if (cur != null) {
- stack.push(cur);
- cur = cur.left;
- } else {
- cur = stack.pop();
- if (pre == null) {
- pre = cur;
- res = pre;
- } else {
- pre.right = cur;
- cur.left = pre;
- pre = cur;
- }
- cur = cur.right;
-
- }
- }
- return res;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的二叉树是完全二叉树;所有结点都没有左/右子树;只有一个结点的二叉树);
-2. 特殊输入测试(指向二叉树根结点的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/37_SerializeBinaryTrees.md b/docs/jianzhioffer/java/37_SerializeBinaryTrees.md
deleted file mode 100644
index e9795c2f3..000000000
--- a/docs/jianzhioffer/java/37_SerializeBinaryTrees.md
+++ /dev/null
@@ -1,89 +0,0 @@
-## 序列化二叉树
-
-### 题目描述
-请实现两个函数,分别用来序列化和反序列化二叉树。使用前序遍历实现,空节点使用字符`#` 表示。
-
-比如有如下二叉树:
-
-```java
- 1
- 2 3
- 4 # 5 6
- # # # # # #
-```
-
-序列化的结果为 `1,2,4,#,#,#,3,5,#,#,6,#,#`
-
-反序列化的结果为上述二叉树
-
-### 解法
-使用前序遍历进行序列化和反序列化。对格式没有要求,只要序列化得到的结果,再反序列化后能与原树相同即可。
-```java
-/**
- * @author mcrwayfun
- * @version 1.0
- * @description
- * @date Created in 2019/1/12
- */
-public class Solution {
-
-
- public String Serialize(TreeNode root) {
-
- StringBuilder res = new StringBuilder();
- if (root == null) {
- return res.toString();
- }
-
- serializeHelper(root, res);
- // 移除最后一个的符号","
- res.deleteCharAt(res.lastIndexOf(","));
- return res.toString();
- }
-
- private void serializeHelper(TreeNode root, StringBuilder res) {
-
- if (root == null) {
- res.append("#");
- res.append(",");
- return;
- }
-
- res.append(root.val);
- res.append(",");
- serializeHelper(root.left, res);
- serializeHelper(root.right, res);
- }
-
- private int index = -1;
-
- public TreeNode Deserialize(String str) {
-
- if (str == null || str.length() == 0) {
- return null;
- }
-
- String[] treeNodeStr = str.split(",");
- return deserializeHelper(treeNodeStr);
- }
-
- private TreeNode deserializeHelper(String[] treeNodeStr) {
-
- index++;
- TreeNode node = null;
-
- // index不越界并且当前节点不为#
- if (index < treeNodeStr.length && !"#".equals(treeNodeStr[index])) {
- node = new TreeNode(Integer.valueOf(treeNodeStr[index]));
- node.left = deserializeHelper(treeNodeStr);
- node.right = deserializeHelper(treeNodeStr);
- }
-
- return node;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的二叉树是完全二叉树;所有节点都没有左/右子树的二叉树;只有一个节点的二叉树;所有节点的值都相同的二叉树);
-2. 特殊输入测试(指向二叉树根结点的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/38_StringPermutation.md b/docs/jianzhioffer/java/38_StringPermutation.md
deleted file mode 100644
index b603cb511..000000000
--- a/docs/jianzhioffer/java/38_StringPermutation.md
+++ /dev/null
@@ -1,74 +0,0 @@
-## 字符串的排列
-
-### 题目描述
-输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。(输入一个字符串,长度不超过9(可能有字符重复),字符只包括大小写字母)。ps:牛客上的测试用例对返回的list要排序。
-
-### 解法
-对整个字符串的排列可以看成两部分。第一步求所有可能出现在第一个位置的字符,即把第一个字符与后面所有非重复的字符进行交换。第二步固定第一个字符,求后面所有字符的排列;第二步中后面的所有字符又可以看成一个完整的字符,继续执行这两个步骤。
-
-注意存在重复值得情况,比如输入字符串bab,将首字符b作为固定字符串,对于将第2个下标的b换到首位仍然是bab,所有这种情况无需输出。
-
-**这道题的时间复杂度应该为O(n!)**
-
-```java
-/**
- * @author mcrwayfun
- * @version 1.0
- * @description
- * @date Created in 2019/1/14
- */
-public class Solution {
-
- public ArrayList Permutation(String str) {
-
- ArrayList reList = new ArrayList<>();
-
- if (str == null || str.length() == 0) {
- return reList;
- }
-
- char[] chars = str.toCharArray();
-
- // 递归输出字符串排列
- permutationHelper(chars, 0, reList);
- Collections.sort(reList);
- return reList;
- }
-
- private void permutationHelper(char[] chars, int index, ArrayList list) {
-
- if (index == chars.length - 1) {
- list.add(new String(chars));
- return;
- }
-
- Set set = new HashSet<>();
- // 确定交换的字符,包括自己[index,length-1]
- for (int i = index; i < chars.length; i++) {
-
- // 排除出现重复字符
- // hash表,查询花费O(1)
- if (!set.contains(chars[i])) {
- set.add(chars[i]);
- // 固定字符index
- swap(chars, i, index);
- // 递归固定剩余字符[index+1,length-1]
- permutationHelper(chars, index + 1, list);
- // 恢复原数组
- swap(chars, index, i);
- }
- }
- }
-
- private void swap(char[] chars, int x, int y) {
-
- char temp = chars[x];
- chars[x] = chars[y];
- chars[y] = temp;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的字符串有一个或多个字符);
-2. 特殊输入测试(输入的字符串为nullptr指针或者内容为空)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/39_MoreThanHalfNumber.md b/docs/jianzhioffer/java/39_MoreThanHalfNumber.md
deleted file mode 100644
index a256e5abe..000000000
--- a/docs/jianzhioffer/java/39_MoreThanHalfNumber.md
+++ /dev/null
@@ -1,162 +0,0 @@
-## 数组中出现次数超过一半的数字
-
-### 题目描述
-数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为 9 的数组 `{1,2,3,2,2,2,5,4,2}`。由于数字 2 在数组中出现了 5 次,超过数组长度的一半,因此输出 2。如果不存在则输出 0。
-
-### 解法
-#### 解法一
-利用快排中的 partition 思想。
-
-数组中有一个数字出现次数超过了数组长度的一半,那么排序后,数组中间的数字一定就是我们要找的数字。我们随机选一个数字,利用 partition() 函数,使得比选中数字小的数字都排在它左边,比选中数字大的数字都排在它的右边。
-
-判断选中数字的下标 `index`:
-
-- 如果 `index = n/2`,那么这个数字就是中位数。
-- 如果 `index > n/2`,那么接着在 index 的左边进行 partition。
-- 如果 `index < n/2`,则在 index 的右边继续进行 partition。
-
-**注意:**这种方法会修改输入的数组。时间复杂度为 `O(n)`。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/6
- */
-
-public class Solution {
- /**
- * 查找数组中出现次数超过一次的数字
- *
- * @param array 数组
- * @return 返回该数,不存在则返回0
- */
- public int MoreThanHalfNum_Solution(int[] array) {
- if (array == null || array.length == 0) {
- return 0;
- }
- int n = array.length;
- int start = 0, end = n - 1;
- int mid = n >> 1;
- int index = partition(array, start, end);
- while (index != mid) {
- if (index > mid) {
- end = index - 1;
- } else {
- start = index + 1;
- }
- index = partition(array, start, end);
- }
-
- return isMoreThanHalf(array, array[index]) ? array[index] : 0;
- }
-
- /**
- * 快排中的 partition 方法
- *
- * @param array 数组
- * @param start 开始位置
- * @param end 结束位置
- * @return
- */
- private int partition(int[] array, int start, int end) {
- int small = start - 1;
- for (int i = start; i < end; ++i) {
- if (array[i] < array[end]) {
- swap(array, i, ++small);
- }
- }
- ++small;
- swap(array, small, end);
- return small;
-
- }
-
- private void swap(int[] array, int i, int j) {
- int t = array[i];
- array[i] = array[j];
- array[j] = t;
- }
-
- /**
- * 判断val元素是否真的超过数组元素个数的一半
- *
- * @param array 数组
- * @param val 某元素
- * @return boolean
- */
- private boolean isMoreThanHalf(int[] array, int val) {
- int cnt = 0;
- for (int e : array) {
- if (e == val) {
- ++cnt;
- }
- }
-
- return cnt * 2 > array.length;
- }
-}
-```
-
-#### 解法二
-利用多数投票算法,从头到尾遍历数组,遇到两个不一样的数就把这两个数同时除去。除去的两个数可能都不是 majority,也可能一个是 majority 另一个不是,但是因为 majority 总数大于一半,所以这么删完最后剩下的肯定是 majority。
-
-此方法时间复杂度为 `O(n)`,且不会改变数组。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/6
- */
-
-public class Solution {
- /**
- * 查找数组中出现次数超过一次的数字
- *
- * @param array 数组
- * @return 返回该数,不存在则返回0
- */
- public int MoreThanHalfNum_Solution(int[] array) {
- if (array == null || array.length == 0) {
- return 0;
- }
-
- int res = array[0];
- int times = 1;
- for (int i = 1; i < array.length; ++i) {
- if (times == 0) {
- res = array[i];
- times = 1;
- } else if (array[i] == res) {
- ++times;
- } else {
- --times;
- }
- }
-
- return isMoreThanHalf(array, res) ? res : 0;
- }
-
-
- /**
- * 判断val元素是否真的超过数组元素个数的一半
- *
- * @param array 数组
- * @param val 某元素
- * @return boolean
- */
- private boolean isMoreThanHalf(int[] array, int val) {
- int cnt = 0;
- for (int e : array) {
- if (e == val) {
- ++cnt;
- }
- }
-
- return cnt * 2 > array.length;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的数组中存在/不存在一个出现次数超过数组长度一半的数字);
-2. 特殊输入测试(输入的数组只有一个数字;输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/40_KLeastNumbers.md b/docs/jianzhioffer/java/40_KLeastNumbers.md
deleted file mode 100644
index 645478a08..000000000
--- a/docs/jianzhioffer/java/40_KLeastNumbers.md
+++ /dev/null
@@ -1,132 +0,0 @@
-## 获取数组中最小的k个数
-
-### 题目描述
-输入 n 个整数,找出其中最小的 K 个数。例如输入 `4,5,1,6,2,7,3,8` 这 8 个数字,则最小的 4 个数字是 `1,2,3,4`。
-
-### 解法
-#### 解法一
-利用快排中的 partition 思想。
-
-数组中有一个数字出现次数超过了数组长度的一半,那么排序后,数组中间的数字一定就是我们要找的数字。我们随机选一个数字,利用 partition() 函数,使得比选中数字小的数字都排在它左边,比选中数字大的数字都排在它的右边。
-
-判断选中数字的下标 `index`:
-
-- 如果 `index = k-1`,结束循环,返回前 k 个数。
-- 如果 `index > k-1`,那么接着在 index 的左边进行 partition。
-- 如果 `index < k-1`,则在 index 的右边继续进行 partition。
-
-**注意**,这种方法会修改输入的数组。时间复杂度为 `O(n)`。
-
-```java
-import java.util.ArrayList;
-
-/**
- * @author bingo
- * @since 2018/12/6
- */
-
-public class Solution {
-
- /**
- * 获取数组中最小的k个数
- *
- * @param input 输入的数组
- * @param k 元素个数
- * @return 最小的k的数列表
- */
- public ArrayList GetLeastNumbers_Solution(int[] input, int k) {
- ArrayList res = new ArrayList<>();
- if (input == null || input.length == 0 || input.length < k || k < 1) {
- return res;
- }
- int n = input.length;
- int start = 0, end = n - 1;
- int index = partition(input, start, end);
- while (index != k - 1) {
- if (index > k - 1) {
- end = index - 1;
- } else {
- start = index + 1;
- }
- index = partition(input, start, end);
- }
- for (int i = 0; i < k; ++i) {
- res.add(input[i]);
- }
- return res;
- }
-
- private int partition(int[] input, int start, int end) {
- int index = start - 1;
- for (int i = start; i < end; ++i) {
- if (input[i] < input[end]) {
- swap(input, i, ++index);
- }
- }
- ++index;
- swap(input, index, end);
- return index;
- }
-
- private void swap(int[] array, int i, int j) {
- int t = array[i];
- array[i] = array[j];
- array[j] = t;
- }
-}
-```
-
-#### 解法二
-利用大根堆,存储最小的 k 个数,最后返回即可。
-
-此方法时间复杂度为 `O(nlogk)`。虽然慢一点,但是它不会改变输入的数组,并且它**适合海量数据的输入**。
-
-假设题目要求从海量的数据中找出最小的 k 个数,由于内存的大小是有限的,有可能不能把这些海量的数据一次性全部载入内存。这个时候,用这种方法是最合适的。就是说它适合 n 很大并且 k 较小的问题。
-
-```java
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.PriorityQueue;
-
-/**
- * @author bingo
- * @since 2018/12/6
- */
-
-public class Solution {
-
- /**
- * 获取数组中最小的k个数
- *
- * @param input 输入的数组
- * @param k 元素个数
- * @return 最小的k的数列表
- */
- public ArrayList GetLeastNumbers_Solution(int[] input, int k) {
- ArrayList res = new ArrayList<>();
- if (input == null || input.length == 0 || input.length < k || k < 1) {
- return res;
- }
-
- PriorityQueue maxHeap = new PriorityQueue<>(k, Comparator.reverseOrder());
- System.out.println(maxHeap.size());
- for (int e : input) {
- if (maxHeap.size() < k) {
- maxHeap.add(e);
- } else {
- if (maxHeap.peek() > e) {
- maxHeap.poll();
- maxHeap.add(e);
- }
-
- }
- }
- res.addAll(maxHeap);
- return res;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的数组中存在/不存在一个出现次数超过数组长度一半的数字);
-2. 特殊输入测试(输入的数组只有一个数字;输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/41_StreamMedian.md b/docs/jianzhioffer/java/41_StreamMedian.md
deleted file mode 100644
index f3e3ce8ed..000000000
--- a/docs/jianzhioffer/java/41_StreamMedian.md
+++ /dev/null
@@ -1,67 +0,0 @@
-## 数据流中的中位数
-
-### 题目描述
-如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个数的平均值。我们使用`Insert()`方法读取数据流,使用`GetMedian()`方法获取当前读取数据的中位数。
-
-### 解法
-利用大根堆存放较小的一半元素,小根堆存放较大的一半元素。维持大小堆的元素个数差不超过 1。
-
-
-```java
-import java.util.Comparator;
-import java.util.PriorityQueue;
-
-/**
- * @author bingo
- * @since 2018/12/7
- */
-
-public class Solution {
-
- private PriorityQueue minHeap = new PriorityQueue<>();
- private PriorityQueue maxHeap = new PriorityQueue<>(Comparator.reverseOrder());
-
- /**
- * 插入一个数
- *
- * @param num 数
- */
- public void Insert(Integer num) {
-
- if (maxHeap.isEmpty() || num < maxHeap.peek()) {
- maxHeap.offer(num);
- if (maxHeap.size() - minHeap.size() > 1) {
- minHeap.offer(maxHeap.poll());
- }
-
- } else {
- minHeap.offer(num);
- if (minHeap.size() - maxHeap.size() > 1) {
- maxHeap.offer(minHeap.poll());
- }
- }
- }
-
- /**
- * 获取中位数
- *
- * @return 中位数
- */
- public Double GetMedian() {
- int size1 = maxHeap.size();
- int size2 = minHeap.size();
- if (size1 > size2) {
- return (double) maxHeap.peek();
- }
- if (size1 < size2) {
- return (double) minHeap.peek();
- }
-
- return (maxHeap.peek() + minHeap.peek()) / 2.0;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(从数据流中读出奇数/偶数个数字);
-2. 边界值测试(从数据流中读出 0/1/2 个数字)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/42_GreatestSumOfSubarrays.md b/docs/jianzhioffer/java/42_GreatestSumOfSubarrays.md
deleted file mode 100644
index e5a2d99c6..000000000
--- a/docs/jianzhioffer/java/42_GreatestSumOfSubarrays.md
+++ /dev/null
@@ -1,49 +0,0 @@
-## 连续子数组的最大和
-
-### 题目描述
-输入一个**非空**整型数组,数组里的数可能为正,也可能为负。
-数组中一个或连续的多个整数组成一个子数组。求所有子数组的和的最大值。
-
-要求时间复杂度为`O(n)`。
-
-### 解法
-动态规划法。
-
-res[i] 表示以第 i 个数字结尾的子数组的最大和,那么求出 `max(res[i])` 即可。
-
-- `res[i] = array[i]`, if `res[i - 1] < 0`
-- `res[i] = res[i - 1] + array[i]`, if `res[i - 1] >= 0`
-
-```java
-
-/**
- * @author bingo
- * @since 2018/12/7
- */
-
-public class Solution {
- /**
- * 求连续子数组的最大和
- *
- * @param array 数组
- * @return 最大和
- */
- public int FindGreatestSumOfSubArray(int[] array) {
- int n = array.length;
- int[] res = new int[n];
- res[0] = array[0];
- int max = res[0];
- for (int i = 1; i < n; ++i) {
- res[i] = res[i - 1] > 0 ? res[i - 1] + array[i] : array[i];
- max = Math.max(max, res[i]);
- }
- return max;
- }
-}
-
-
-```
-
-### 测试用例
-1. 功能测试(输入的数组中有正数也有负数;输入的数组中全是正数;输入的数组中全是负数);
-2. 特殊输入测试(表示数组的指针位为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/43_NumberOf1.md b/docs/jianzhioffer/java/43_NumberOf1.md
deleted file mode 100644
index 27352aafc..000000000
--- a/docs/jianzhioffer/java/43_NumberOf1.md
+++ /dev/null
@@ -1,66 +0,0 @@
-## 整数中1出现的次数
-
-### 题目描述
-求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现6次,但是对于后面问题他就没辙了。ACMer希望你们帮帮他,并把问题更加普遍化,可以很快的求出任意非负整数区间中1出现的次数(从1 到 n 中1出现的次数)。
-
-### 解法
-- 编程之美上给出的规律:
-
- 1. 如果第i位(自右至左,从1开始标号)上的数字为0,则第i位可能出现1的次数由更高位决定(若没有高位,视高位为0),等于更高位数字X当前位数的权重10^(i-1)。
- 2. 如果第i位上的数字为1,则第i位上可能出现1的次数不仅受更高位影响,还受低位影响(若没有低位,视低位为0),等于更高位数字X当前位数的权重10^(i-1)+(低位数字+1)。
- 3. 如果第i位上的数字大于1,则第i位上可能出现1的次数仅由更高位决定(若没有高位,视高位为0),等于(更高位数字+1)X当前位数的权重10^(i-1)。
-
- 总结一下以上的算法,可以看到,当计算右数第 i 位包含的 X 的个数时:
-
- 1. 取第 i 位左边(高位)的数字,乘以 10i−1,得到**基础值** a。
- 2. 取第 i 位数字,计算**修正值**:
- 1. 如果大于 X,则结果为 a+10i−1。
- 2. 如果小于 X,则结果为 a。
- 3. 如果等 X,则取第 i 位右边(低位)数字,设为 b,最后结果为 a+b+1。
-
- 相应的代码非常简单,效率也非常高,时间复杂度只有 O(logn)。
-
-```java
-
-/**
- * @author mcrwayfun
- * @version 1.0
- * @description
- * @date Created in 2019/1/17
- */
-public class Solution {
-
- public int NumberOf1Between1AndN_Solution(int n) {
-
- if (n < 1) {
- return 0;
- }
-
- int high, low, curr, tmp, i = 1;
- high = n;
- int number = 0;
- while (high != 0) {
- // 获取第i位的高位
- high = n / (int) Math.pow(10, i);
- tmp = n % (int) Math.pow(10, i);
- // 获取第i位
- curr = tmp / (int) Math.pow(10, i - 1);
- // 获取第i位的低位
- low = tmp % (int) Math.pow(10, i - 1);
- if (curr == 1) {
- number += high * (int) Math.pow(10, i - 1) + low + 1;
- } else if (curr < 1) {
- number += high * (int) Math.pow(10, i - 1);
- } else {
- number += (high + 1) * (int) Math.pow(10, i - 1);
- }
- i++;
- }
- return number;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入1~n的数字);
-2. 特殊输入测试(输入的数字小于0)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/44_DigitsInSequence.md b/docs/jianzhioffer/java/44_DigitsInSequence.md
deleted file mode 100644
index 427f37445..000000000
--- a/docs/jianzhioffer/java/44_DigitsInSequence.md
+++ /dev/null
@@ -1,71 +0,0 @@
-## 数字序列中某一位的数字
-
-### 题目描述
-数字以 `0123456789101112131415…` 的格式序列化到一个字符序列中。
-
-在这个序列中,第 5 位(从 0 开始计数)是 5,第 13 位是 1,第 19 位是 4,等等。
-
-请写一个函数求任意位对应的数字。
-
-### 解法
-举个栗子,求序列第 1001 位。
-
-序列的前 10 位是 `0~9`, 这 10 个只有一位的数字。显然第 1001 位在这 10 个数字之后,因此这 10 个数字可以直接跳过。再从后面序列中找第 991(991=1001-10) 位的数字。接下来有 90 个两位数,共 180 位,由于 991>180,所以继续跳过。从 881 找...最后可以找到对应的数字以及数字的某一位。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/7
- */
-
-public class Solution {
- /**
- * 求数字序列中某一位的数字
- *
- * @param n 第n位
- * @return 第n位的数字
- */
- public int digitAtIndex(int n) {
- if (n < 0) {
- return -1;
- }
- int digits = 1;
- while (true) {
- long numbers = countOfIntegers(digits);
- if (n < digits * numbers) {
- break;
- }
- n -= numbers * digits;
- ++digits;
- }
- return digitAtIndex(digits, n);
-
- }
-
- private long countOfIntegers(int digits) {
- return digits == 1
- ? 10
- : (int) (9 * Math.pow(10, digits - 1));
- }
-
- private int digitAtIndex(int digits, int n) {
- int beginNumber = getBeginNumber(digits);
- int val = beginNumber + n / digits;
- int indexFromRight = digits - n % digits;
- for (int i = 1; i < indexFromRight; ++i) {
- val /= 10;
- }
- return val % 10;
- }
-
- private int getBeginNumber(int digits) {
- return digits == 1
- ? 0
- : (int) Math.pow(10, digits - 1);
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入 10、190、1000);
-2. 边界值测试(输入 0、1)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/45_SortArrayForMinNumber.md b/docs/jianzhioffer/java/45_SortArrayForMinNumber.md
deleted file mode 100644
index b563cb46e..000000000
--- a/docs/jianzhioffer/java/45_SortArrayForMinNumber.md
+++ /dev/null
@@ -1,50 +0,0 @@
-## 把数组排成最小的数
-
-### 题目描述
-输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。
-
-例如输入数组 `[3, 32, 321]`,则打印出这3个数字能排成的最小数字`321323`。
-
-### 解法
-
-
-```java
-import java.util.Arrays;
-
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-class Solution {
-
- /**
- * 打印数组元素组成的最小的数字
- *
- * @param nums 数组
- * @return 最小的数字
- */
- public String printMinNumber(int[] nums) {
- if (nums == null || nums.length == 0) {
- return "";
- }
- int n = nums.length;
- String[] strNums = new String[n];
- for (int i = 0; i < n; ++i) {
- strNums[i] = String.valueOf(nums[i]);
- }
-
- Arrays.sort(strNums, (o1, o2) -> (o1 + o2).compareTo(o2 + o1));
-
- StringBuilder sb = new StringBuilder();
- for (String str : strNums) {
- sb.append(str);
- }
- return sb.toString();
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的数组中有多个数字;输入的数组中的数字有重复的数位;输入的数组中只有一个数字);
-2. 特殊输入测试(表示数组的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/46_TranslateNumbersToStrings.md b/docs/jianzhioffer/java/46_TranslateNumbersToStrings.md
deleted file mode 100644
index 759b1f9c3..000000000
--- a/docs/jianzhioffer/java/46_TranslateNumbersToStrings.md
+++ /dev/null
@@ -1,56 +0,0 @@
-## 把数字翻译成字符串
-
-### 题目描述
-给定一个数字,我们按照如下规则把它翻译为字符串:
-
-0 翻译成 ”a”,1 翻译成 ”b”,……,11 翻译成 ”l”,……,25 翻译成 ”z”。
-
-一个数字可能有多个翻译。例如 12258 有 5 种不同的翻译,它们分别是 ”bccfi”、”bwfi”、”bczi”、”mcfi”和”mzi”。
-
-请编程实现一个函数用来计算一个数字有多少种不同的翻译方法。
-
-### 解法
-先写入递推式,res 表示共有多少种翻译方法。看最后一个字符,判断它与前一个字符能否构成有效翻译,计算 res[i]:
-
-- 能,那么 `res[i] = res[i - 1] + res[i - 2]`;
-- 不能,那么 `res[i] = res[i - 1]`。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-class Solution {
- /**
- * 获取翻译字符串的方法个数
- *
- * @param s 字符串
- * @return 个数
- */
- public int getTranslationCount(String s) {
- if (s == null || s.length() < 2) {
- return 1;
- }
- char[] chars = s.toCharArray();
- int n = chars.length;
- int[] res = new int[n];
- res[0] = 1;
- res[1] = isInRange(chars[0], chars[1]) ? 2 : 1;
- for (int i = 2; i < n; ++i) {
- res[i] = res[i - 1] + (isInRange(chars[i - 1], chars[i]) ? res[i - 2] : 0);
- }
- return res[n - 1];
- }
-
- private boolean isInRange(char a, char b) {
- int s = (a - '0') * 10 + (b -'0');
- return s >= 10 && s <= 25;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(只有一位数字;包含多位数字);
-2. 特殊输入测试(负数;0;包含 25、26 的数字)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/47_MaxValueOfGifts.md b/docs/jianzhioffer/java/47_MaxValueOfGifts.md
deleted file mode 100644
index 8af6ff5b2..000000000
--- a/docs/jianzhioffer/java/47_MaxValueOfGifts.md
+++ /dev/null
@@ -1,57 +0,0 @@
-## 礼物的最大价值
-
-### 题目描述
-在一个 `m×n` 的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于 0)。
-
-你可以从棋盘的左上角开始拿格子里的礼物,并每次向左或者向下移动一格直到到达棋盘的右下角。
-
-给定一个棋盘及其上面的礼物,请计算你最多能拿到多少价值的礼物?
-
-### 解法
-写出递推式,res 表示获得的最大礼物。
-
-```java
-res[i][j] = Math.max(res[i - 1][j], res[i][j - 1]) + grid[i][j];
-```
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-class Solution {
- /**
- * 获取礼物的最大价值
- *
- * @param grid 数组
- * @return 最大价值
- */
- public int getMaxValue(int[][] grid) {
- if (grid == null || grid.length == 0) {
- return 0;
- }
- int m = grid.length;
- int n = grid[0].length;
- int[][] res = new int[m][n];
- res[0][0] = grid[0][0];
- for (int j = 1; j < n; ++j) {
- res[0][j] = res[0][j - 1] + grid[0][j];
- }
- for (int i = 1; i < m; ++i) {
- res[i][0] = res[i - 1][0] + grid[i][0];
- }
- for (int i = 1; i < m; ++i) {
- for (int j = 1; j < n; ++j) {
- res[i][j] = Math.max(res[i - 1][j], res[i][j - 1]) + grid[i][j];
- }
- }
- return res[m - 1][n - 1];
- }
-}
-```
-
-### 测试用例
-1. 功能测试(多行多列的矩阵;一行或者一列的矩阵;只有一个数字的矩阵);
-2. 特殊输入测试(指向矩阵数组的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/48_LongestSubstringWithoutDup.md b/docs/jianzhioffer/java/48_LongestSubstringWithoutDup.md
deleted file mode 100644
index 0012f287b..000000000
--- a/docs/jianzhioffer/java/48_LongestSubstringWithoutDup.md
+++ /dev/null
@@ -1,63 +0,0 @@
-## 最长不含重复字符的子字符串
-
-### 题目描述
-请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。
-
-假设字符串中只包含从 `a` 到 `z`的字符。
-
-### 解法
-动态规划。
-
-`res[i]` 表示以 `s[i]` 字符结尾的最长不重复字符串的长度。判断 `s[i]`:
-- 若 `s[i]` 在前面没出现过,那么 `res[i] = res[i - 1] + 1`;
-- 若 `s[i]` 在前面有出现过,判断它上一次出现的位置 `index` 到 `i` 的距离 `d` 与 `res[i - 1]` 的大小关系:
- - 若 `d <= res[i - 1]`,说明它被包含在 `res[i - 1]` 构成的子串中,那么 `res[i] = d`;
- - 若 `d > res[i - 1]`,说明它在 `res[i - 1]` 构成的子串的左侧,那么 `res[i] = res[i - 1] + 1`。
-
-需要用一个数组 t 记录一下当前出现的字符在哪个位置。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-class Solution {
- /**
- * 最长不含重复字符的子字符串
- *
- * @param s 字符串
- * @return 最长不重复字符子串
- */
- public int longestSubstringWithoutDuplication(String s) {
- if (s == null || s.length() == 0) {
- return 0;
- }
- char[] chars = s.toCharArray();
- int[] t = new int[26];
- for (int i = 0; i < 26; ++i) {
- t[i] = -1;
- }
- t[chars[0] - 'a'] = 0;
- int n = chars.length;
- int[] res = new int[n];
- res[0] = 1;
- int max = res[0];
- for (int i = 1; i < n; ++i) {
- int index = t[chars[i] - 'a'];
- int d = i - index;
- res[i] = (index == -1 || d > res[i - 1])
- ? res[i - 1] + 1
- : d;
-
- t[chars[i] - 'a'] = i;
- max = Math.max(max, res[i]);
- }
- return max;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(包含多个字符的字符串;只有一个字符的字符串;所有字符都唯一的字符串;所有字符都相同的字符串);
-2. 特殊输入测试(空字符串)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/49_UglyNumber.md b/docs/jianzhioffer/java/49_UglyNumber.md
deleted file mode 100644
index bec37fd34..000000000
--- a/docs/jianzhioffer/java/49_UglyNumber.md
+++ /dev/null
@@ -1,106 +0,0 @@
-## 丑数
-
-### 题目描述
-把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。
-
-### 解法1
-由题目可以得知,丑数必定可以整除2、3或者5(除了丑数1之外),也就是说,如果一个数能够被2整除,就连续除以2;能够被3整除,就连续除以3;能够被5整除,就连续除以5;如果最后得到1,那么这个数便是丑数。因此我们可以使用暴力的方式遍历到第N个丑数。
-
-该解法的time complexity为O(count),比如第1500个丑数为859963392,那么就需要枚举1到859963392
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/01/23
- * @description
- */
-public class Solution {
-
- private boolean isUgly(int number){
- if(number % 2 == 0)
- number /= 2;
- if(number % 3 == 0)
- number /= 3;
- if(number % 5 == 0)
- number /= 5;
- return number == 1;
- }
-
- public int GetUglyNumber_Solution(int index){
- if(index <= 0)
- return 0;
-
- int number = 0;
- int count = 0;
- while(count < index){
- number++;
- if(isUgly(number)){
- count++;
- }
- }
-
- return number;
- }
-}
-```
-
-### 解法2
-
-把15以内的丑数列出来:`1、2、3、4、5、6、8、9、10、12、15` ,你会发现新丑数必定是旧丑数乘以因子2、3或者5得来的。所以可以使用一个list来存储已经出现的丑数以此来计算出新的丑数,从而避免对非丑数的计算。
-
-通过维护3个下标i2,i3,i5和它们对应的值m2,m3,m5,每次向list中添加的为m2,m3,m5中的最小值,以此来维护list的有序性。
-
-该解法的time complexity为O(n),space complexity为O(n),属于典型的用空间换时间的解决方法。
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/01/23
- * @description
- */
-public class Solution {
-
- public int GetUglyNumber_Solution(int index) {
-
- if (index <= 0)
- return 0;
-
- List reList = new ArrayList<>();
- // 第一个丑数为1
- reList.add(1);
- int i2 = 0, i3 = 0, i5 = 0;
- while (reList.size() < index) {
-
- int m2 = reList.get(i2) * 2;
- int m3 = reList.get(i3) * 3;
- int m5 = reList.get(i5) * 5;
-
- // 求出m2、m3、m5中的最小值,该值为加入list的丑数
- int min = Math.min(m2, Math.min(m3, m5));
-
- if (m2 == min) {
- i2++;
- }
- if (m3 == min) {
- i3++;
- }
- if (m5 == min) {
- i5++;
- }
-
- reList.add(min);
- }
-
- // O(1)
- return reList.get(reList.size() - 1);
- }
-}
-```
-
-### 测试用例
-
-1. 功能测试(输入2、3、4、5、6等)。
-2. 特殊输入测试(边界值1;无效输入0)。
-3. 性能测试(输入较大的数字,比如1500)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/50_01_FirstNotRepeatingChar.md b/docs/jianzhioffer/java/50_01_FirstNotRepeatingChar.md
deleted file mode 100644
index ebf2baeb5..000000000
--- a/docs/jianzhioffer/java/50_01_FirstNotRepeatingChar.md
+++ /dev/null
@@ -1,43 +0,0 @@
-## 第一个只出现一次的字符
-
-### 题目描述
-在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写).
-
-### 解法1
-使用HashMap来统计字符出现的次数,因为字符的多少是固定的(大小写字母一共52个),所以可以认为使用HashMap的空间复杂度为O(1)。该解法时间复杂度为O(n)。
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/01/24
- * @description
- */
-public class Solution {
-
- public int FirstNotRepeatingChar(String str) {
-
- if (str == null || str.length() == 0) {
- return -1;
- }
-
- Map characterMap = new HashMap<>();
- // hashMap is HashTable,search cost O(1)
- for (int i = 0; i < str.length(); i++) {
- characterMap.put(str.charAt(i), characterMap.getOrDefault(str.charAt(i), 0) + 1);
- }
-
- for (int i = 0; i < str.length(); i++) {
- if (characterMap.get(str.charAt(i)) == 1) {
- return i;
- }
- }
-
- return -1;
- }
-}
-```
-### 测试用例
-
-1. 功能测试(字符串中仅存在只出现一次的字符;字符串中不存在只出现一次的字符;字符串中所有字符都只出现一次)。
-2. 特殊输入测试(字符串为null)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/50_02_FristCharacterInStream.md b/docs/jianzhioffer/java/50_02_FristCharacterInStream.md
deleted file mode 100644
index 2d67dbcca..000000000
--- a/docs/jianzhioffer/java/50_02_FristCharacterInStream.md
+++ /dev/null
@@ -1,45 +0,0 @@
-## 字符流中第一个不重复的字符
-
-### 题目描述
-
-请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。如果当前字符流没有存在出现一次的字符,返回#字符。
-
-
-### 解法1
-与上一道题的思路是一致的。
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/01/25
- * @description
- */
-public class Solution {
-
- private StringBuilder res = new StringBuilder();
- private Map characterMap = new HashMap<>();
-
- // Insert one char from stringstream
- public void Insert(char ch) {
- res.append(ch);
- characterMap.put(ch, characterMap.getOrDefault(ch, 0) + 1);
- }
-
- // return the first appearence once char in current stringstream
- public char FirstAppearingOnce() {
-
- for (char c : res.toString().toCharArray()) {
- if (characterMap.get(c) == 1) {
- return c;
- }
- }
-
- return '#';
- }
-}
-```
-### 测试用例
-
-1. 功能测试(读入一个字符;读入多个字符;读入的所有字符都是唯一的;读入的所有字符都是重复出现的)。
-2. 特殊输入测试(读入0个字符)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/52_FirstCommonNodesInLists.md b/docs/jianzhioffer/java/52_FirstCommonNodesInLists.md
deleted file mode 100644
index 78fe0068b..000000000
--- a/docs/jianzhioffer/java/52_FirstCommonNodesInLists.md
+++ /dev/null
@@ -1,86 +0,0 @@
-## 两个链表的第一个公共结点
-
-### 题目描述
-输入两个链表,找出它们的第一个公共结点。
-
-**样例**
-```
-给出两个链表如下所示:
-A: a1 → a2
- ↘
- c1 → c2 → c3
- ↗
-B: b1 → b2 → b3
-
-输出第一个公共节点c1
-```
-
-### 解法
-先遍历两链表,求出两链表的长度,再求长度差 `|n1 - n2|`。
-
-较长的链表先走 `|n1 - n2|` 步,之后两链表再同时走,首次相遇时的节点即为两链表的第一个公共节点。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-/**
- * Definition for singly-linked list.
- * public class ListNode {
- * int val;
- * ListNode next;
- * ListNode(int x) {
- * val = x;
- * next = null;
- * }
- * }
- */
-class Solution {
-
- /**
- * 求两链表第一个公共节点
- *
- * @param headA 链表A
- * @param headB 链表B
- * @return 第一个公共节点
- */
- public ListNode findFirstCommonNode(ListNode headA, ListNode headB) {
- if (headA == null || headB == null) {
- return null;
- }
- int n1 = len(headA), n2 = len(headB);
- ListNode p1 = headA, p2 = headB;
- if (n1 > n2) {
- for (int i = 0; i < n1 - n2; ++i) {
- p1 = p1.next;
- }
- } else if (n1 < n2) {
- for (int i = 0; i < n2 - n1; ++i) {
- p2 = p2.next;
- }
- }
- while (p1 != p2 && p1 != null && p2 != null) {
- p1 = p1.next;
- p2 = p2.next;
- }
- return (p1 == null || p2 == null) ? null : p1;
- }
-
- private int len(ListNode head) {
- int n = 0;
- ListNode cur = head;
- while (cur != null) {
- ++n;
- cur = cur.next;
- }
- return n;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入的两个链表有公共节点;第一个公共节点在链表的中间,第一个公共节点在链表的末尾,第一个公共节点是链表的头节点;输入的两个链表没有公共节点);
-2. 特殊输入测试(输入的链表头节点是空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/53_01_NumberOfK.md b/docs/jianzhioffer/java/53_01_NumberOfK.md
deleted file mode 100644
index 76cb7d228..000000000
--- a/docs/jianzhioffer/java/53_01_NumberOfK.md
+++ /dev/null
@@ -1,99 +0,0 @@
-## 数字在排序数组中出现的次数
-
-### 题目描述
-统计一个数字在排序数组中出现的次数。
-
-例如输入排序数组 `[1, 2, 3, 3, 3, 3, 4, 5]` 和数字 3,由于 3 在这个数组中出现了 4 次,因此输出 4。
-
-**样例**
-
-```
-输入:[1, 2, 3, 3, 3, 3, 4, 5] , 3
-
-输出:4
-```
-
-### 解法
-找出第一个 k 和最后一个 k 出现的位置。
-
-找第一个 k 时,利用二分法,如果 `nums[m] == k`,判断它的前一个位置是不是也是 k,如果不是,说明这是第一个 k,直接返回。如果是,那么递归在左边查找第一个 k。
-
-找最后一个 k 也同理。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-class Solution {
- /**
- * 求数字k在排序数组中出现的次数
- *
- * @param nums 数组
- * @param k 数字k
- * @return k在数组中出现的次数
- */
- public int getNumberOfK(int[] nums, int k) {
- if (nums == null || nums.length == 0) {
- return 0;
- }
- int start = 0, end = nums.length - 1;
- int first = getFirstK(nums, start, end, k);
- int last = getLastK(nums, start, end, k);
- if (first > -1 && last > -1) {
- return last - first + 1;
- }
- return 0;
- }
-
- private int getFirstK(int[] nums, int start, int end, int k) {
- if (start > end) {
- return -1;
- }
- int m = start + ((end - start) >> 1);
- if (nums[m] == k) {
- if (m == 0 || (m > 0 && nums[m - 1] != k)) {
- return m;
- } else {
- end = m - 1;
- }
- } else {
- if (nums[m] > k) {
- end = m - 1;
- } else {
- start = m + 1;
- }
- }
- return getFirstK(nums, start, end, k);
- }
-
- private int getLastK(int[] nums, int start, int end, int k) {
- if (start > end) {
- return -1;
- }
- int m = start + ((end - start) >> 1);
- if (nums[m] == k) {
- if (m == nums.length - 1 || (m < nums.length - 1 && nums[m + 1] != k)) {
- return m;
- } else {
- start = m + 1;
- }
- } else {
- if (nums[m] > k) {
- end = m - 1;
- } else {
- start = m + 1;
- }
- }
- return getLastK(nums, start, end, k);
-
- }
-}
-```
-
-### 测试用例
-1. 功能测试(数组中包含要查找的数字;数组中没有要查找的数字;要查找的数字在数组中出现一次/多次);
-2. 边界值测试(查找数组中的最大值、最小值;数组中只有一个数字);
-3. 特殊输入测试(表示数组的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/53_02_MissingNumber.md b/docs/jianzhioffer/java/53_02_MissingNumber.md
deleted file mode 100644
index ab3f8db5b..000000000
--- a/docs/jianzhioffer/java/53_02_MissingNumber.md
+++ /dev/null
@@ -1,62 +0,0 @@
-## 0到n-1中缺失的数字
-
-### 题目描述
-一个长度为 `n-1` 的递增排序数组中的所有数字都是唯一的,并且每个数字都在范围 `0` 到 `n-1` 之内。
-
-在范围 `0` 到 `n-1` 的 `n` 个数字中有且只有一个数字不在该数组中,请找出这个数字。
-
-**样例**
-```
-输入:[0,1,2,4]
-
-输出:3
-```
-
-### 解法
-找出第一个与下标不对应的数字即可。
-
-特殊情况:
-- 下标都对应,那么应该返回 `最后一个数+1`;
-- 缺失的数字是第一个,那么返回 0。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/8
- */
-
-class Solution {
- /**
- * 获取0~n-1缺失的数字
- *
- * @param nums 数组
- * @return 缺失的数字
- */
- public int getMissingNumber(int[] nums) {
- if (nums == null || nums.length == 0) {
- return 0;
- }
- int n = nums.length;
- int start = 0, end = n - 1;
- while (start <= end) {
- int mid = start + ((end - start) >> 1);
- if (nums[mid] != mid) {
- if (mid == 0 || nums[mid - 1] == mid - 1) {
- return mid;
- }
- end = mid - 1;
- } else {
- start = mid + 1;
- }
- }
- return start == n ? n : -1;
-
- }
-}
-```
-
-### 测试用例
-1. 功能测试(缺失的数字位于数组的开始、中间或者末尾);
-2. 边界值测试(数组中只有一个数字 0);
-3. 特殊输入测试(表示数组的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/53_03_IntegerIdenticalToIndex.md b/docs/jianzhioffer/java/53_03_IntegerIdenticalToIndex.md
deleted file mode 100644
index 6ea63a4a4..000000000
--- a/docs/jianzhioffer/java/53_03_IntegerIdenticalToIndex.md
+++ /dev/null
@@ -1,63 +0,0 @@
-## 数组中数值和下标相等的元素
-
-### 题目描述
-假设一个单调递增的数组里的每个元素都是整数并且是唯一的。
-
-请编程实现一个函数找出数组中任意一个数值等于其下标的元素。
-
-例如,在数组 `[-3, -1, 1, 3, 5]` 中,数字 3 和它的下标相等。
-
-**样例**
-```
-输入:[-3, -1, 1, 3, 5]
-
-输出:3
-```
-
-**注意**:如果不存在,则返回 -1。
-
-### 解法
-二分法查找。
-- 当前元素等于对应的下标,直接返回该下标;
-- 当前元素大于该下标,在左边查找;
-- 当前元素小于该下标,在右边查找。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/10
- */
-
-class Solution {
- /**
- * 找出单调递增数组中数值和下标相等的元素
- *
- * @param nums 数组
- * @return 数值与下标相等的元素
- */
- public int getNumberSameAsIndex(int[] nums) {
- if (nums == null || nums.length == 0) {
- return -1;
- }
- int start = 0, end = nums.length - 1;
- while (start <= end) {
- int mid = start + ((end - start) >> 1);
- if (nums[mid] == mid) {
- return mid;
- }
- if (nums[mid] < mid) {
- start = mid + 1;
- } else {
- end = mid - 1;
- }
- }
- return -1;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(数组中包含或者不包含数值和下标相等的元素);
-2. 边界值测试(数组中只有一个数字;数值和下标相等的元素位于数组的开头或者结尾);
-3. 特殊输入测试(表示数组的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/54_KthNodeInBST.md b/docs/jianzhioffer/java/54_KthNodeInBST.md
deleted file mode 100644
index be0bc7996..000000000
--- a/docs/jianzhioffer/java/54_KthNodeInBST.md
+++ /dev/null
@@ -1,54 +0,0 @@
-## 二叉搜索树的第k个结点
-
-### 题目描述
-给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4
-
-### 解法
-因为BST的中序遍历得到的是一个升序的列表,所以在进行中序遍历行进行判断即可。所以该算法的时间复杂度为O(logn)
-
-
-```java
-/**
- * @author mcrwayfun
- * @version 1.0
- * @description
- * @date Created in 2019/1/28
- */
-class Solution {
-
- private int count = 0;
-
- public TreeNode KthNode(TreeNode pRoot, int k) {
-
- if (pRoot == null || k == 0) {
- return null;
- }
-
- // 左递归
- TreeNode retNode = KthNode(pRoot.left, k);
-
- if (retNode != null) {
- return retNode;
- }
-
- // 符合条件则返回
- count++;
- if (count == k) {
- return pRoot;
- }
-
- // 右递归
- retNode = KthNode(pRoot.right, k);
- if (retNode != null) {
- return retNode;
- }
-
- return null;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(各种形态不同的二叉搜索树);
-2. 边界值测试(输入k为0、1、二叉搜索树的结点数、二叉搜索树的结点数+1);
-3. 特殊输入测试(指向二叉搜索树的节点的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/55_01_TreeDepth.md b/docs/jianzhioffer/java/55_01_TreeDepth.md
deleted file mode 100644
index 99797309c..000000000
--- a/docs/jianzhioffer/java/55_01_TreeDepth.md
+++ /dev/null
@@ -1,59 +0,0 @@
-## 二叉树的深度
-
-### 题目描述
-输入一棵二叉树的根结点,求该树的深度。
-
-从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。
-
-**样例**
-```
-输入:二叉树[8, 12, 2, null, null, 6, 4, null, null, null, null]如下图所示:
- 8
- / \
- 12 2
- / \
- 6 4
-
-输出:3
-```
-
-### 解法
-递归即可。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/10
- */
-
-/**
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode(int x) { val = x; }
- * }
- */
-class Solution {
- /**
- * 求二叉树的深度
- *
- * @param root 二叉树根结点
- * @return 深度
- */
- public int treeDepth(TreeNode root) {
- if (root == null) {
- return 0;
- }
- int lDepth = treeDepth(root.left);
- int rDepth = treeDepth(root.right);
- return 1 + Math.max(lDepth, rDepth);
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入普通的二叉树;二叉树中所有节点都没有左/右子树);
-2. 特殊输入测试(二叉树只有一个节点;二叉树的头节点为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/55_02_BalancedBinaryTree.md b/docs/jianzhioffer/java/55_02_BalancedBinaryTree.md
deleted file mode 100644
index 521e1ceb7..000000000
--- a/docs/jianzhioffer/java/55_02_BalancedBinaryTree.md
+++ /dev/null
@@ -1,127 +0,0 @@
-## 平衡二叉树
-
-### 题目描述
-输入一棵二叉树的根结点,判断该树是不是平衡二叉树。
-
-如果某二叉树中任意结点的左右子树的深度相差不超过1,那么它就是一棵平衡二叉树。
-
-**注意:**
-
-- 规定空树也是一棵平衡二叉树。
-
-**样例**
-```
-输入:二叉树[5,7,11,null,null,12,9,null,null,null,null]如下所示,
- 5
- / \
- 7 11
- / \
- 12 9
-
-输出:true
-```
-
-### 解法
-#### 解法一
-求每个节点左右孩子的深度,判断该节点是否平衡。
-
-这种方法需要重复遍历节点多次,不推荐。
-
-
-```java
-/**
- * @author bingo
- * @since 2018/12/10
- */
-
-/**
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode(int x) { val = x; }
- * }
- */
-class Solution {
- /**
- * 判断是否是平衡二叉树
- *
- * @param root 二叉树根结点
- * @return 是否是平衡二叉树
- */
- public boolean isBalanced(TreeNode root) {
- if (root == null) {
- return true;
- }
- if (Math.abs(treeDepth(root.left) - treeDepth(root.right)) > 1) {
- return false;
- }
- return isBalanced(root.left) && isBalanced(root.right);
- }
-
- private int treeDepth(TreeNode root) {
- if (root == null) {
- return 0;
- }
- int lDepth = treeDepth(root.left);
- int rDepth = treeDepth(root.right);
- return 1 + Math.max(lDepth, rDepth);
- }
-}
-```
-
-#### 解法二
-
-```java
-/**
- * @author bingo
- * @since 2018/12/10
- */
-
-/**
- * Definition for a binary tree node.
- * public class TreeNode {
- * int val;
- * TreeNode left;
- * TreeNode right;
- * TreeNode(int x) { val = x; }
- * }
- */
-class Solution {
- private boolean isBalanced;
-
- /**
- * 判断是否是平衡二叉树
- *
- * @param root 二叉树根结点
- * @return 是否是平衡二叉树
- */
- public boolean isBalanced(TreeNode root) {
- if (root == null) {
- return true;
- }
- isBalanced = true;
- treeDepth(root);
- return isBalanced;
- }
-
- private int treeDepth(TreeNode root) {
- if (root == null || !isBalanced) {
- return 0;
- }
- int lDepth = treeDepth(root.left);
- int rDepth = treeDepth(root.right);
- if (Math.abs(lDepth - rDepth) > 1) {
- isBalanced = false;
- }
- return 1 + Math.max(lDepth, rDepth);
-
- }
-}
-```
-
-
-### 测试用例
-1. 功能测试(平衡的二叉树;不是平衡的二叉树;二叉树中所有节点都没有左/右子树);
-2. 特殊输入测试(二叉树只有一个节点;二叉树的头节点为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/56_01_NumbersAppearOnce.md b/docs/jianzhioffer/java/56_01_NumbersAppearOnce.md
deleted file mode 100644
index 1576feee2..000000000
--- a/docs/jianzhioffer/java/56_01_NumbersAppearOnce.md
+++ /dev/null
@@ -1,77 +0,0 @@
-## 数组中只出现一次的两个数字
-
-### 题目描述
-一个整型数组里除了两个数字之外,其他的数字都出现了两次。
-
-请写程序找出这两个只出现一次的数字。
-
-你可以假设这两个数字一定存在。
-
-**样例**
-```
-输入:[1,2,3,3,4,4]
-
-输出:[1,2]
-```
-
-### 解法
-如果数组有一个数字出现一次,其它数字都出现两次。那么我们很容易通过异或 `^` 运算求出来。
-
-而现在是有两个数字出现一次,那么我们考虑一下怎么将这两个数字隔开,之后我们对隔开的数组分别进行异或,不就求出来了?
-
-我们先异或,求得的结果是两个不相同的数字异或的结果,结果一定不为 0。那么它的二进制表示中一定有 1。我们根据这个 1 在二进制中出现的位置。将数组划分,这样,两个只出现一次的数字就会被隔开,之后求异或即可。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/10
- */
-
-class Solution {
- /**
- * 求数组中只出现一次的两个数字
- *
- * @param nums 数字
- * @return 两个数字组成的数组
- */
- public int[] findNumsAppearOnce(int[] nums) {
- if (nums == null || nums.length < 2) {
- return null;
- }
- int xorRes = 0;
- for (int e : nums) {
- xorRes ^= e;
- }
- int[] res = new int[2];
- int index = indexOf1(xorRes);
- for (int e : nums) {
- if (isBit1(e, index)) {
- res[0] ^= e;
- } else {
- res[1] ^= e;
- }
- }
- return res;
-
-
- }
-
- private int indexOf1(int val) {
- int index = 0;
- while ((val & 1) == 0) {
- val = val >> 1;
- ++index;
- }
- return index;
- }
-
- private boolean isBit1(int val, int index) {
- val = val >> index;
- return (val & 1) == 1;
- }
-}
-```
-
-
-### 测试用例
-1. 功能测试(数组中有多对重复的数字;数组中没有重复的数字)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/56_02_NumberAppearingOnce.md b/docs/jianzhioffer/java/56_02_NumberAppearingOnce.md
deleted file mode 100644
index f6e101c3c..000000000
--- a/docs/jianzhioffer/java/56_02_NumberAppearingOnce.md
+++ /dev/null
@@ -1,55 +0,0 @@
-## 数组中唯一只出现一次的数字
-
-### 题目描述
-在一个数组中除了一个数字只出现一次之外,其他数字都出现了三次。
-
-请找出那个只出现一次的数字。
-
-你可以假设满足条件的数字一定存在。
-
-**思考题:**
-
-- 如果要求只使用 `O(n)` 的时间和额外 `O(1)` 的空间,该怎么做呢?
-
-### 解法
-分别累加数组中每个元素的二进制中出现的数字,那么出现三次的数字,二进制位上最后累加的结果一定能被 3 整除。不能被 3 整除的位,就属于只出现一次的数字。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/10
- */
-
-class Solution {
- /**
- * 找出数组中只出现一次的数字,其它数字都出现三次
- *
- * @param nums 数字
- * @return 只出现一次的数字
- */
- public int findNumberAppearingOnce(int[] nums) {
- if (nums == null || nums.length == 0) {
- return 0;
- }
- int[] bits = new int[32];
- int n = nums.length;
- for (int i = 0; i < n; ++i) {
- int val = nums[i];
- for (int j = 0; j < 32; ++j) {
- bits[j] += (val & 1);
- val = val >> 1;
- }
- }
- int res = 0;
- for (int i = 0; i < 32; ++i) {
- if (bits[i] % 3 != 0) {
- res += Math.pow(2, i);
- }
- }
- return res;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(唯一只出现一次的数字分别是 0、正数、负数;重复出现三次的数字分别是 0、正数、负数)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/57_01_TwoNumbersWithSum.md b/docs/jianzhioffer/java/57_01_TwoNumbersWithSum.md
deleted file mode 100644
index 0b4770178..000000000
--- a/docs/jianzhioffer/java/57_01_TwoNumbersWithSum.md
+++ /dev/null
@@ -1,55 +0,0 @@
-## 和为S的两个数字
-
-### 题目描述
-输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S,如果有多对数字的和等于S,输出两个数的乘积最小的。ps:对应每个测试案例,输出两个数,小的先输出。
-
-### 解法
-定义两个指针,start指向数组头,end指向数组末尾。如果:
-
-- `sum == array[start] + array[end]`,则返回结果
-- `sum > array[start] + array[end]`,则start++,因为数组是递增的,所以从小数右边找一个大数与 `array[end]` 求和再次判断
-- 否则 end--
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/02/02
- * @description
- */
-public class Solution {
-
- public ArrayList FindNumbersWithSum(int[] array, int sum) {
-
- ArrayList reList = new ArrayList<>();
-
- if (array == null || array.length < 2 || sum <= array[0]) {
- return reList;
- }
-
- int start = 0;
- int end = array.length - 1;
-
- while (start < end) {
-
- int curSum = array[start] + array[end];
- if (curSum == sum) {
- reList.add(array[start]);
- reList.add(array[end]);
- return reList;
- } else if (curSum < sum) {
- start++;
- } else {
- end--;
- }
- }
-
- // 查无
- return reList;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(数组中存在和为 s 的两个数;数组中不存在和为 s 的两个数);
-2. 特殊输入测试(表示数组的指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/57_02_ContinuousSquenceWithSum.md b/docs/jianzhioffer/java/57_02_ContinuousSquenceWithSum.md
deleted file mode 100644
index c837b5875..000000000
--- a/docs/jianzhioffer/java/57_02_ContinuousSquenceWithSum.md
+++ /dev/null
@@ -1,77 +0,0 @@
-## 和为S的连续正数序列
-
-### 题目描述
-输入一个正数 s,打印出所有和为 s 的连续正数序列(至少含有两个数)。
-
-例如输入 15,由于 `1+2+3+4+5=4+5+6=7+8=15`,所以结果打印出 3 个连续序列 1~5、4~6 和 7~8。
-
-**样例**
-```
-输入:15
-
-输出:[[1,2,3,4,5],[4,5,6],[7,8]]
-```
-
-### 解法
-这道题同样利用两个指针left和right,将(1,2)作为初始序列。当序列和大于所求值,则left向前走,把最小的数排除了;当序列和小于所求值,则right向前走,把一个更大的数包进序列中;如果序列和等于所求值,则求值区间[left,right]中的所有数并加入到列表中,并且right向前走,把一个更大的值包入序列中。循环直到 `left < (sum + 1)/2` 。
-
-这道题的time complexity为O(n^2),space complexity为O(1)
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/02/03
- * @description
- */
-public class Solution {
-
- public List> findContinuousSequence(int sum) {
-
- List> reList = new ArrayList<>();
-
- if (sum < 3) {
- return reList;
- }
-
- int left = 1;
- int right = 2;
- int mid = (sum + 1) / 2;
- int curSum = left + right;
-
- // left小于sum一半即可(1/2n)
- while (left < mid) {
-
- // 等与sum则加入列表中(2~1/2n)
- if (curSum == sum) {
- reList.add(getListFromleftToright(left, right));
- // right增加并重新寻找序列
- right++;
- curSum += right;
- } else if (curSum > sum) {
- curSum -= left;
- left++;
- } else {
- right++;
- curSum += right;
- }
- }
-
- return reList;
- }
-
- private List getListFromleftToright(int left, int right) {
-
- List tempList = new ArrayList<>();
- for (int i = left; i <= right; i++) {
- tempList.add(i);
- }
-
- return tempList;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(存在和为 s 的连续序列,如 9、100 等;不存在和为 s 的连续序列,如 4、0 等);
-2. 边界值测试(连续序列的最小和 3)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/58_01_ReverseWordsInSentence.md b/docs/jianzhioffer/java/58_01_ReverseWordsInSentence.md
deleted file mode 100644
index 87f557479..000000000
--- a/docs/jianzhioffer/java/58_01_ReverseWordsInSentence.md
+++ /dev/null
@@ -1,55 +0,0 @@
-## 翻转单词顺序
-
-### 题目描述
-输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。
-
-为简单起见,标点符号和普通字母一样处理。
-
-例如输入字符串 `"I am a student."`,则输出 `"student. a am I"`。
-
-**样例**
-```
-输入:"I am a student."
-
-输出:"student. a am I"
-```
-
-### 解法
-先对字符串按空格切割成数组,再逆序数组后,最后将元素拼接并返回。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/12
- */
-
-class Solution {
- /**
- * 翻转单词
- *
- * @param s 字符串
- * @return 翻转后的字符串
- */
- public String reverseWords(String s) {
- if (s == null || s.length() == 0 || s.trim().equals("")) {
- return s;
- }
-
- String[] arr = s.split(" ");
- int p = 0, q = arr.length - 1;
- while (p < q) {
- swap(arr, p++, q--);
- }
- return String.join(" ", arr);
- }
- private void swap(String[] arr, int p, int q) {
- String t = arr[p];
- arr[p] = arr[q];
- arr[q] = t;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(句子中有多个单词;句子中只有一个单词);
-2. 特殊输入测试(字符串指针为空指针;字符串的内容为空;字符串中只有空格)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/58_02_LeftRotateString.md b/docs/jianzhioffer/java/58_02_LeftRotateString.md
deleted file mode 100644
index e78dc16bd..000000000
--- a/docs/jianzhioffer/java/58_02_LeftRotateString.md
+++ /dev/null
@@ -1,67 +0,0 @@
-## 左旋转字符串
-
-### 题目描述
-字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。
-
-请定义一个函数实现字符串左旋转操作的功能。
-
-比如输入字符串 `"abcdefg"` 和数字 2,该函数将返回左旋转 2 位得到的结果 `"cdefgab"`。
-
-**注意:**
-
-- 数据保证 n 小于等于输入字符串的长度。
-
-**样例**
-```
-输入:"abcdefg" , n=2
-
-输出:"cdefgab"
-```
-
-### 解法
-先翻转前 n 个字符,再翻转后面的字符,最后整体翻转。
-
-```java
-/**
- * @author bingo
- * @since 2018/12/12
- */
-
-class Solution {
-
- /**
- * 左旋转字符串
- *
- * @param str 字符串
- * @param n 左旋的位数
- * @return 旋转后的字符串
- */
- public String leftRotateString(String str, int n) {
- if (str == null || n < 1 || n > str.length()) {
- return str;
- }
- char[] chars = str.toCharArray();
- int len = chars.length;
- reverse(chars, 0, n - 1);
- reverse(chars, n, len - 1);
- reverse(chars, 0, len - 1);
- return new String(chars);
- }
-
- private void reverse(char[] chars, int p, int q) {
- while (p < q) {
- swap(chars, p++, q--);
- }
- }
-
- private void swap(char[] chars, int p, int q) {
- char t = chars[p];
- chars[p] = chars[q];
- chars[q] = t;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(把长度为 n 的字符串左旋转 0/1/2/n-1/n/n+1 个字符);
-2. 特殊输入测试(字符串指针为空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/59_01_MaxInSlidingWindow.md b/docs/jianzhioffer/java/59_01_MaxInSlidingWindow.md
deleted file mode 100644
index f568e9b30..000000000
--- a/docs/jianzhioffer/java/59_01_MaxInSlidingWindow.md
+++ /dev/null
@@ -1,75 +0,0 @@
-## 滑动窗口的最大值
-
-### 题目描述
-给定一个数组和滑动窗口的大小,请找出所有滑动窗口里的最大值。
-
-例如,如果输入数组 `[2, 3, 4, 2, 6, 2, 5, 1]` 及滑动窗口的大小 3,那么一共存在 6 个滑动窗口,它们的最大值分别为 `[4, 4, 6, 6, 6, 5]`。
-
-**注意:**
-
-- 数据保证 k 大于 0,且 k 小于等于数组长度。
-
-**样例**
-
-```
-输入:[2, 3, 4, 2, 6, 2, 5, 1] , k=3
-
-输出: [4, 4, 6, 6, 6, 5]
-```
-
-### 解法
-使用一个双端队列,保证队首存放的是窗口最大值的下标。遍历数组,
-
-1. 队尾元素比要入队的元素小,则把其移除(因为不可能成为窗口最大值)。
-2. 队首下标对应的元素不在窗口内(即窗口最大值),将其从队列中移除。
-3. 把每次滑动值的下标加入队列中(经过步骤1、2,此时加入队列的下标要么是当前窗口最大值的下标,要么是小于窗口最大值的下标)。
-4. 滑动窗口的首地址i大于size就写入窗口最大值。
-
-time complexity:O(n)
-
-space complexity:O(k) , k is the size
-
-```java
-/**
- * @author mcrwayfun
- * @version v1.0
- * @date Created in 2019/02/05
- * @description
- */
-class Solution {
-
- public ArrayList maxInWindows(int[] num, int size) {
-
- ArrayList reList = new ArrayList<>();
- if (num == null || num.length < size || size < 1) {
- return reList;
- }
-
- Deque deque = new LinkedList<>();
- for (int i = 0; i < num.length; i++) {
-
- // 队尾元素比要入队的元素小,则把其移除(因为不可能成为窗口最大值)
- while (!deque.isEmpty() && num[deque.getLast()] <= num[i]) {
- deque.pollLast();
- }
- // 队首下标对应的元素不在窗口内(即窗口最大值),将其从队列中移除
- while (!deque.isEmpty() && (i - deque.getFirst() + 1 > size)) {
- deque.pollFirst();
- }
- // 把每次滑动的值加入到队列中
- deque.add(i);
- // 滑动窗口的首地址i大于size就写入窗口最大值
- if (!deque.isEmpty() && i + 1 >= size) {
- reList.add(num[deque.getFirst()]);
- }
- }
-
- return reList;
- }
-}
-```
-
-### 测试用例
-1. 功能测试(输入数组的数字大小无序;输入数组的数字单调递增;输入数组的数字单调递减);
-2. 边界值测试(滑动窗口的大小为 0、1、等于输入数组的长度、大于输入数组的长度);
-3. 特殊输入测试(输入数组为空)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/61_ContinousCards.md b/docs/jianzhioffer/java/61_ContinousCards.md
deleted file mode 100644
index 9ff94a437..000000000
--- a/docs/jianzhioffer/java/61_ContinousCards.md
+++ /dev/null
@@ -1,78 +0,0 @@
-## 扑克牌的顺子
-
-### 题目描述
-从扑克牌中随机抽 `5` 张牌,判断是不是一个顺子,即这5张牌是不是连续的。
-
-`2~10` 为数字本身,`A` 为`1`,`J` 为 `11`,`Q` 为 `12`,`K` 为 `13`,大小王可以看做任意数字。
-
-为了方便,大小王均以 `0` 来表示,并且假设这副牌中大小王均有两张。
-
-**样例1**
-```
-输入:[8,9,10,11,12]
-
-输出:true
-```
-
-**样例2**
-```
-输入:[0,8,9,11,12]
-
-输出:true
-```
-
-### 解法
-- 对数组排序;
-- 计算出 0 的个数 `zeroCount`;
-- 从第一个不是 0 的数字开始遍历,与后一个数字比较,如果相等,直接返回 `false`;否则累计 `gap`;
-- 判断 `zeroCount` 是否大于等于 `gap`。
-
-
-```java
-import java.util.Arrays;
-
-/**
- * @author bingo
- * @since 2018/12/12
- */
-
-class Solution {
-
- /**
- * 判断是否是连续的数字
- *
- * @param numbers 数组
- * @return 是否是顺子
- */
- public boolean isContinuous(int [] numbers) {
- if (numbers == null || numbers.length == 0) {
- return false;
- }
- int zeroCount = 0;
- Arrays.sort(numbers);
- for (int e : numbers) {
- if (e > 0) {
- break;
- }
- ++zeroCount;
- }
-
- int p = zeroCount, q = p + 1, n = numbers.length;
- int gap = 0;
- while (q < n) {
- if (numbers[p] == numbers[q]) {
- return false;
- }
- gap += (numbers[q] - numbers[p] - 1);
- p = q;
- ++q;
- }
- return gap <= zeroCount;
-
- }
-}
-```
-
-### 测试用例
-1. 功能测试(抽出的牌中有一个或者多个大、小王;抽出的牌中没有大、小王;抽出的牌中有对子);
-2. 特殊输入测试(输入空指针)。
\ No newline at end of file
diff --git a/docs/jianzhioffer/java/README.md b/docs/jianzhioffer/java/README.md
deleted file mode 100644
index a7e31d6e0..000000000
--- a/docs/jianzhioffer/java/README.md
+++ /dev/null
@@ -1,71 +0,0 @@
-# 剑指 Offer Java 题解
-
-> 来源:[《剑指 Offer》 Java 版实现](https://github.com/doocs/coding-interview)
-
-| # | Title |
-|---|---|
-| 03_01 | [Find Duplication In Array](/docs/剑指offer/Java/03_01_DuplicationInArray) |
-| 03_02 | [Find Duplication In Array II](/docs/剑指offer/Java/03_02_DuplicationInArrayNoEdit) |
-| 04 | [Find In Partially Sorted Matrix](/docs/剑指offer/Java/04_FindInPartiallySortedMatrix) |
-| 05 | [Replace Spaces](/docs/剑指offer/Java/05_ReplaceSpaces) |
-| 06 | [Print List In Reversed Order](/docs/剑指offer/Java/06_PrintListInReversedOrder) |
-| 07 | [Construct Binary Tree](/docs/剑指offer/Java/07_ConstructBinaryTree) |
-| 08 | [Next Node In Binary Trees](/docs/剑指offer/Java/08_NextNodeInBinaryTrees) |
-| 09_01 | [Queue With Two Stacks](/docs/剑指offer/Java/09_01_QueueWithTwoStacks) |
-| 09_02 | [Stack With Two Queues](/docs/剑指offer/Java/09_02_StackWithTwoQueues) |
-| 10_01 | [Fibonacci](/docs/剑指offer/Java/10_01_Fibonacci) |
-| 10_02 | [Jump Floor](/docs/剑指offer/Java/10_02_JumpFloor) |
-| 10_03 | [Jump Floor II](/docs/剑指offer/Java/10_03_JumpFloorII) |
-| 10_04 | [Rect Cover](/docs/剑指offer/Java/10_04_RectCover) |
-| 11 | [Min Number In Rotated Array](/docs/剑指offer/Java/11_MinNumberInRotatedArray) |
-| 12 | [String Path In Matrix](/docs/剑指offer/Java/12_StringPathInMatrix) |
-| 13 | [Robot Move](/docs/剑指offer/Java/13_RobotMove) |
-| 14 | [Cutting Rope](/docs/剑指offer/Java/14_CuttingRope) |
-| 15 | [Number Of 1 In Binary](/docs/剑指offer/Java/15_NumberOf1InBinary) |
-| 16 | [Power](/docs/剑指offer/Java/16_Power) |
-| 17 | [Print 1 To Max Of N Digits](/docs/剑指offer/Java/17_Print1ToMaxOfNDigits) |
-| 18_01 | [Delete Node In List](/docs/剑指offer/Java/18_01_DeleteNodeInList) |
-| 18_02 | [Delete Duplicated Node](/docs/剑指offer/Java/18_02_DeleteDuplicatedNode) |
-| 19 | [Regular Expressions Matching](/docs/剑指offer/Java/19_RegularExpressionsMatching) |
-| 20 | [Numeric Strings](/docs/剑指offer/Java/20_NumericStrings) |
-| 21 | [Reorder Array](/docs/剑指offer/Java/21_ReorderArray) |
-| 22 | [Kth Node From End](/docs/剑指offer/Java/22_KthNodeFromEnd) |
-| 23 | [Entry Node In List Loop](/docs/剑指offer/Java/23_EntryNodeInListLoop) |
-| 24 | [Reverse List](/docs/剑指offer/Java/24_ReverseList) |
-| 25 | [Merge Sorted Lists](/docs/剑指offer/Java/25_MergeSortedLists) |
-| 26 | [Substructure In Tree](/docs/剑指offer/Java/26_SubstructureInTree) |
-| 27 | [Mirror Of Binary Tree](/docs/剑指offer/Java/27_MirrorOfBinaryTree) |
-| 28 | [Symmetrical Binary Tree](/docs/剑指offer/Java/28_SymmetricalBinaryTree) |
-| 29 | [Print Matrix](/docs/剑指offer/Java/29_PrintMatrix) |
-| 30 | [Min In Stack](/docs/剑指offer/Java/30_MinInStack) |
-| 31 | [Stack Push Pop Order](/docs/剑指offer/Java/31_StackPushPopOrder) |
-| 32_01 | [Print Tree From Top To Bottom](/docs/剑指offer/Java/32_01_PrintTreeFromTopToBottom) |
-| 32_02 | [Print Trees In Lines](/docs/剑指offer/Java/32_02_PrintTreesInLines) |
-| 32_03 | [Print Trees In Zigzag](/docs/剑指offer/Java/32_03_PrintTreesInZigzag) |
-| 33 | [Squence Of BST](/docs/剑指offer/Java/33_SquenceOfBST) |
-| 34 | [Path In Tree](/docs/剑指offer/Java/34_PathInTree) |
-| 35 | [Copy Complex List](/docs/剑指offer/Java/35_CopyComplexList) |
-| 36 | [Convert Binary Search Tree](/docs/剑指offer/Java/36_ConvertBinarySearchTree) |
-| 39 | [More Than Half Number](/docs/剑指offer/Java/39_MoreThanHalfNumber) |
-| 40 | [K Least Numbers](/docs/剑指offer/Java/40_KLeastNumbers) |
-| 41 | [Stream Median](/docs/剑指offer/Java/41_StreamMedian) |
-| 42 | [Greatest Sum Of Subarrays](/docs/剑指offer/Java/42_GreatestSumOfSubarrays) |
-| 44 | [Digits In Sequence](/docs/剑指offer/Java/44_DigitsInSequence) |
-| 45 | [Sort Array For Min Number](/docs/剑指offer/Java/45_SortArrayForMinNumber) |
-| 46 | [Translate Numbers To Strings](/docs/剑指offer/Java/46_TranslateNumbersToStrings) |
-| 47 | [Max Value Of Gifts](/docs/剑指offer/Java/47_MaxValueOfGifts) |
-| 48 | [Longest Substring Without Dup](/docs/剑指offer/Java/48_LongestSubstringWithoutDup) |
-| 52 | [First Common Nodes In Lists](/docs/剑指offer/Java/52_FirstCommonNodesInLists) |
-| 53_01 | [Number Of K](/docs/剑指offer/Java/53_01_NumberOfK) |
-| 53_02 | [Missing Number](/docs/剑指offer/Java/53_02_MissingNumber) |
-| 53_03 | [Integer Identical To Index](/docs/剑指offer/Java/53_03_IntegerIdenticalToIndex) |
-| 55_01 | [Tree Depth](/docs/剑指offer/Java/55_01_TreeDepth) |
-| 55_02 | [Balanced Binary Tree](/docs/剑指offer/Java/55_02_BalancedBinaryTree) |
-| 56_01 | [Numbers Appear Once](/docs/剑指offer/Java/56_01_NumbersAppearOnce) |
-| 56_02 | [Number Appearing Once](/docs/剑指offer/Java/56_02_NumberAppearingOnce) |
-| 57_01 | [Two Numbers With Sum](/docs/剑指offer/Java/57_01_TwoNumbersWithSum) |
-| 57_02 | [Continuous Squence With Sum](/docs/剑指offer/Java/57_02_ContinuousSquenceWithSum) |
-| 58_01 | [Reverse Words In Sentence](/docs/剑指offer/Java/58_01_ReverseWordsInSentence) |
-| 58_02 | [Left Rotate String](/docs/剑指offer/Java/58_02_LeftRotateString) |
-| 59_01 | [Max In Sliding Window](/docs/剑指offer/Java/59_01_MaxInSlidingWindow) |
-| 61 | [Continous Cards](/docs/剑指offer/Java/61_ContinousCards) |
diff --git a/docs/jianzhioffer/java/SUMMARY.md b/docs/jianzhioffer/java/SUMMARY.md
deleted file mode 100644
index 528c38641..000000000
--- a/docs/jianzhioffer/java/SUMMARY.md
+++ /dev/null
@@ -1,73 +0,0 @@
-+ [剑指 Offer Java 题解](README.md)
-+ [找出数组中重复的数字](03_01_DuplicationInArray.md)
-+ [不修改数组找出重复的数字](03_02_DuplicationInArrayNoEdit.md)
-+ [二维数组中的查找](04_FindInPartiallySortedMatrix.md)
-+ [替换空格](05_ReplaceSpaces.md)
-+ [从尾到头打印链表](06_PrintListInReversedOrder.md)
-+ [重建二叉树](07_ConstructBinaryTree.md)
-+ [二叉树的下一个结点](08_NextNodeInBinaryTrees.md)
-+ [用两个栈实现队列](09_01_QueueWithTwoStacks.md)
-+ [用两个队列实现栈](09_02_StackWithTwoQueues.md)
-+ [斐波那契数列](10_01_Fibonacci.md)
-+ [跳台阶](10_02_JumpFloor.md)
-+ [变态跳台阶](10_03_JumpFloorII.md)
-+ [矩形覆盖](10_04_RectCover.md)
-+ [旋转数组的最小数字](11_MinNumberInRotatedArray.md)
-+ [矩阵中的路径](12_StringPathInMatrix.md)
-+ [机器人的移动范围](13_RobotMove.md)
-+ [剪绳子](14_CuttingRope.md)
-+ [二进制中 1 的个数](15_NumberOf1InBinary.md)
-+ [数值的整数次方](16_Power.md)
-+ [打印从 1 到最大的 n 位数](17_Print1ToMaxOfNDigits.md)
-+ [在O(1)时间内删除链表节点](18_01_DeleteNodeInList.md)
-+ [删除链表中重复的节点](18_02_DeleteDuplicatedNode.md)
-+ [正则表达式匹配](19_RegularExpressionsMatching.md)
-+ [表示数值的字符串](20_NumericStrings.md)
-+ [调整数组顺序使奇数位于偶数前面](21_ReorderArray.md)
-+ [链表中倒数第k个结点](22_KthNodeFromEnd.md)
-+ [链表中环的入口结点](23_EntryNodeInListLoop.md)
-+ [反转链表](24_ReverseList.md)
-+ [合并两个排序的链表](25_MergeSortedLists.md)
-+ [树的子结构](26_SubstructureInTree.md)
-+ [二叉树的镜像](27_MirrorOfBinaryTree.md)
-+ [对称的二叉树](28_SymmetricalBinaryTree.md)
-+ [顺时针打印矩阵](29_PrintMatrix.md)
-+ [包含min函数的栈](30_MinInStack.md)
-+ [栈的压入、弹出序列](31_StackPushPopOrder.md)
-+ [不分行从上到下打印二叉树](32_01_PrintTreeFromTopToBottom.md)
-+ [把二叉树打印成多行](32_02_PrintTreesInLines.md)
-+ [按之字形打印二叉树](32_03_PrintTreesInZigzag.md)
-+ [二叉搜索树的后序遍历序列](33_SquenceOfBST.md)
-+ [二叉树中和为某一值的路径](34_PathInTree.md)
-+ [复杂链表的复制](35_CopyComplexList.md)
-+ [二叉搜索树与双向链表](36_ConvertBinarySearchTree.md)
-+ [序列化二叉树](37_SerializeBinaryTrees.md)
-+ [字符串的排列](38_StringPermutation.md)
-+ [数组中出现次数超过一半的数字](39_MoreThanHalfNumber.md)
-+ [获取数组中最小的k个数](40_KLeastNumbers.md)
-+ [数据流中的中位数](41_StreamMedian.md)
-+ [连续子数组的最大和](42_GreatestSumOfSubarrays.md)
-+ [整数中1出现的次数](43_NumberOf1.md)
-+ [数字序列中某一位的数字](44_DigitsInSequence.md)
-+ [把数组排成最小的数](45_SortArrayForMinNumber.md)
-+ [把数字翻译成字符串](46_TranslateNumbersToStrings.md)
-+ [礼物的最大价值](47_MaxValueOfGifts.md)
-+ [最长不含重复字符的子字符串](48_LongestSubstringWithoutDup.md)
-+ [丑数](49_UglyNumber.md)
-+ [第一个只出现一次的字符](50_01_FirstNotRepeatingChar.md)
-+ [字符流中第一个不重复的字符](50_02_FristCharacterInStream.md)
-+ [两个链表的第一个公共结点](52_FirstCommonNodesInLists.md)
-+ [数字在排序数组中出现的次数](53_01_NumberOfK.md)
-+ [0到n-1中缺失的数字](53_02_MissingNumber.md)
-+ [数组中数值和下标相等的元素](53_03_IntegerIdenticalToIndex.md)
-+ [二叉搜索树的第k个结点](54_KthNodeInBST.md)
-+ [二叉树的深度](55_01_TreeDepth.md)
-+ [平衡二叉树](55_02_BalancedBinaryTree.md)
-+ [数组中只出现一次的两个数字](56_01_NumbersAppearOnce.md)
-+ [数组中唯一只出现一次的数字](56_02_NumberAppearingOnce.md)
-+ [和为S的两个数字](57_01_TwoNumbersWithSum.md)
-+ [和为S的连续正数序列](57_02_ContinuousSquenceWithSum.md)
-+ [翻转单词顺序](58_01_ReverseWordsInSentence.md)
-+ [左旋转字符串](58_02_LeftRotateString.md)
-+ [滑动窗口的最大值](59_01_MaxInSlidingWindow.md)
-+ [扑克牌的顺子](61_ContinousCards.md)
diff --git a/docs/leetcode/cpp/0001._Two_Sum.md b/docs/leetcode/cpp/0001._Two_Sum.md
deleted file mode 100644
index 917f83e6f..000000000
--- a/docs/leetcode/cpp/0001._Two_Sum.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# 1. Two Sum
- **难度: Easy **
- ## 刷题内容
- > 原题连接
- * https://leetcode.com/problems/two-sum
-* https://leetcode-cn.com/problems/two-sum
- > 内容描述
- ```
-给定 nums = [2, 7, 11, 15], target = 9
- 因为 nums[0] + nums[1] = 2 + 7 = 9
-所以返回 [0, 1]
-```
- ## 解题方案
- > 思路 1
-******- 时间复杂度: O(NlgN)******- 空间复杂度: O(N)******
- 采用双指针法,先将数组排序形成了一个有序的区间,指针i,j分别指向头尾,
-```
-当 nums1[i] + nums[j] > traget 时,j--,
-nums[i] + nums[j] < target 时,i++,
-直到 nums[i] + nums[j] == target
-```
-```cpp
-class Solution
-{
-public:
- vector twoSum(vector& nums, int target)
- {
- vector > nums1;
- for(int i = 0;i < nums.size();++i)
- nums1.push_back(make_pair(nums[i],i));
- sort(nums1.begin(),nums1.end());
- int i = 0,j = nums1.size() - 1;
- vector ret;
- while(i < j)
- {
- if(nums1[i].first + nums1[j].first == target)
- {
- ret.push_back(nums1[i].second);
- ret.push_back(nums1[j].second);
- return ret;
- }
- nums1[i].first +nums1[j].first < target ? ++i : --j;
- }
- }
-};
-```
-> 思路 2
-******- 时间复杂度: O(N)******- 空间复杂度: O(N)******
- c++中提供了 unordered_map 的容器,unordered_map 中的元素没有按照它们的键值或映射值的任何顺序排序,
-而是根据它们的散列值组织成桶以允许通过它们的键值直接快速访问单个元素(具有常数平均时间复杂度)
-将先出现的元素储存在 unorder_map 中,遍历数组,每次查找 target - nums[i] 是否存在即可。
- ```cpp
-class Solution
-{
-public:
- vector twoSum(vector& nums, int target)
- {
- unordered_map m;
- vector res;
- for (int i = 0; i < nums.size(); ++i) {
- m[nums[i]] = i;
- }
- for (int i = 0; i < nums.size(); ++i) {
- int t = target - nums[i];
- if (m.count(t) && m[t] != i) {
- res.push_back(i);
- res.push_back(m[t]);
- break;
- }
- }
- return res;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0002._Add_Two_Numbers.md b/docs/leetcode/cpp/0002._Add_Two_Numbers.md
deleted file mode 100644
index 728077ac6..000000000
--- a/docs/leetcode/cpp/0002._Add_Two_Numbers.md
+++ /dev/null
@@ -1,70 +0,0 @@
-# 2. Add Two Numbers
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/add-two-numbers
-
-> 内容描述
-
-```
-给定两个链表代表两个非负数,求这两个数的和
-(2 -> 4 -> 3) + (5 -> 6 -> 4)
-因为 342 + 465 = 807
-所以返回 7 -> 0 -> 8
-```
-
-## 解题方案
-
-> 思路
-
-
-这题的的关键在于链表的数储存是倒序的,因此只要从链表头相加,再将所得数挨个储存即可,但是要注意两数相加有可能大于10要进一位。
-```cpp
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- * int val;
- * ListNode *next;
- * ListNode(int x) : val(x), next(NULL) {}
- * };
- */
-class Solution {
-public:
- ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
- ListNode* current;
- ListNode* ret = nullptr;
- int num = 0;
- while(l1 && l2)
- {
- int sum = l1 ->val + l2 ->val + num;
- ListNode* node = new ListNode(sum % 10);
- num = sum / 10;
- ret ? current ->next = node : ret = node;
- current = node;
- l1 = l1 ->next;
- l2 = l2 ->next;
- }
- if(l2)
- l1 = l2;
- while(l1)
- {
- int sum = num + l1 ->val;
- ListNode* node = new ListNode(sum % 10);
- num = sum / 10;
- current ->next = node;
- current = node;
- l1 = l1 ->next;
- }
- if(num)
- {
- ListNode* node = new ListNode(num);
- current ->next = node;
- }
- return ret;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0003._Longest_Substring_Without_Repeating_Characters.md b/docs/leetcode/cpp/0003._Longest_Substring_Without_Repeating_Characters.md
deleted file mode 100644
index 983bad57c..000000000
--- a/docs/leetcode/cpp/0003._Longest_Substring_Without_Repeating_Characters.md
+++ /dev/null
@@ -1,97 +0,0 @@
-# 3. Longest Substring Without Repeating Characters
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/longest-substring-without-repeating-characters
-
-> 内容描述
-
-```
-
-Given a string, find the length of the longest substring without repeating characters.
-
-Example 1:
-
-Input: "abcabcbb"
-Output: 3
-Explanation: The answer is "abc", with the length of 3.
-Example 2:
-
-Input: "bbbbb"
-Output: 1
-Explanation: The answer is "b", with the length of 1.
-Example 3:
-
-Input: "pwwkew"
-Output: 3
-Explanation: The answer is "wke", with the length of 3.
- Note that the answer must be a substring, "pwke" is a subsequence and not a substring.
-```
-
-## 解题方案
-
-> 思路 1
-******- 时间复杂度: O(NlgN)******- 空间复杂度: O(N)******
-
-
-用 map储存 key为字符,value 为这个字符的位置,我们可以维护一个子字符串(无重复字符),记录它的起始位置,遍历 string s 当无法在map中找到字符或者小于子字符串的起始位置,就是没有在这个字符串中出现,反之则字符重复,不过 map查找为 O(lgn),因此总的时间复杂度为O(NlgN)
-```cpp
-class Solution {
-public:
- int lengthOfLongestSubstring(string s) {
- map m;
- int beg = 0,length = s.length(),ll = 0,ans = 0;
- for(int i = 0;i < length;++i)
- {
- if(m.find(s[i]) == m.end() || m[s[i]] < beg)
- ll++;
- else
- {
- int pos = m[s[i]];
- ans = max(ll,ans);
- ll = ll - (pos - beg);
- beg = pos + 1;
- }
- m[s[i]] = i;
- }
- ans = max(ans,ll);
- return ans;
- }
-};
-```
-
-> 思路 2
-******- 时间复杂度: O(NlgN)******- 空间复杂度: O(1)******
-
-这个思路和上面差不多,用到了一个小窍门,因为储存的是字符,char为8位,因此能储存的最大数为256,这样空间复杂度就为O(1)
-
-```cpp
-class Solution {
-public:
- int lengthOfLongestSubstring(string s) {
- int m[256];
- for(int i = 0;i < 256;++i)
- m[i] = -1;
- int beg = 0,length = s.length(),ll = 0,ans = 0;
- for(int i = 0;i < length;++i)
- {
- if(m[s[i]] < beg)
- ll++;
- else
- {
- int pos = m[s[i]];
- ans = max(ll,ans);
- ll = ll - (pos - beg);
- beg = pos + 1;
- }
- m[s[i]] = i;
- }
- ans = max(ans,ll);
- return ans;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0004._Median_of_Two_Sorted_Arrays.md b/docs/leetcode/cpp/0004._Median_of_Two_Sorted_Arrays.md
deleted file mode 100644
index be2f433bb..000000000
--- a/docs/leetcode/cpp/0004._Median_of_Two_Sorted_Arrays.md
+++ /dev/null
@@ -1,159 +0,0 @@
-# 004. Median of Two Sorted Arrays
-
-**难度Hard**
-
-## 刷题内容
-> 原题连接
-
-* https://leetcode.com/problems/median-of-two-sorted-arrays/submissions/
-
-> 内容描述
-
-```
-There are two sorted arrays nums1 and nums2 of size m and n respectively.
-
-Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
-
-You may assume nums1 and nums2 cannot be both empty.
-
-Example 1:
-
-nums1 = [1, 3]
-nums2 = [2]
-
-The median is 2.0
-Example 2:
-
-nums1 = [1, 2]
-nums2 = [3, 4]
-
-The median is (2 + 3)/2 = 2.5
-```
-
-> 思路1
-******- 时间复杂度: O(n + m)******- 空间复杂度: O(1)******
-
-直接用暴利搜索,类似与归并两个有序的数组。遍历两个数组,当总长度等于(m+n)/ 2,注意区分总长度奇数和偶数
-```cpp
-class Solution {
-public:
- double findMedianSortedArrays(vector& nums1, vector& nums2) {
- int temp = (nums1.size() + nums2.size()) / 2,count1 = 0,i = 0,j = 0,current,pre;
- while(i < nums1.size() && j < nums2.size() && count1 <= temp)
- {
- pre = current;
- if(nums1[i] > nums2[j])
- current = nums2[j++];
- else
- current = nums1[i++];
- ++count1;
- }
- if(count1 <= temp)
- {
- if(i < nums1.size())
- while(count1 <= temp)
- {
- pre = current;
- current = nums1[i++];
- ++count1;
- }
- else
- while(count1 <= temp)
- {
- pre = current;
- current = nums2[j++];
- ++count1;
- }
- }
- if((nums1.size() + nums2.size()) % 2)
- return current;
- double ans = (current + pre) / 2.0;
- return ans;
- }
-};
-```
-> 思路2
-******- 时间复杂度: O(lg(min(n.m)))******- 空间复杂度: O(1)******
-
-我们可以通过二分查找优化算法,利用中位数的定义,将两个数组划分为左右两个部分,nums1左半部分加nums2左半部分等于nums1右半部分加nums2的右半部分,如果总长度为偶数,那么nums1左半部分加nums2左半部分等于nums1右半部分加nums2的右半部分加1。并且```max(nums1[i],nums2[j]) <= max(nums1[i + 1],nums2[j + 1])```,接下来我们只要二分查找找i,并且要注意边界情况
-
-```cpp
-class Solution {
-public:
- double findMedianSortedArrays(vector& nums1, vector& nums2) {
- int m = nums1.size(),n = nums2.size(),sum = m + n;
- if(!nums1.size())
- return sum % 2 ? nums2[sum / 2] : (nums2[sum /2] + nums2[sum / 2 - 1]) / 2.0;
- if(!nums2.size())
- return sum % 2 ? nums1[sum / 2] : (nums1[sum /2] + nums1[sum / 2 - 1]) / 2.0;
- if(m > n)
- return findMedianSortedArrays(nums2,nums1);
- int l = 0,r = m - 1;
- while(l < r)
- {
- int mid = (l + r) / 2;
- int j = (sum + 1) / 2 - mid - 2;
- int min1 = max(nums1[mid],nums2[j]),max1 = min(nums1[mid + 1],nums2[j + 1]);
- if(min1 <= max1)
- return sum % 2 ? min1 : (min1 + max1) / 2.0;
- else if(nums1[mid] > nums2[j])
- r = mid - 1;
- else
- l = mid + 1;
- }
- int j = (sum + 1) / 2 - l - 2;
- int min1,max1;
- if(j < 0)
- min1 = nums1[l];
- else
- min1 = max(nums1[l],nums2[j]);
- if(l == nums1.size() - 1)
- max1 = nums2[j + 1];
- else
- max1 = min(nums1[l + 1],nums2[j + 1]);
- if(min1 <= max1)
- return sum % 2 ? min1 : (min1 + max1) / 2.0;
- j++;
- if(j < nums2.size() - 1)
- max1 = min(nums1[l],nums2[j + 1]);
- else
- max1 = nums1[l];
- min1 = nums2[j];
- return sum % 2 ? min1 : (min1 + max1) / 2.0;
- }
-};
-```
-> 思路3
-******- 时间复杂度: O(lg(n+m))******- 空间复杂度: O(1)******
-
-由于题目中建议我们在时间复杂度O(lg(m+n))中完成,我们可以把这题看成寻找第k大的值,这样我们可以递归的去做,每次查找k/2,知道k等于1,注意边界值的处理
-```cpp
-class Solution {
-public:
-int getKth(vector nums1, int start1, int end1, vector nums2, int start2, int end2, int k) {
- int len1 = end1 - start1 + 1;
- int len2 = end2 - start2 + 1;
- if (len1 > len2) return getKth(nums2, start2, end2, nums1, start1, end1, k);
- if (len1 == 0) return nums2[start2 + k - 1];
-
- if (k == 1) return min(nums1[start1], nums2[start2]);
-
- int i = start1 + min(len1, k / 2) - 1;
- int j = start2 + min(len2, k / 2) - 1;
-
- if (nums1[i] > nums2[j]) {
- return getKth(nums1, start1, end1, nums2, j + 1, end2, k - (j - start2 + 1));
- }
- else {
- return getKth(nums1, i + 1, end1, nums2, start2, end2, k - (i - start1 + 1));
- }
- }
-double findMedianSortedArrays(vector nums1, vector nums2) {
- int n = nums1.size();
- int m = nums2.size();
- int left = (n + m + 1) / 2;
- int right = (n + m + 2) / 2;
- return (getKth(nums1, 0, n - 1, nums2, 0, m - 1, left) + getKth(nums1, 0, n - 1, nums2, 0, m - 1, right)) * 0.5;
-}
-};
-```
diff --git a/docs/leetcode/cpp/0005._Longest_Palindromic_Substring.md b/docs/leetcode/cpp/0005._Longest_Palindromic_Substring.md
deleted file mode 100644
index b535fbe5d..000000000
--- a/docs/leetcode/cpp/0005._Longest_Palindromic_Substring.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# 5. Longest Palindromic Substring
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/longest-palindromic-substring
-
-> 内容描述
-
-```
-Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
-
-Example 1:
-
-Input: "babad"
-Output: "bab"
-Note: "aba" is also a valid answer.
-Example 2:
-
-Input: "cbbd"
-Output: "bb"
-```
-
-## 解题方案
-
-> 思路 1
-******- 时间复杂度: O(N^2)******- 空间复杂度: O(N^2)******
-
-
-这题如果用单纯暴力的解法,时间复杂度为 O(n ^ 3),肯定超时,那么就要对这个算法进行优化,这里采用的是DP思想,定义 p(i,j)为s中的第i个数到s中的第j个数的子串,不难看出 p(i,j)中的子串有重复计算,接下来就可以写出状态转移方程 P(i,j)=(P(i+1,j?1) and S[i] == S[j])
-
-```cpp
-class Solution {
-public:
- int dp[1000][1000] = {0};
- string longestPalindrome(string s) {
- int beg = 0,en = 1,ans = 0;
- int length = s.length();
- for(int i = 0;i < length;++i)
- {
- dp[i][i] = 1;
- if(i + 1 < length && s[i] == s[i + 1])
- dp[i][i + 1] = 1;
- }
- for(int i = 0;i < length;++i)
- for(int j = 0;j <= i;++j)
- {
- if(i > j + 1)
- dp[j][i] = (dp[j + 1][i - 1] && s[i] == s[j]);
- if(dp[j][i] && i - j + 1 > ans)
- {
- ans = i - j + 1;
- beg = j;
- en = i + 1;
- }
- }
- string ret(s.begin() + beg,s.begin() + en);
- return ret;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0006._ZigZag_Conversion.md b/docs/leetcode/cpp/0006._ZigZag_Conversion.md
deleted file mode 100644
index 6cbbc25c6..000000000
--- a/docs/leetcode/cpp/0006._ZigZag_Conversion.md
+++ /dev/null
@@ -1,96 +0,0 @@
-# 6. ZigZag Conversion
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-*https://leetcode.com/problems/zigzag-conversion
-*
-> 内容描述
-
-```
-The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
-
-P A H N
-A P L S I I G
-Y I R
-And then read line by line: "PAHNAPLSIIGYIR"
-
-Write the code that will take a string and make this conversion given a number of rows:
-
-string convert(string s, int numRows);
-Example 1:
-
-Input: s = "PAYPALISHIRING", numRows = 3
-Output: "PAHNAPLSIIGYIR"
-Example 2:
-
-Input: s = "PAYPALISHIRING", numRows = 4
-Output: "PINALSIGYAHRPI"
-Explanation:
-
-P I N
-A L S I G
-Y A H R
-P I
-```
-
-## 解题方案
-
-> 思路1
-******- 时间复杂度: O(N)******- 空间复杂度: O(N + numRows)******
-
-
-这道题理解了题目意思其实不难,一般人可能会开一个二维数组,然后就按题目意思储存,这样做的话时间复杂度和空间复杂度都比较大,这里我用的方法先用一个 string 类型变量 str ,resize 和输入的 s 长度相等,接着只要遍历找到 s[i] 在 str 中的位置即可
-
-
-```cpp
-class Solution {
-public:
- string convert(string s, int numRows) {
- string newStr;
- if(!s.length() || numRows == 1)
- return s;
- newStr.resize(s.length());
- int num = numRows * 2 - 2,col = s.length() / num,rem = (s.length() - 1) % num;
- vector rowNum;
- for(int i = 0;i < numRows;++i)
- if(!i)
- s.length() % num ? rowNum.push_back(col + 1) : rowNum.push_back(col);
- else
- {
- if(i == numRows - 1)
- rem >= i ? rowNum.push_back(rowNum[i - 1] + (s.length() - 1) / num + 1) : rowNum.push_back(rowNum[i - 1] + (s.length() - 1) / num);
- else
- {
- int temp = 2 * numRows - i - 2,col1 = (s.length() - 1) / num;
- if(rem >= temp)
- rowNum.push_back(rowNum[i - 1] + (col1 + 1) * 2);
- else if(rem >= i)
- rowNum.push_back(rowNum[i - 1] + col1 * 2 + 1);
- else
- rowNum.push_back(rowNum[i - 1] + col1 * 2);
- }
- }
- for(int i = 0;i < s.length();++i)
- {
- int index1 = i % num;
- int index2 = i / num;
- if(!index1)
- newStr[index2] = s[i];
- else if(index1 == numRows - 1)
- newStr[index2 + rowNum[index1 - 1]] = s[i];
- else if(index1 < numRows)
- newStr[index2 * 2 + rowNum[index1 - 1]] = s[i];
- else
- {
- int index3 = 2 * numRows - index1 - 2;
- newStr[index2 * 2 + 1 + rowNum[index3 - 1]] = s[i];
- }
- }
- return newStr;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0007._Reverse_Integer.md b/docs/leetcode/cpp/0007._Reverse_Integer.md
deleted file mode 100644
index 296913158..000000000
--- a/docs/leetcode/cpp/0007._Reverse_Integer.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# 7. Reverse Integer
-
-**�Ѷ�:Easy**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/reverse-integer/
-
-> ��������
-
-```
-Given a 32-bit signed integer, reverse digits of an integer.
-
-Example 1:
-
-Input: 123
-Output: 321
-Example 2:
-
-Input: -123
-Output: -321
-Example 3:
-
-Input: 120
-Output: 21
-Note:
-Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [?231, 231 ? 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(1)******
-
-һ��easy����Ŀ�����μ������λ����������Ҫע�ⳬ��int�ķ�Χ��
-
-```cpp
-class Solution {
-public:
- int reverse(int x) {
- long long val = 0;
- do
- {
- val = val * 10 + x % 10;
- x /= 10;
- } while (x);
-
- return (val > INT_MAX || val < INT_MIN) ? 0 : val;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0008._String_to_Integer_(atoi).md b/docs/leetcode/cpp/0008._String_to_Integer_(atoi).md
deleted file mode 100644
index 66c9454fa..000000000
--- a/docs/leetcode/cpp/0008._String_to_Integer_(atoi).md
+++ /dev/null
@@ -1,104 +0,0 @@
-# 8. String to Integer (atoi)
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/string-to-integer-atoi/
-
-> ��������
-
-```
-Implement atoi which converts a string to an integer.
-
-The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.
-
-The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
-
-If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
-
-If no valid conversion could be performed, a zero value is returned.
-
-Note:
-
-Only the space character ' ' is considered as whitespace character.
-Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [?231, 231 ? 1]. If the numerical value is out of the range of representable values, INT_MAX (231 ? 1) or INT_MIN (?231) is returned.
-Example 1:
-
-Input: "42"
-Output: 42
-Example 2:
-
-Input: " -42"
-Output: -42
-Explanation: The first non-whitespace character is '-', which is the minus sign.
- Then take as many numerical digits as possible, which gets 42.
-Example 3:
-
-Input: "4193 with words"
-Output: 4193
-Explanation: Conversion stops at digit '3' as the next character is not a numerical digit.
-Example 4:
-
-Input: "words and 987"
-Output: 0
-Explanation: The first non-whitespace character is 'w', which is not a numerical
- digit or a +/- sign. Therefore no valid conversion could be performed.
-Example 5:
-
-Input: "-91283472332"
-Output: -2147483648
-Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer.
- Thefore INT_MIN (?231) is returned.
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(N)******
-
-��һ���ַ���ת�����֣�����ַ���ֻ������ֻҪ�����ַ���ת��int���͵����ּ��ɣ������������������ģ����Ҫע��߽�ֵ���ж����ֵ�����������Ϊ�����Ч�ʡ��ȼ�����10��32�η���10��n�η���ֵ��
-
-```cpp
-class Solution {
-public:
- int myAtoi(string str) {
- int i = 0,count1 = 0;
- long long arr[34];
- arr[0] = 1;
- for(int i = 1;i < 34;++i)
- arr[i] = arr[i - 1] * 10;
- while(str[i] == ' ')
- i++;
- if(str[i] == '-' || str[i] == '+')
- {
- if(str[i] == '-')
- count1 = 1;
- i++;
- }
- if(!isdigit(str[i]))
- return 0;
- while(str[i] == '0')
- i++;
- long long num = 0;
- int j = i;
- while(j < str.length() && isdigit(str[j]))
- j++;
- if(j - i > 33)
- return count1 ? INT_MIN : INT_MAX;
- j--;
- int t = 0;
- while(j >= i)
- {
- num += (str[j] - '0') * arr[t++];
- if(!count1 && num > INT_MAX)
- return INT_MAX;
- if(count1 && num * -1 < INT_MIN)
- return INT_MIN;
- j--;
- }
- if(count1)
- num *= -1;
- return num;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0009._Palindrome_Number.md b/docs/leetcode/cpp/0009._Palindrome_Number.md
deleted file mode 100644
index 788beb123..000000000
--- a/docs/leetcode/cpp/0009._Palindrome_Number.md
+++ /dev/null
@@ -1,102 +0,0 @@
-# 9. Palindrome Number
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/palindrome-number
-*
-> 内容描述
-
-```
-Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
-
-Example 1:
-
-Input: 121
-Output: true
-Example 2:
-
-Input: -121
-Output: false
-Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
-Example 3:
-
-Input: 10
-Output: false
-Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
-Follow up:
-
-Coud you solve it without converting the integer to a string?
-```
-
-## 解题方案
-
-> 思路1
-******- 时间复杂度: O(N)******- 空间复杂度: O(1)******
-
-
-这题的难度不大,由于是数字,判断回文只需要求出倒过来的数字,判断两者是否相等,不过要注意负数一定不是回文
-
-
-```cpp
-class Solution {
-public:
- bool isPalindrome(int x) {
- long long ret = 0;
- int num = x;
- if(x < 0)
- return false;
- while(num)
- {
- ret = 10 * ret + num % 10;
- num /= 10;
- }
- if(ret == x)
- return true;
- return false;
- }
-};
-```
-> 思路2
-******- 时间复杂度: O(N)******- 空间复杂度: O(1)******
-
-
-计算出数字的长度,用双指针法,一个指针指向头,另一个指向尾,相等就前一个指针加一,后一个指针减一,若不相等则返回 false
-
-
-```cpp
-class Solution {
-public:
- bool isPalindrome(int x) {
- if (x < 0)
- return false;
-
- int cnt = 0;
- long fac = 1;
- int div = INT_MAX;
- while (div != 0) {
- cnt++;
- fac *= 10;
- div = x/fac;
- }
-
- fac /= 10;
- for (int i=0; i难度: Hard **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/regular-expression-matching
-
-> 内容描述
-
-```
-Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.
-
-'.' Matches any single character.
-'*' Matches zero or more of the preceding element.
-The matching should cover the entire input string (not partial).
-
-Note:
-
-s could be empty and contains only lowercase letters a-z.
-p could be empty and contains only lowercase letters a-z, and characters like . or *.
-
-Example 1:
-
-Input:
-s = "aa"
-p = "a"
-Output: false
-Explanation: "a" does not match the entire string "aa".
-
-Example 2:
-
-Input:
-s = "aa"
-p = "a*"
-Output: true
-Explanation: '*' means zero or more of the precedeng element, 'a'. Therefore, by repeating 'a' once, it becomes "aa".
-
-Example 3:
-
-Input:
-s = "ab"
-p = ".*"
-Output: true
-Explanation: ".*" means "zero or more (*) of any character (.)".
-
-Example 4:
-
-Input:
-s = "aab"
-p = "c*a*b"
-Output: true
-Explanation: c can be repeated 0 times, a can be repeated 1 time. Therefore it matches "aab".
-
-Example 5:
-
-Input:
-s = "mississippi"
-p = "mis*is*p*."
-Output: false
-```
-
-## 解题方案
-
-> 思路1
-******- 时间复杂度: O(n^2)******- 空间复杂度: O(n^2)******
-
-用动态规划的思路去解,dp[i][j]代表字符串s中第i个字符之前的字符串与p中第j个字符串之前的字符是否匹配。写出状态转移方程。当```s[i] == p[j] || p[j] == '.'```时。```dp[i + 1][j + 1] = dp[i][j]```。当```p[j] == '*'```时,可以匹配0个,1个或多个之前相同的字符。当之前的字符```s[i] == p[j - 1] || p[j - 1] == '*'```时。```dp[i + 1][j + 1] = dp[i][j] || dp[i][j + 1]```表示匹配1个或者多个。还可匹配0个。因此```dp[i + 1][j + 1] = dp[i + 1][j + 1] || dp[i + 1][j - 1]```
-
-```cpp
-class Solution {
-public:
- bool isMatch(string s, string p) {
- s.push_back(' ');
- p.push_back(' ');
- int len1 = s.length(),len2 = p.length();
- int dp[len1 + 1][len2 + 1];
- memset(dp,0,sizeof(dp));
- dp[0][0] = 1;
- for(int i = 1;i < len2;++i)
- if(p[i] == '*')
- dp[0][i + 1] = dp[0][i - 1];
- for(int i = 0;i < len1;++i)
- for(int j = 0;j < len2;++j)
- if(j && p[j] == '*')
- {
- dp[i + 1][j + 1] = (p[j - 1] == s[i] || p[j - 1] == '.') && (dp[i][j] || dp[i][j + 1]);
- dp[i + 1][j + 1] = dp[i + 1][j + 1] || dp[i + 1][j - 1];
- }
- else if(s[i] == p[j] || p[j] == '.')
- dp[i + 1][j + 1] = dp[i][j];
- return dp[len1][len2];
- }
-};
-```
diff --git a/docs/leetcode/cpp/0011._Container_With_Most_Water.md b/docs/leetcode/cpp/0011._Container_With_Most_Water.md
deleted file mode 100644
index 1a610d4da..000000000
--- a/docs/leetcode/cpp/0011._Container_With_Most_Water.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# 11. container with most water
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-*https://leetcode.com/problems/container-with-most-water/
-*
-> 内容描述
-
-```
-Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
-
-Note: You may not slant the container and n is at least 2.
-```
-
-## 解题方案
-
-> 思路
-******- 时间复杂度: O(N)******- 空间复杂度: O(1)******
-
-这道题刚开始很容易想到用暴力的方法去解,但是时间复杂度为 O(n^2) 测试之后发现是 TLE,那么我们就要对算法进行优化,这里我们用双指针法,定义两个指针,一个指向头,另一个指向尾部,比较两个指针指向的数的大小,若头部的大,则指向头部的指针向后移动一位,反之,则指向尾部的指针向前移动一位。
-
-
-```cpp
-class Solution {
-public:
- int maxArea(vector& height) {
- int i = 0,j = height.size() - 1,ans = INT_MIN;
- while(i < j)
- {
- int t = min(height[i],height[j]);
- ans = max(ans,t * (j - i));
- height[i] < height[j] ? i++ : j--;
- }
- return ans;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0012._Integer_to_Roman.md b/docs/leetcode/cpp/0012._Integer_to_Roman.md
deleted file mode 100644
index e646d8a4c..000000000
--- a/docs/leetcode/cpp/0012._Integer_to_Roman.md
+++ /dev/null
@@ -1,164 +0,0 @@
-# 12. Integer to Roman
-
-**�Ѷ�:Medium**
-
-## ˢ������
-
-> ԭ������
-
-* https://leetcode.com/problems/rotate-list/
-
-> ��������
-
-```
-Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
-
-Symbol Value
-I 1
-V 5
-X 10
-L 50
-C 100
-D 500
-M 1000
-For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II.
-
-Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:
-
-I can be placed before V (5) and X (10) to make 4 and 9.
-X can be placed before L (50) and C (100) to make 40 and 90.
-C can be placed before D (500) and M (1000) to make 400 and 900.
-Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.
-
-Example 1:
-
-Input: 3
-Output: "III"
-Example 2:
-
-Input: 4
-Output: "IV"
-Example 3:
-
-Input: 9
-Output: "IX"
-Example 4:
-
-Input: 58
-Output: "LVIII"
-Explanation: L = 50, V = 5, III = 3.
-Example 5:
-
-Input: 1994
-Output: "MCMXCIV"
-Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
-
-```
-
-
-
-> ˼·1
-
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(n)******
-
-��Ŀ���ѣ�ֱ����һ�ֱ�����д��
-
-```cpp
-class Solution {
-public:
- string intToRoman(int num) {
- string ans;
- vector table;
- int a = 0;
- int count = 0;
- while(num){
- a = num%10;
- num /= 10;
- ++count;
- if(count==1){
- if(a==1) table.push_back("I");
- else if(a==2) table.push_back("II");
- else if(a==3) table.push_back("III");
- else if(a==4) table.push_back("IV");
- else if(a==5) table.push_back("V");
- else if(a==6) table.push_back("VI");
- else if(a==7) table.push_back("VII");
- else if(a==8) table.push_back("VIII");
- else if(a==9) table.push_back("IX");
- }
- else if(count==2){
- if(a==1) table.push_back("X");
- else if(a==2) table.push_back("XX");
- else if(a==3) table.push_back("XXX");
- else if(a==4) table.push_back("XL");
- else if(a==5) table.push_back("L");
- else if(a==6) table.push_back("LX");
- else if(a==7) table.push_back("LXX");
- else if(a==8) table.push_back("LXXX");
- else if(a==9) table.push_back("XC");
- }
- else if(count==3){
- if(a==1) table.push_back("C");
- else if(a==2) table.push_back("CC");
- else if(a==3) table.push_back("CCC");
- else if(a==4) table.push_back("CD");
- else if(a==5) table.push_back("D");
- else if(a==6) table.push_back("DC");
- else if(a==7) table.push_back("DCC");
- else if(a==8) table.push_back("DCCC");
- else if(a==9) table.push_back("CM");
- }
- else if(count==4){
- if(a==1) table.push_back("M");
- else if(a==2) table.push_back("MM");
- else if(a==3) table.push_back("MMM");
- }
- }
- for(int i = table.size()-1; i >= 0; --i){
- ans += table[i];
- }
- return ans;
- }
-};
-```
-
-> ˼·2
-
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(1)******
-
-̫���if else���IJ��ÿ������ǿ��Ի�һ�ָ����ŵ�д�����ô�����ÿ���
-
-```cpp
-class Solution {
-public:
- int arr[7] = {'I','V','X','L','C','D','M'};
- int arr1[13] = {1,4,5,9,10,40,50,90,100,400,500,900,1000};
- void f(int& num,int i,string& ans)
- {
- if(i % 2)
- {
- ans.push_back(arr[i / 4 * 2]);
- ans.push_back(arr[i / 2 + 1]);
- }
- else
- ans.push_back(arr[i / 2]);
- num -= arr1[i];
- }
- string intToRoman(int num) {
- string ans;
- while(num)
- {
- int i;
- for(i = 0;i < 13;++i)
- if(num < arr1[i])
- {
- f(num,i - 1,ans);
- break;
- }
- if(i == 13)
- f(num,i - 1,ans);
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0014._Longest_Common_Prefix.md b/docs/leetcode/cpp/0014._Longest_Common_Prefix.md
deleted file mode 100644
index d87e89f1d..000000000
--- a/docs/leetcode/cpp/0014._Longest_Common_Prefix.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# 14. Longest Common Prefix
-
-**�Ѷ�:Easy**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/longest-common-prefix/
-
-> ��������
-
-```
-Write a function to find the longest common prefix string amongst an array of strings.
-
-If there is no common prefix, return an empty string "".
-
-Example 1:
-
-Input: ["flower","flow","flight"]
-Output: "fl"
-Example 2:
-
-Input: ["dog","racecar","car"]
-Output: ""
-Explanation: There is no common prefix among the input strings.
-Note:
-
-All given inputs are in lowercase letters a-z.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n^2)******- �ռ临�Ӷ�: O(1)******
-
-���ǰ�����Ӵ���ֻ�б��������Ӵ������������Ӵ����ɣ�����Ҫע����ܴ��ڿ��ַ���
-
-```cpp
-class Solution {
-public:
- string longestCommonPrefix(vector& strs) {
- string temp;
- if(!strs.size() || !strs[0].length())
- return temp;
- int j = 0;
- while(1)
- {
- int i = 0;
- int ch = strs[0][j];
- for(;i < strs.size();++i)
- if(j >= strs[i].length() || strs[i][j] != ch)
- break;
- if(i != strs.size())
- break;
- temp.push_back(strs[0][j++]);
- }
- return temp;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0015._3sum.md b/docs/leetcode/cpp/0015._3sum.md
deleted file mode 100644
index bbcbb74e8..000000000
--- a/docs/leetcode/cpp/0015._3sum.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# 15. 3sum
-
-**难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-*https://leetcode.com/problems/3sum
-*
-> 内容描述
-
-```
-Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
-
-Note:
-
-The solution set must not contain duplicate triplets.
-```
-
-## 解题方案
-
-> 思路
-******- 时间复杂度: O(N ^ 2)******- 空间复杂度: O(N)******
-
-之前做过两个数之和等于某个数的题目,其实这题也差不多,三数之和等于0,那么我们只要让另外两个数之和等于第三个数的相反数即可,不过这里要注意会存在重复,所以要去重
-
-
-```cpp
-class Solution {
-public:
- vector> threeSum(vector& nums) {
- vector > ret;
- sort(nums.begin(),nums.end());
- for(int i = 0;i < nums.size();++i)
- {
- int t1 = i + 1,t2 = nums.size() - 1;
- if(i && nums[i] == nums[i - 1])
- continue;
- while(t1 < t2)
- if(nums[t1] + nums[t2] == -nums[i])
- {
- vector v;
- v.push_back(nums[i]);
- v.push_back(nums[t1]);
- v.push_back(nums[t2]);
- ret.push_back(v);
- ++t1;
- --t2;
- }
- else if(nums[t1] + nums[t2] < -nums[i])
- ++t1;
- else
- --t2;
- }
- auto pos = unique(ret.begin(),ret.end());
- ret.erase(pos,ret.end());
- return ret;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0016._3Sum_Closest.md b/docs/leetcode/cpp/0016._3Sum_Closest.md
deleted file mode 100644
index 496ac062c..000000000
--- a/docs/leetcode/cpp/0016._3Sum_Closest.md
+++ /dev/null
@@ -1,45 +0,0 @@
-## 16. 3Sum Closest
-
-难度:Medium
-
-## 内容
-
-> 原题链接:https://leetcode.com/problems/3sum-closest
-
-Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
-
-Example:
-
-```
-Given array nums = [-1, 2, 1, -4], and target = 1.
-
-The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
-```
-
-## 思路
-
-先排序,遍历第一个数,第二和第三个数通过双指针查找,转化为2sum closest的问题。如果遇到和等于target的三个数,直接返回target。
-
-## 代码
-
-```
-class Solution {
-public:
- int threeSumClosest(vector& nums, int target) {
- std::sort(nums.begin(), nums.end());
- int min_distance{INT_MAX}, sum{0}, cur_sum{0};
- for (auto it = nums.cbegin(); it != nums.cend(); ++it)
- for (auto left_idx = std::next(it), right_idx = std::prev(nums.cend()); left_idx < right_idx; cur_sum > target ? --right_idx : ++left_idx) {
- cur_sum = *it + *left_idx + *right_idx;
- auto cur_distance = std::abs(cur_sum - target);
- if (cur_sum == target)
- return target;
- else if (cur_distance < min_distance) {
- min_distance = cur_distance;
- sum = cur_sum;
- }
- }
- return sum;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0017._Letter_Combinations_of_a_Phone_Number.md b/docs/leetcode/cpp/0017._Letter_Combinations_of_a_Phone_Number.md
deleted file mode 100644
index d7a240e85..000000000
--- a/docs/leetcode/cpp/0017._Letter_Combinations_of_a_Phone_Number.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# 17. Letter Combinations of a Phone Number
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/letter-combinations-of-a-phone-number/
-
-> ��������
-
-```
-Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
-
-A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.
-
-
-
-Example:
-
-Input: "23"
-Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
-Note:
-
-Although the above answer is in lexicographical order, your answer could be in any order you want.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(2^n)******- �ռ临�Ӷ�: O(1)******
-
-�û��ݷ�ȥ�⣬�Ƚ������ַ���ת�����֡�����7��9֮����������ֶ���3����ĸ�������ÿ�����ִ�������ĸ���������û��ݷ�
-
-```cpp
-class Solution {
-public:
- void DFS(string& s,int i,vector& ans,string& temp)
- {
- if(i == s.length())
- {
- ans.push_back(temp);
- return;
- }
- int t = s[i] - '2';
- int ch_beg;
- if(t < 6)
- ch_beg = 'a' + t * 3;
- else
- ch_beg = 'a' + (t - 1) * 3 + 4;
- int en = 3;
- if(t == 5 || t == 7)
- en = 4;
- for(int j = 0;j < en;++j)
- {
- temp.push_back(ch_beg + j);
- DFS(s,i + 1,ans,temp);
- temp.pop_back();
- }
- }
- vector letterCombinations(string digits) {
- vector ans;
- if(!digits.size())
- return ans;
- string temp;
- DFS(digits,0,ans,temp);
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0018._4Sum.md b/docs/leetcode/cpp/0018._4Sum.md
deleted file mode 100644
index c3e0db2cb..000000000
--- a/docs/leetcode/cpp/0018._4Sum.md
+++ /dev/null
@@ -1,57 +0,0 @@
-## 18. 4Sum
-
-难度:Medium
-
-## 内容
-
-题目链接:https://leetcode.com/problems/4sum
-
-Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
-
-Note:
-
-The solution set must not contain duplicate quadruplets.
-
-Example:
-
-```
-Given array nums = [1, 0, -1, 0, -2, 2], and target = 0.
-
-A solution set is:
-[
- [-1, 0, 0, 1],
- [-2, -1, 1, 2],
- [-2, 0, 0, 2]
-]
-```
-
-## 思路
-
-思路和 3Sum 类似,多了一层for循环。为了避免重复,在存储结果的时候使用STL的set。
-
-## 代码
-
-```
-class Solution {
-public:
- vector> fourSum(vector& nums, int target) {
- if (nums.size() < 4) return vector>{};
- std::set> res;
- std::sort(nums.begin(), nums.end());
- for (size_t i = 0; i < nums.size() - 3; ++i)
- for (size_t j = i + 1; j < nums.size() - 2; ++j) {
- auto left_idx = j + 1; auto right_idx = nums.size() - 1;
- int sum = 0;
- for (left_idx = j + 1, right_idx = nums.size() - 1; left_idx < right_idx; sum > target ? --right_idx : ++left_idx) {
- sum = nums[i] + nums[j] + nums[left_idx] + nums[right_idx];
- if (sum == target) {
- vector res_single{nums[i], nums[j], nums[left_idx], nums[right_idx]};
- res.insert(res_single);
- }
-
- }
- }
- return vector>(res.begin(), res.end());
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0019._Remove_Nth_Node_From_End_of_List.md b/docs/leetcode/cpp/0019._Remove_Nth_Node_From_End_of_List.md
deleted file mode 100644
index 2c1fc990f..000000000
--- a/docs/leetcode/cpp/0019._Remove_Nth_Node_From_End_of_List.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# 19. Remove Nth Node From End of List
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/remove-nth-node-from-end-of-list/
-
-> ��������
-
-```
-Given a linked list, remove the n-th node from the end of list and return its head.
-
-Example:
-
-Given linked list: 1->2->3->4->5, and n = 2.
-
-After removing the second node from the end, the linked list becomes 1->2->3->5.
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(1)******
-
-ɾ��������n������Ϊ�˷�ֹ��������Ϊ1ʱ�Ŀ�ָ���쳣���Ȳ���һ������ͷ����������ֻҪ�ȱ���������������������ܳ��ȣ������ܳ��ȼ�ȥ n ��������Ҫɾ��������ǰһ����������ͷ�ij��ȣ�������ֻҪ�ø�ѭ���ҵ���ɾ��Ҫɾ���Ľڵ㼴�ɡ�
-
-```cpp
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- * int val;
- * ListNode *next;
- * ListNode(int x) : val(x), next(NULL) {}
- * };
- */
-class Solution {
-public:
- ListNode* removeNthFromEnd(ListNode* head, int n) {
- ListNode* current = head;
- int num = 0;
- while(current)
- {
- num++;
- current = current ->next;
- }
- ListNode* n1 = new ListNode(0);
- n1 ->next = head;
- current = n1;
- num -= n;
- while(num)
- {
- num--;
- current = current ->next;
- }
- ListNode* temp = current ->next;
- current ->next = temp ->next;
- return n1 ->next;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0020._Valid_Parentheses.md b/docs/leetcode/cpp/0020._Valid_Parentheses.md
deleted file mode 100644
index 102c66ca6..000000000
--- a/docs/leetcode/cpp/0020._Valid_Parentheses.md
+++ /dev/null
@@ -1,55 +0,0 @@
-## 20. Valid Parentheses
- **难度: Easy **
-## 刷题内容
-> 原题连接
-* https://leetcode-cn.com/problems/valid-parentheses/
-> 内容描述
-```
-Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
-
-An input string is valid if:
-
-Open brackets must be closed by the same type of brackets.
-Open brackets must be closed in the correct order.
-Note that an empty string is also considered valid.
-
-### Example
-1. Input: "()" -> Output: true
-
-2. Input: "()[]{}" -> Output: true
-
-3. Input: "(]" -> Output: false
-
-4. Input: "([)]" -> Output: false
-
-5. Input: "{[]}" -> Output: true
-```
-## 解题方案
-> 思路:
-```
-利用栈先进后出的先天优势,解决匹配问题。
-```
-```cpp
-bool isValid(string s) {
- stack stacks;
- for(int i=0;i难度:Easy **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/merge-two-sorted-lists
-*
-> 内容描述
-
-```
-Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
-
-Example:
-
-Input: 1->2->4, 1->3->4
-Output: 1->1->2->3->4->4
-```
-
-## 解题方案
-
-> 思路
-******- 时间复杂度: O(N + M)******- 空间复杂度: O(1)******
-
-首先这两个链表是排序好的,那么我们先定义一个空链表,再定义两个指针 i,j,按照顺序比较两个链表,如果 i 指向的数字小于 j指向的数字,i 指向的节点插入新链表中,i = i -> next,反之则操作 j。不过要注意其中一个链表可能会先结束,所以另一个未结束的链表直接插入新链表即可
-
-
-```cpp
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- * int val;
- * ListNode *next;
- * ListNode(int x) : val(x), next(NULL) {}
- * };
- */
-class Solution {
-public:
- ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
- ListNode* h1 = l1;
- ListNode* h2 = l2;
- ListNode* t = new ListNode(0);
- ListNode* curr = t;
- while (h1 && h2)
- {
- if (h1->val <= h2->val) {
- curr->next = h1;
- h1 = h1->next;
- }
- else{
- curr->next = h2;
- h2 = h2->next;
- }
- curr = curr->next;
- }
- while (h1)
- {
- curr->next = h1;
- h1 = h1->next;
- curr = curr->next;
- }
- while(h2)
- {
- curr->next = h2;
- h2 = h2->next;
- curr = curr->next;
- }
- ListNode* res = t->next;
- delete t;
- return res;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0022._Generate_Parentheses.md b/docs/leetcode/cpp/0022._Generate_Parentheses.md
deleted file mode 100644
index 469322c3a..000000000
--- a/docs/leetcode/cpp/0022._Generate_Parentheses.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# 22. Generate Parentheses
-
- **难度: Medium **
-
- ## 刷题内容
-
- > 原题连接
-
-* https://leetcode-cn.com/problems/generate-parentheses/
-
- > 内容描述
-
- ```
-给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。
-
-例如,给出 n = 3,生成结果为:
-
-[
- "((()))",
- "(()())",
- "(())()",
- "()(())",
- "()()()"
-]
- ```
-
-## 解题方案
-> 思路 1
-```
-回溯法
-```
-
-```cpp
-void dfs(int left, int total, string path, vector& ans){
- if(total==0&&left==0){
- ans.push_back(path);
- return ;
- }
- if(left>0)
- dfs(left-1, total-1, path+"(", ans);
- if(left generateParenthesis(int n) {
- vector ans;
- string path="";
- dfs(n, n*2, path, ans);
- return ans;
-}
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0023._Merge_K_Sorted_Lists.md b/docs/leetcode/cpp/0023._Merge_K_Sorted_Lists.md
deleted file mode 100644
index bddfa6bb4..000000000
--- a/docs/leetcode/cpp/0023._Merge_K_Sorted_Lists.md
+++ /dev/null
@@ -1,125 +0,0 @@
-# 23. merge k sorted lists
-
-**难度: Hard **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/merge-k-sorted-lists/
-
-> 内容描述
-
-```
-Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
-
-Example:
-
-Input:
-[
- 1->4->5,
- 1->3->4,
- 2->6
-]
-Output: 1->1->2->3->4->4->5->6
-```
-
-## 解题方案
-
-> 思路1
-******- 时间复杂度: O(Nlg(K))******- 空间复杂度: O(K)******
-
-这里运用最小堆,先去每个链表的第一个元素构建最小堆,由于链表都是已排序的,因此,每次堆的顶部都是最小的元素,这里用优先队列实现最小堆。
-
-
-```cpp
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- * int val;
- * ListNode *next;
- * ListNode(int x) : val(x), next(NULL) {}
- * };
- */
-class Solution {
-public:
- struct cmp
- {
- bool operator()(ListNode* a, ListNode* b) const
- {
- return a ->val > b ->val;
- }
- };
- ListNode* mergeKLists(vector& lists) {
- priority_queue,cmp> pq;
- ListNode* ret = nullptr;
- ListNode* current = nullptr;
- for(int i = 0;i < lists.size();++i)
- if(lists[i])
- pq.push(lists[i]);
- while(pq.size())
- {
- ListNode* temp = pq.top();
- pq.pop();
- if(!ret)
- ret = temp;
- else
- current ->next = temp;
- current = temp;
- if(temp ->next)
- pq.push(temp ->next);
- }
- return ret;
- }
-};
-```
-> 思路2
-******- 时间复杂度: O(Nlg(K))******- 空间复杂度: O(1)******
-
-这个思路用分治思想,我们可以通过归并排序解决,首先前面已经做过了两个有序链表的排序,我们可以把链表看做元素,只要对数组 Lists进行归并排序即可。
-
-```cpp
-class Solution {
-public:
- ListNode* merge(ListNode* list1, ListNode* list2) {
- ListNode head(0);
- ListNode* tail = &head;
- auto cur1 = list1;
- auto cur2 = list2;
- while (cur1 != nullptr && cur2 != nullptr) {
- if (cur1->val < cur2->val) {
- tail->next = cur1;
- tail = tail->next;
- cur1 = cur1->next;
- } else {
- tail->next = cur2;
- tail = tail->next;
- cur2 = cur2->next;
- }
- }
- auto cur = cur1 == nullptr ? cur2 : cur1;
- while (cur != nullptr) {
- tail->next = cur;
- tail = tail->next;
- cur = cur->next;
- }
- return head.next;
- }
- ListNode* mergeSort(vector& lists, int start, int end) {
- if (start > end) {
- return nullptr;
- }
- if (start == end) {
- return lists[start];
- }
- int mid = start + (end - start) / 2;
- auto list1 = mergeSort(lists, start, mid);
- auto list2 = mergeSort(lists, mid + 1, end);
- return merge(list1, list2);
- }
- ListNode* mergeKLists(vector& lists) {
- int n = lists.size();
- return mergeSort(lists, 0, n - 1);
- }
-};
-```
diff --git a/docs/leetcode/cpp/0024._Swap_Nodes_in_Pairs.md b/docs/leetcode/cpp/0024._Swap_Nodes_in_Pairs.md
deleted file mode 100644
index 4e812adab..000000000
--- a/docs/leetcode/cpp/0024._Swap_Nodes_in_Pairs.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# 24. Swap Nodes in Pairs
-
- **难度: Medium **
-
- ## 刷题内容
-
- > 原题连接
-
-* https://leetcode-cn.com/problems/swap-nodes-in-pairs/
-
- > 内容描述
-
- ```
-给定一个链表,两两交换其中相邻的节点,并返回交换后的链表。
-
-示例:
-
-给定 1->2->3->4, 你应该返回 2->1->4->3.
-说明:
-
-你的算法只能使用常数的额外空间。
-你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。
- ```
-
-## 解题方案
-> 思路 1
-```
-链表反转
-```
-
-```cpp
-ListNode* swapPairs(ListNode* head) {
- if(head==NULL||head->next==NULL)
- return head;
-
- ListNode* slow=head;
- ListNode* fast=head->next;
- ListNode* pre=new ListNode(0);
- ListNode* ans = pre;
- while(slow&&fast){
- slow->next = fast->next;
- fast->next = slow;
- pre->next = fast;
- if(slow->next==NULL||slow->next->next==NULL){
- break;
- }
- fast = slow->next->next;
- pre = slow;
- slow = slow->next;
- }
- return ans->next;
-}
-```
diff --git a/docs/leetcode/cpp/0025._Reverse_Nodes_In_K_Group.md b/docs/leetcode/cpp/0025._Reverse_Nodes_In_K_Group.md
deleted file mode 100644
index cdc28074c..000000000
--- a/docs/leetcode/cpp/0025._Reverse_Nodes_In_K_Group.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# 25.reverse nodes in k group
-
-**�Ѷ�Hard **
-
-## ˢ������
-
-> ԭ������
-
-* https://leetcode.com/problems/reverse-nodes-in-k-group/
-
-> ��������
-
-```
-Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
-
-k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
-
-Example:
-
-Given this linked list: 1->2->3->4->5
-
-For k = 2, you should return: 2->1->4->3->5
-
-For k = 3, you should return: 3->2->1->4->5
-
-Note:
-
-Only constant extra memory is allowed.
-You may not alter the values in the list's nodes, only nodes itself may be changed.
-```
-> ˼·1
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(1)******
-
-��Ŀ�������ѣ����������˵ݹ�ķ���ȥ�⣬����Ŀ�е�note��˵�����ж���Ĵ���ռ䣬���ݹ�����ɸ����Ŀռ䣬���ѵݹ�ij�ѭ�����������»��ǵݹ�İ汾
-
-```cpp
-/**
- * Definition for singly-linked list.
- * struct ListNode {
- * int val;
- * ListNode *next;
- * ListNode(int x) : val(x), next(NULL) {}
- * };
- */
-class Solution {
-public:
- ListNode* reverseKGroup(ListNode* head, int k) {
- if(!head)
- return head;
- ListNode* current = head,*next1,*pre = nullptr;
- int m = 1;
- while(m <= k && current)
- {
- next1 = current ->next;
- current ->next = pre;
- pre = current;
- current = next1;
- ++m;
- }
- if(m <= k)
- {
- while(current != head)
- {
- ListNode* temp = pre ->next;
- pre ->next = current;
- current = pre;
- pre = temp;
- }
- pre = head;
- }
- else
- head ->next = reverseKGroup(current,k);
- return pre;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0026._Remove_Duplicates_From_Sorted_Array.md b/docs/leetcode/cpp/0026._Remove_Duplicates_From_Sorted_Array.md
deleted file mode 100644
index 9dfffb6a3..000000000
--- a/docs/leetcode/cpp/0026._Remove_Duplicates_From_Sorted_Array.md
+++ /dev/null
@@ -1,71 +0,0 @@
-# 26.Remove Duplicates From Sorted Array
-
-**�Ѷ�Easy **
-
-## ˢ������
-
-> ԭ������
-
-* https://leetcode.com/problems/remove-duplicates-from-sorted-array/
-> ��������
-
-```
-Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.
-
-Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
-
-Example 1:
-
-Given nums = [1,1,2],
-
-Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively.
-
-It doesn't matter what you leave beyond the returned length.
-Example 2:
-
-Given nums = [0,0,1,1,1,2,2,3,3,4],
-
-Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively.
-
-It doesn't matter what values are set beyond the returned length.
-Clarification:
-
-Confused why the returned value is an integer but your answer is an array?
-
-Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.
-
-Internally you can think of this:
-
-// nums is passed in by reference. (i.e., without making a copy)
-int len = removeDuplicates(nums);
-
-// any modification to nums in your function would be known by the caller.
-// using the length returned by your function, it prints the first len elements.
-for (int i = 0; i < len; i++) {
- print(nums[i]);
-}
-```
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(1)******
-
-���������Ѿ�����õģ�����ֱ�ӱ������飬��һ��ָ�� i ָ��ʼ������һ�� j ָ��ڶ������� j ָ����������� i ָ���������```++i,++j```������ֻ```++j```
-
-```cpp
-class Solution {
-public:
- int removeDuplicates(vector& nums) {
- int j = 0;
- if(!nums.size())
- return 0;
- for(int i = 1;i < nums.size();)
- {
- while(nums[j] == nums[i] && i < nums.size())
- ++i;
- if(i == nums.size())
- break;
- swap(nums[++j],nums[i++]);
- }
- return j + 1;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0027._Remove_Element.md b/docs/leetcode/cpp/0027._Remove_Element.md
deleted file mode 100644
index 30694b543..000000000
--- a/docs/leetcode/cpp/0027._Remove_Element.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# 27.Remove Element
-
-**�Ѷ�Easy **
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/remove-element/
-
-> ��������
-
-```
-Given an array nums and a value val, remove all instances of that value in-place and return the new length.
-
-Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
-
-The order of elements can be changed. It doesn't matter what you leave beyond the new length.
-
-Example 1:
-
-Given nums = [3,2,2,3], val = 3,
-
-Your function should return length = 2, with the first two elements of nums being 2.
-
-It doesn't matter what you leave beyond the returned length.
-Example 2:
-
-Given nums = [0,1,2,2,3,0,4,2], val = 2,
-
-Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4.
-
-Note that the order of those five elements can be arbitrary.
-
-It doesn't matter what values are set beyond the returned length.
-Clarification:
-
-Confused why the returned value is an integer but your answer is an array?
-
-Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.
-
-Internally you can think of this:
-
-// nums is passed in by reference. (i.e., without making a copy)
-int len = removeElement(nums, val);
-
-// any modification to nums in your function would be known by the caller.
-// using the length returned by your function, it prints the first len elements.
-for (int i = 0; i < len; i++) {
- print(nums[i]);
-}
-```
-> ˼·
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(1)******
-
-���ǿ��Ա������飬�ѵ��� val �����ŵ�����ĺ�벿�־��С����ǿ�����˫ָ��ʵ�֡��� nums[i] != val ʱ��nums[j++] = nums[i]
-```cpp
-class Solution {
-public:
- int removeElement(vector& nums, int val) {
- int i ,count = 0,j = 0,numsSize = nums.size();
- for(i = 0;i < numsSize;i++)
- {
- if(nums[i] == val)
- {
- count++;
- }
- else
- nums[j++] = nums[i];
- }
- return numsSize - count;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0028._Implement_Strstr.md b/docs/leetcode/cpp/0028._Implement_Strstr.md
deleted file mode 100644
index b80786a76..000000000
--- a/docs/leetcode/cpp/0028._Implement_Strstr.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# 28.implement strstr
-
-**�Ѷ�Easy **
-
-## ˢ������
-
-> ԭ������
-
-* https://leetcode.com/problems/implement-strstr/
-> ��������
-
-```
-Implement strStr().
-
-Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
-
-Example 1:
-
-Input: haystack = "hello", needle = "ll"
-Output: 2
-Example 2:
-
-Input: haystack = "aaaaa", needle = "bba"
-Output: -1
-Clarification:
-
-What should we return when needle is an empty string? This is a great question to ask during an interview.
-
-For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C's strstr() and Java's indexOf().
-```
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(1)******
-
-����ֱ�ӱ��� haystack ��ƥ�䵽�� needle ��һ���ַ����ʱ���ͱ��� needle�������Ƚ��ַ���
-
-```cpp
-class Solution {
-public:
- int strStr(string haystack, string needle) {
- int j = 0,i = 0,index= 0;
- while(i < haystack.size() && j < needle.size())
- {
- if(haystack[i] == needle[j])
- {
- if(!j)
- index = i;
- j++;
- i++;
- }
- else
- {
- i = ++index;
- j = 0;
- }
- }
- if(j == needle.size())
- return index;
- return -1;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0029._Divide_Two_Integers.md b/docs/leetcode/cpp/0029._Divide_Two_Integers.md
deleted file mode 100644
index 432bb349a..000000000
--- a/docs/leetcode/cpp/0029._Divide_Two_Integers.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# 29.divide two integers
-
-**�Ѷ�Medium **
-
-## ˢ������
-
-> ԭ������
-
-* https://leetcode.com/problems/divide-two-integers/
-> ��������
-
-```
-Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.
-
-Return the quotient after dividing dividend by divisor.
-
-The integer division should truncate toward zero.
-
-Example 1:
-
-Input: dividend = 10, divisor = 3
-Output: 3
-Example 2:
-
-Input: dividend = 7, divisor = -3
-Output: -2
-Note:
-
-Both dividend and divisor will be 32-bit signed integers.
-The divisor will never be 0.
-Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [?231, 231 ? 1]. For the purpose of this problem, assume that your function returns 231 ? 1 when the division result overflows.
-
-```
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(1)******
-
-�������ֱ���ñ����ķ����϶���ʱ�������������˿ռ任ʱ�䣬�������� int ���Ϊ2^31 - 1 ��������Ĵ�СҲ�ǹ̶��ġ����������ñ��������ȶ���һ��res = 0��ÿ�ζ����� res += divisor * 2^n ֱ������dividend �������ٴ� res = divisor * 2^(n-1)��ʼ��ֱ��ij��res + divisor > dividend
-
-
-```cpp
-class Solution {
-public:
- int divide(int dividend, int divisor) {
- if(!dividend)
- return 0;
- long long arr[33];
- arr[0] = 1;
- for(int i = 1;i < 33;++i)
- arr[i] = arr[i - 1] * 2;
- long long temp1 = dividend,temp2 = divisor;
- if(temp1 < 0)
- temp1 *= -1;
- if(temp2 < 0)
- temp2 *= -1;
- long long res,pre = 0,ret = 0;
- int count1 = 0;
- while(1)
- {
- res = pre + arr[count1] * temp2;
- if(res > temp1)
- {
- if(!count1)
- break;
- pre = pre + arr[count1 - 1] * temp2;
- ret += arr[count1 - 1];
- count1 = 0;
- }
- else
- count1++;
- }
- if(dividend < 0)
- ret *= -1;
- if(divisor < 0)
- ret *= -1;
- if(ret == 2147483648)
- return ret - 1;
- return ret;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0030._Substring_With_Concatenation_Of_All_Words.md b/docs/leetcode/cpp/0030._Substring_With_Concatenation_Of_All_Words.md
deleted file mode 100644
index 52efa1f10..000000000
--- a/docs/leetcode/cpp/0030._Substring_With_Concatenation_Of_All_Words.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# 30.substring with concatenation of all words
-
-**难度Hard **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/substring-with-concatenation-of-all-words/
-
-> 内容描述
-
-```
-You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.
-
-Example 1:
-
-Input:
- s = "barfoothefoobarman",
- words = ["foo","bar"]
-Output: [0,9]
-Explanation: Substrings starting at index 0 and 9 are "barfoor" and "foobar" respectively.
-The output order does not matter, returning [9,0] is fine too.
-Example 2:
-
-Input:
- s = "wordgoodstudentgoodword",
- words = ["word","student"]
-Output: []
-
-```
-> 思路
-******- 时间复杂度: O(mlgn)******- 空间复杂度: O(m+n)******
-
-这题可以两个 map 来解决,第一个 map 中存放了 words 中的所有单词和出现的次数,接下来遍历字符串,固定区间的大小为 words 的长度,存入另一个map,两个 map 相等就放入返回数组中
-
-```cpp
-class Solution {
-public:
- vector findSubstring(string s, vector& words) {
- vector ans;
- if(!s.length() || !words.size())
- return ans;
- unordered_map m1;
- int len = words.size(),wl = words[0].length(),sl = s.length();
- for(int i = 0;i < words.size();++i)
- m1[words[i]]++;
- int count1 = 0,reLen = wl * len,left = 0;
- for(int i = 0;i < sl - wl * len + 1;++i)
- {
- unordered_map m2;
- for(int j = 0,left = i;j < len;j ++)
- {
- string temp = s.substr(left,wl);
- left += wl;
- m2[temp]++;
- }
- if(m2 == m1)
- ans.push_back(i);
- }
- return ans;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0031._Next_Permutatio.md b/docs/leetcode/cpp/0031._Next_Permutatio.md
deleted file mode 100644
index 5266def01..000000000
--- a/docs/leetcode/cpp/0031._Next_Permutatio.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# 31.Next Permutatio
-
-**难度Medium **
-
-## 刷题内容
-> 原题连接
-
-* https://leetcode.com/problems/next-permutation/
-
-> 内容描述
-
-```
-Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
-
-If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
-
-The replacement must be in-place and use only constant extra memory.
-
-Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
-
-1,2,3 → 1,3,2
-3,2,1 → 1,2,3
-1,1,5 → 1,5,1
-```
-> 思路
-******- 时间复杂度: O(n)******- 空间复杂度: O(1)******
-
-我们可以用两个指针表示需要交换的两个数,遍历数组。这题的最坏的情况下,数组降序排列,排序算法的复杂度也是O(n)。
-
-```cpp
-class Solution {
-public:
- void nextPermutation(vector& nums) {
- int n1 = 0,n2 = 0;
- for(int i = 1;i < nums.size();++i)
- if(nums[i] > nums[n2])
- {
- n1 = n2;
- n2 = i;
- }
- else if((nums[i] < nums[n2] && nums[i] > nums[n1]) || nums[i] == nums[n2])
- n2 = i;
- else if(nums[i] <= nums[n1])
- {
- int j = i;
- for(;j < nums.size() - 1;++j)
- if(nums[j + 1] > nums[j])
- {
- n1 = j;
- n2 = j + 1;
- break;
- }
- i = j + 1;
- }
- if(n1 == n2)
- sort(nums.begin(),nums.end());
- else
- {
- swap(nums[n1],nums[n2]);
- sort(nums.begin() + n1 + 1,nums.end());
- }
- }
-};
-```
diff --git a/docs/leetcode/cpp/0032._Longest_Valid_Parentheses.md b/docs/leetcode/cpp/0032._Longest_Valid_Parentheses.md
deleted file mode 100644
index dfa13eae0..000000000
--- a/docs/leetcode/cpp/0032._Longest_Valid_Parentheses.md
+++ /dev/null
@@ -1,57 +0,0 @@
-# 32. Longest Valid Parentheses
-
-**�Ѷ�:Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/longest-valid-parentheses/
-
-> ��������
-
-```
-Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
-
-Example 1:
-
-Input: "(()"
-Output: 2
-Explanation: The longest valid parentheses substring is "()"
-Example 2:
-
-Input: ")()())"
-Output: 4
-Explanation: The longest valid parentheses substring is "()()"
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(n)******
-
-��DP�ķ��������⡣������һ��ջȥ����������ߵIJ��֣���'('��λ�ã�ֱ��������һ��')'ʱ���ͼ�¼ջ����'('λ�ã����������ǾͿ���д��״̬ת�Ʒ��̡���������dp[i]�����ַ����е�i������������Զ��λ�á�����һ������')'ʱ��dp[i] = ջ��'('��λ�á����ڿ��Դ������������ţ���dp[dp[i] - 1]���ڣ���dp[i] = dp[dp[i] - 1]����Ҫע��߽缴�ɡ�
-
-```cpp
-class Solution {
-public:
- int longestValidParentheses(string s) {
- int len = s.length();
- if(!len)
- return 0;
- int dp[len];
- memset(dp,-1,sizeof(dp));
- int ans = 0;
- vector v;
- for(int i = 0;i < len;++i)
- if(s[i] == '(')
- v.push_back(i);
- else if(s[i] == ')' && v.size())
- {
- dp[i] = v[v.size() - 1];
- if(dp[i] && dp[dp[i] - 1] >= 0)
- dp[i] = dp[dp[i] - 1];
- ans = max(ans,i - dp[i] + 1);
- v.pop_back();
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0033._Search_in_Rotated_Sorted_Array.md b/docs/leetcode/cpp/0033._Search_in_Rotated_Sorted_Array.md
deleted file mode 100644
index 275307b05..000000000
--- a/docs/leetcode/cpp/0033._Search_in_Rotated_Sorted_Array.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# 033. Search in Rotated Sorted Array
-
-**难度Medium**
-
-## 刷题内容
-> 原题连接
-
-* https://leetcode.com/problems/search-in-rotated-sorted-array/
-
-> 内容描述
-
-```
-Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
-
-(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
-
-You are given a target value to search. If found in the array return its index, otherwise return -1.
-
-You may assume no duplicate exists in the array.
-
-Your algorithm's runtime complexity must be in the order of O(log n).
-
-Example 1:
-
-Input: nums = [4,5,6,7,0,1,2], target = 0
-Output: 4
-Example 2:
-
-Input: nums = [4,5,6,7,0,1,2], target = 3
-Output: -1
-```
-> 思路1
-******- 时间复杂度: O(n)******- 空间复杂度: O(1)******
-
-第一个方法是直接遍历数组,找到返回数组下标,找不到就返回-1
-
-```cpp
-class Solution {
-public:
- int search(vector& nums, int target) {
- for(int i = 0;i < nums.size();++i)
- if(nums[i] == target)
- return i;
- return -1;
- }
-};
-```
-> 思路2
-******- 时间复杂度: O(lgn)*****- 空间复杂度: O(1)******
-
-第二个方法是用二分法找到旋转轴,再用二分法找到目标数
-```cpp
-class Solution {
-public:
- int search(vector& nums, int target) {
- int i = 0,j = nums.size() - 1;
- if(!nums.size())
- return -1;
- while(i < j - 1)
- {
- int mid = (i + j) / 2;
- if(nums[i] < nums[mid])
- i = mid;
- else
- j = mid;
- //cout << i << j << endl;
- }
- if(nums[i] <= nums[j])
- j = i;
- //cout << j;
- auto pos = lower_bound(nums.begin(),nums.begin() + j,target);
- if(pos != nums.end() && (*pos) == target)
- return pos - nums.begin();
- pos = lower_bound(nums.begin() + j,nums.end(),target);
- if(pos != nums.end() && (*pos) == target)
- return pos - nums.begin();
- return -1;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0034._Find_First_and_Last_Position_of_Element_in_Sorted_Array.md b/docs/leetcode/cpp/0034._Find_First_and_Last_Position_of_Element_in_Sorted_Array.md
deleted file mode 100644
index 27a9b7bf7..000000000
--- a/docs/leetcode/cpp/0034._Find_First_and_Last_Position_of_Element_in_Sorted_Array.md
+++ /dev/null
@@ -1,105 +0,0 @@
-# 34. Find First and Last Position of Element in Sorted Array
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
-
-> ��������
-
-```
-Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.
-
-Your algorithm's runtime complexity must be in the order of O(log n).
-
-If the target is not found in the array, return [-1, -1].
-
-Example 1:
-
-Input: nums = [5,7,7,8,8,10], target = 8
-Output: [3,4]
-Example 2:
-
-Input: nums = [5,7,7,8,8,10], target = 6
-Output: [-1,-1]
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(lgn)******- �ռ临�Ӷ�: O(1)******
-
-���͵Ķ����������Ȳ���Ŀ���������Ƿ���target���ڷֱ�����ҵ�һ�����ֵ�target�����һ��target��
-
-```cpp
-class Solution {
-public:
- vector searchRange(vector& nums, int target) {
- int l = 0,r = nums.size();
- vector ans = {-1,-1};
- int mid = -1;
- while(l < r)
- {
- mid = (r + l) / 2;
- if(nums[mid] < target)
- l = mid + 1;
- else if(nums[mid] > target)
- r = mid;
- else
- break;
- }
- if(mid == -1 || nums[mid] != target)
- return ans;
- int mid1 = l = mid;
- r = nums.size();
- while(l < r)
- {
- mid = (r + l) / 2;
- if(mid == nums.size())
- break;
- if(nums[mid] > target)
- r = mid;
- else
- l = mid + 1;
- }
- if(nums[mid] > target)
- mid--;
- ans[1] = mid;
- l = 0;
- r = mid1 + 1;
- while(l < r)
- {
- mid = (r + l) / 2;
- if(nums[mid] < target)
- l = mid + 1;
- else
- r = mid;
- }
- if(nums[mid] < target)
- mid++;
- ans[0] = mid;
- return ans;
- }
-};
-```
-
-> ˼·2
-******- ʱ�临�Ӷ�: O(lgn)******- �ռ临�Ӷ�: O(1)******
-
-���������õ���c++���������������lower_bound��upper_bound
-
-```cpp
-class Solution {
-public:
- vector searchRange(vector& nums, int target) {
- auto pos1 = lower_bound(nums.begin(),nums.end(),target);
- vector ans = {-1,-1};
- if(pos1 == nums.end() || (*pos1) != target)
- return ans;
- ans[0] = pos1 - nums.begin();
- auto pos2 = upper_bound(nums.begin(),nums.end(),target);
- ans[1] = pos2 - nums.begin() - 1;
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0035._Search_Insert_Position.md b/docs/leetcode/cpp/0035._Search_Insert_Position.md
deleted file mode 100644
index 03ee90eab..000000000
--- a/docs/leetcode/cpp/0035._Search_Insert_Position.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# 35.search insert position
-
-**难度:Easy **
-
-## 刷题内容
-
-> 原题连接
-
-*https://leetcode.com/problems/search-insert-position/
-*
-> 内容描述
-
-```
-Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
-
-You may assume no duplicates in the array.
-```
-> 思路1
-******- 时间复杂度: O(lgN)******- 空间复杂度: O(1)******
-
-由于数组是已经排序好的,这就是一个很典型的二分法
-
-```cpp
-class Solution {
-public:
- int searchInsert(vector& nums, int target) {
- int first = 0,last = nums.size() - 1;
- while(last > (first + 1))
- {
- int medium = (last + first) / 2;
- if(nums[medium] == target)
- return medium;
- else if(nums[medium] < target)
- first = medium;
- else
- last = medium;
- }
- if(target > nums[last])
- return last + 1;
- else if((target < nums[first]) || (target == nums[first]))
- return first;
- else
- return last;
- }
-};
-```
-> 思路2
-******- 时间复杂度: O(lgN)******- 空间复杂度: O(1)******
-
-其实这个思路也是二分法,只不过c++中已经给我们封装好了lower_bound,我们直接调用即可
-代码看上去也简洁很多
-```cpp
-class Solution {
-public:
- int searchInsert(vector& nums, int target) {
- auto pos = lower_bound(nums.begin(),nums.end(),target);
- return pos - nums.begin();
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0036._Valid_Sudoku.md b/docs/leetcode/cpp/0036._Valid_Sudoku.md
deleted file mode 100644
index 48d5cdaac..000000000
--- a/docs/leetcode/cpp/0036._Valid_Sudoku.md
+++ /dev/null
@@ -1,90 +0,0 @@
-# 36. Valid Sudoku
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/valid-sudoku/
-
-> ��������
-
-```
-Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
-
-Each row must contain the digits 1-9 without repetition.
-Each column must contain the digits 1-9 without repetition.
-Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without repetition.
-A partially filled sudoku which is valid.
-
-The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
-Example 1:
-
-Input:
-[
- ["5","3",".",".","7",".",".",".","."],
- ["6",".",".","1","9","5",".",".","."],
- [".","9","8",".",".",".",".","6","."],
- ["8",".",".",".","6",".",".",".","3"],
- ["4",".",".","8",".","3",".",".","1"],
- ["7",".",".",".","2",".",".",".","6"],
- [".","6",".",".",".",".","2","8","."],
- [".",".",".","4","1","9",".",".","5"],
- [".",".",".",".","8",".",".","7","9"]
-]
-Output: true
-Example 2:
-
-Input:
-[
- ["8","3",".",".","7",".",".",".","."],
- ["6",".",".","1","9","5",".",".","."],
- [".","9","8",".",".",".",".","6","."],
- ["8",".",".",".","6",".",".",".","3"],
- ["4",".",".","8",".","3",".",".","1"],
- ["7",".",".",".","2",".",".",".","6"],
- [".","6",".",".",".",".","2","8","."],
- [".",".",".","4","1","9",".",".","5"],
- [".",".",".",".","8",".",".","7","9"]
-]
-Output: false
-Explanation: Same as Example 1, except with the 5 in the top left corner being
- modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
-Note:
-
-A Sudoku board (partially filled) could be valid but is not necessarily solvable.
-Only the filled cells need to be validated according to the mentioned rules.
-The given board contain only digits 1-9 and the character '.'.
-The given board size is always 9x9.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n^2)******- �ռ临�Ӷ�: O(1)******
-
-����board��9x9�ģ�ʵ�ʵ�ʱ�临�Ӷ�Ҳ��9x9�ġ���������ֻҪ�ֱ��ж�ÿ��ÿ�к�ÿ9��С�������Ƿ����ظ��������ɡ��ѶȲ���
-
-
-```cpp
-class Solution {
-public:
- bool isValidSudoku(vector>& board) {
- int arr[9][9];
- int arr1[9][9];
- int arr2[9][9];
- memset(arr,0,sizeof(arr));
- memset(arr2,0,sizeof(arr1));
- memset(arr1,0,sizeof(arr1));
- for(int i = 0;i < 9;++i)
- for(int j = 0;j < 9;++j)
- if(board[i][j] != '.')
- {
- if(arr[i][board[i][j] - '1'] || arr1[j][board[i][j] -'1'] || arr2[3 * (i / 3) + (j / 3)][board[i][j] -'1'])
- return 0;
- arr[i][board[i][j] - '1'] = 1;
- arr1[j][board[i][j] -'1'] = 1;
- arr2[3 * (i / 3) + (j / 3)][board[i][j] -'1'] = 1;
- }
- return 1;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0038._Count_and_Say.md b/docs/leetcode/cpp/0038._Count_and_Say.md
deleted file mode 100644
index 3051bf77c..000000000
--- a/docs/leetcode/cpp/0038._Count_and_Say.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# 38. Count and Say
-
-**�Ѷ�:Easy**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/count-and-say/
-
-> ��������
-
-```
-The count-and-say sequence is the sequence of integers with the first five terms as following:
-
-1. 1
-2. 11
-3. 21
-4. 1211
-5. 111221
-1 is read off as "one 1" or 11.
-11 is read off as "two 1s" or 21.
-21 is read off as "one 2, then one 1" or 1211.
-
-Given an integer n where 1 �� n �� 30, generate the nth term of the count-and-say sequence.
-
-Note: Each term of the sequence of integers will be represented as a string.
-
-
-Example 1:
-
-Input: 1
-Output: "1"
-Example 2:
-
-Input: 4
-Output: "1211"
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(1)******
-
-����ҪŪ�����Ŀ����˼n == 1ʱ����1��������һ��1���� one 1��n == 2ʱ���ǡ�11����������2��1���� two 1��n == 3ʱ���ǡ�21��������1��2��1��1���� one 2 one 1��n == 4ʱ���ǡ�1211���������������ƣ�����д��ѭ��ģ������IJ������ɡ�
-
-```cpp
-class Solution {
-public:
- string countAndSay(int n) {
- string str;
- str.push_back('0' + 1);
- n--;
- while(n)
- {
- string temp;
- for(int i = 0;i < str.length();)
- {
- int j = 0;
- while(i + j < str.length() && str[i] == str[j + i])
- ++j;
- temp.push_back('0' + j);
- temp.push_back(str[i]);
- i += j;
- }
- --n;
- str = temp;
- }
- return str;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0039._Combination_Sum.md b/docs/leetcode/cpp/0039._Combination_Sum.md
deleted file mode 100644
index 37226b709..000000000
--- a/docs/leetcode/cpp/0039._Combination_Sum.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# 39. Combination Sum
-
- **难度: Middle **
-
- ## 刷题内容
-
- > 原题连接
-
-* https://leetcode-cn.com/problems/combination-sum/
-
- > 内容描述
-
- ```
-给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。
-
-candidates 中的数字可以无限制重复被选取。
-
-说明:
-
-所有数字(包括 target)都是正整数。
-解集不能包含重复的组合。
-示例 1:
-
-输入: candidates = [2,3,6,7], target = 7,
-所求解集为:
-[
- [7],
- [2,2,3]
-]
-示例 2:
-
-输入: candidates = [2,3,5], target = 8,
-所求解集为:
-[
- [2,2,2,2],
- [2,3,3],
- [3,5]
-]
- ```
-
-## 解题方案
-> 思路 1
-```
-回溯
-```
-
-```cpp
-void dfs(vector& candidates, int target, int index, vector& path, vector>& ans){
- if(target<0)
- return ;
- if(target == 0){
- ans.push_back(path);
- return ;
- }
- for(int i=index;i> combinationSum(vector& candidates, int target) {
- sort(candidates.begin(), candidates.end());
- vector> ans;
- vector path;
- dfs(candidates, target, 0, path, ans);
- return ans;
-}
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0040._Combination_Sum_II.md b/docs/leetcode/cpp/0040._Combination_Sum_II.md
deleted file mode 100644
index f837be356..000000000
--- a/docs/leetcode/cpp/0040._Combination_Sum_II.md
+++ /dev/null
@@ -1,70 +0,0 @@
-# 40. Combination Sum II
-
- **难度: Medium **
-
- ## 刷题内容
-
- > 原题连接
-
-* https://leetcode-cn.com/problems/combination-sum-ii/
-
- > 内容描述
-
- ```
-给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。
-
-candidates 中的每个数字在每个组合中只能使用一次。
-
-说明:
-
-所有数字(包括目标数)都是正整数。
-解集不能包含重复的组合。
-示例 1:
-
-输入: candidates = [10,1,2,7,6,1,5], target = 8,
-所求解集为:
-[
- [1, 7],
- [1, 2, 5],
- [2, 6],
- [1, 1, 6]
-]
-示例 2:
-
-输入: candidates = [2,5,2,1,2], target = 5,
-所求解集为:
-[
- [1,2,2],
- [5]
-]
- ```
-
-## 解题方案
-> 思路 1
-```
-回溯
-```
-
-```cpp
-void dfs(vector& candidates, int target, int index, vector& path, vector>& ans){
- if(target<0)
- return ;
- if(target == 0){
- ans.push_back(path);
- return ;
- }
- for(int i=index;i index && candidates[i] == candidates[i - 1]) continue;
- path.push_back(candidates[i]);
- dfs(candidates, target-candidates[i], i+1, path, ans);
- path.pop_back();
- }
-}
-vector> combinationSum2(vector& candidates, int target) {
- vector> ans;
- vector path;
- sort(candidates.begin(), candidates.end());
- dfs(candidates, target, 0, path, ans);
- return ans;
-}
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0041._First_Missing_Positive.md b/docs/leetcode/cpp/0041._First_Missing_Positive.md
deleted file mode 100644
index 8c3b40a76..000000000
--- a/docs/leetcode/cpp/0041._First_Missing_Positive.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# 041.First Missing Positive
-
-**�Ѷ�Hard **
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/first-missing-positive/
-
-> ��������
-
-```
-Given an unsorted integer array, find the smallest missing positive integer.
-
-Example 1:
-
-Input: [1,2,0]
-Output: 3
-Example 2:
-
-Input: [3,4,-1,1]
-Output: 2
-Example 3:
-
-Input: [7,8,9,11,12]
-Output: 1
-```
-> ˼·
-******- ʱ�临�Ӷ�: O(n)******- �ռ临�Ӷ�: O(1)******
-
-�տ�ʼ��Ŀ����˼������ˣ�֮�������AC�ˡ���ʵ�����������������������Ĵ���ռ䣬Ӧ�û������뵽��ֱ�� hash �����У��������ǿ��Ա������飬���������1����������ĵ�һ������1����2���ڣ���������ĵڶ���λ�ӣ���������
-
-```cpp
-class Solution {
-public:
- int firstMissingPositive(vector& nums) {
- if(!nums.size())
- return 1;
- for(int i = 0;i < nums.size();)
- {
- if(nums[i] < nums.size() && nums[i] != nums[nums[i] - 1])
- swap(nums[i],nums[nums[i] - 1]);
- else
- ++i;
- }
- for(int i = 0;i < nums.size();++i)
- if(nums[i] != i + 1)
- return i + 1;
- return nums.size() + 1;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0042._Trapping_Rain_Water.md b/docs/leetcode/cpp/0042._Trapping_Rain_Water.md
deleted file mode 100644
index 55cb1d390..000000000
--- a/docs/leetcode/cpp/0042._Trapping_Rain_Water.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# 42. Trapping Rain Water
-
-**�Ѷ�Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/trapping-rain-water/
-
-> ��������
-
-```
-Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
-
-Example:
-
-Input: [0,1,0,2,1,0,1,3,2,1,2,1]
-Output: 6
-```
-
-��¼ l = 0��������������飬��� height[i] < height[l],��˵����λ������ˮ����¼����ˮ���������� height[i] >= height[l]����˵��[i,l]�������ڿ��Ի�ˮ��Ȼ���ȥ����ˮ��������ǻ�ˮ�����������������֮����� l != height.size() - 1������������飬�����������衣
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(1)******
-
-```cpp
-class Solution {
-public:
- int trap(vector& height) {
- int l = 0,sum1 = 0,water = 0,i;
- for(i = 1;i < height.size();++i)
- if(height[i] >= height[l])
- {
- water = water + height[l] * (i - l - 1) - sum1;
- l = i;
- sum1 = 0;
- }
- else
- sum1 += height[i];
- if(l != (height.size() - 1))
- {
- int temp = l;
- sum1 = 0;
- for(i = height.size() - 2,l = height.size() - 1;i >= temp;--i)
- if(height[i] >= height[l])
- {
- water = water + height[l] * (l- i - 1) - sum1;
- l = i;
- sum1 = 0;
- }
- else
- sum1 += height[i];
- }
- return water;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0043._Multiply_Strings.md b/docs/leetcode/cpp/0043._Multiply_Strings.md
deleted file mode 100644
index 402275e25..000000000
--- a/docs/leetcode/cpp/0043._Multiply_Strings.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# 43. Multiply Strings
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/multiply-strings/
-
-> ��������
-
-```
-Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
-
-Example 1:
-
-Input: num1 = "2", num2 = "3"
-Output: "6"
-Example 2:
-
-Input: num1 = "123", num2 = "456"
-Output: "56088"
-Note:
-
-The length of both num1 and num2 is < 110.
-Both num1 and num2 contain only digits 0-9.
-Both num1 and num2 do not contain any leading zero, except the number 0 itself.
-You must not use any built-in BigInteger library or convert the inputs to integer directly.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n^2)******- �ռ临�Ӷ�: O(1)******
-
-������������ֱȽϴ���long long�����ֵ����˲���ת�����֣�������������ģ���������ֵij˷�����ÿһλ��¼��һ���ַ����С�
-
-```cpp
-class Solution {
-public:
- string multiply(string num1, string num2) {
- string ans;
- int d[120][120];
- memset(d,0,sizeof(d));
- for(int i = num2.size() - 1;i >= 0;--i)
- {
- int count1 = 0;
- for(int j = num1.size()- 1;j >= 0;--j)
- {
- int pro_ans = (num1[j] - '0') * (num2[i] - '0');
- d[num2.size() - 1 - i][num1.size() - j - 1] = pro_ans % 10 + count1;
- count1 = pro_ans / 10;
- if(d[num2.size() - 1 - i][num1.size() - j - 1] >= 10)
- {
- count1++;
- d[num2.size() - 1 - i][num1.size() - j - 1] %= 10;
- }
- }
- d[num2.size() - 1 - i][num1.size()] = count1;
- }
- int count1 = 0;
- for(int j = 0;j < num1.size() + num2.size();++j)
- {
- for(int i = 0;i <= num2.size();++i)
- if(j - i >= 0 && j - i <= num1.size())
- count1 += d[i][j - i];
- ans.push_back(count1 % 10 + '0');
- count1 /= 10;
- }
- while(ans.length() > 1 && ans[ans.length() - 1] == '0')
- ans.pop_back();
- reverse(ans.begin(),ans.end());
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0044._Wildcard_Matching.md b/docs/leetcode/cpp/0044._Wildcard_Matching.md
deleted file mode 100644
index 86a0eecbc..000000000
--- a/docs/leetcode/cpp/0044._Wildcard_Matching.md
+++ /dev/null
@@ -1,98 +0,0 @@
-# 44. Wildcard Matching
-
-**�Ѷ�:Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/wildcard-matching/
-
-> ��������
-
-```
-Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.
-
-'?' Matches any single character.
-'*' Matches any sequence of characters (including the empty sequence).
-The matching should cover the entire input string (not partial).
-
-Note:
-
-s could be empty and contains only lowercase letters a-z.
-p could be empty and contains only lowercase letters a-z, and characters like ? or *.
-Example 1:
-
-Input:
-s = "aa"
-p = "a"
-Output: false
-Explanation: "a" does not match the entire string "aa".
-Example 2:
-
-Input:
-s = "aa"
-p = "*"
-Output: true
-Explanation: '*' matches any sequence.
-Example 3:
-
-Input:
-s = "cb"
-p = "?a"
-Output: false
-Explanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.
-Example 4:
-
-Input:
-s = "adceb"
-p = "*a*b"
-Output: true
-Explanation: The first '*' matches the empty sequence, while the second '*' matches the substring "dce".
-Example 5:
-
-Input:
-s = "acdcb"
-p = "a*c?b"
-Output: false
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(n^2)******- �ռ临�Ӷ�: O(n^2)******
-
-�տ�ʼ����ʱ����Ϊ��һ����ģ���⣬��������ʱ��ŷ��ֿ�����DP����ʹ��DPʱ���ҵ�״̬ת�Ʒ��̡��������Ƕ�������dp[i][j]��ʾ���ַ��� p �е� i - 1����ĸ֮ǰ���ַ������ַ��� s �еĵ� j - 1����ĸ֮ǰ���Ӵ�ƥ�䣬���ǾͿ���д����Ӧ��״̬ת�Ʒ��̵�p[i] == '?'����p[i] == s[j]ʱ��dp[i + 1][j + 1] = dp[i][j],��p[i] == '*'ʱ��j < p.length(),����dp[i + 1][j + 1] = dp[i][j],����dp[i + 1][j] = dp[i][j],���dp[p.length()][s.length() - 1]
-
-```cpp
-class Solution {
-public:
- bool isMatch(string s, string p) {
- if(!p.length())
- return !s.length();
- s.push_back(' ');
- int dp[p.length() + 1][s.length() + 1];
- for(int i =0;i <= p.length();++i)
- for(int j = 0;j <= s.length();++j)
- dp[i][j] = 0;
-
- int count1 = 1;
- dp[0][0] = 1;
- for(int i = 0;i < p.length();++i)
- {
- for(int j = 0;j < s.length();++j)
- if(p[i] == '?' || p[i] == s[j])
- dp[i + 1][j + 1] = dp[i][j];
- else if(p[i] == '*' && dp[i][j])
- {
- dp[i + 1][j + 1] = 1;
- dp[i + 1][j] = 1;
- ++j;
- while(j < s.length())
- {
- dp[i + 1][j + 1] = 1;
- ++j;
- }
- }
- }
- return dp[p.length()][s.length() - 1];
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0045._Jump_Game_II.md b/docs/leetcode/cpp/0045._Jump_Game_II.md
deleted file mode 100644
index adbc9cfdd..000000000
--- a/docs/leetcode/cpp/0045._Jump_Game_II.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# 045. Jump Game II
-
-**�Ѷ�Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/jump-game-ii/
-
-> ��������
-
-```
-Given an array of non-negative integers, you are initially positioned at the first index of the array.
-
-Each element in the array represents your maximum jump length at that position.
-
-Your goal is to reach the last index in the minimum number of jumps.
-
-Example:
-
-Input: [2,3,1,1,4]
-Output: 2
-Explanation: The minimum number of jumps to reach the last index is 2.
- Jump 1 step from index 0 to 1, then 3 steps to the last index.
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(n)*****- �ռ临�Ӷ�: O(1)******
-
-�տ�ʼ�뵽ʹ�ö�̬�滮��ʱ�临�Ӷ�ΪO(n)������TLE�ˣ���ʵ������O(n)��ʱ�临�Ӷ�����ɵġ��������飬ÿ�ζ��ߵ���nums[i]�ķ�Χ�����ߵ�����Զ�ľ��롣��¼ans��
-```cpp
-class Solution {
-public:
- int jump(vector& nums) {
- int i = 0,length = nums.size(),next = nums[0],ans = 0;
- if(length < 2)
- return 0;
- while(i < length)
- {
- ++ans;
- if(next >= length - 1)
- return ans;
- int current = i;
- for(int j = current+1;j <= min(next,length - 1);++j)
- {
- i = max(i,nums[j] + j);
- cout << i << " ";
- }
- swap(i,next);
- cout << i << " "<< next << endl;
- }
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0046._Permutations.md b/docs/leetcode/cpp/0046._Permutations.md
deleted file mode 100644
index f2a9e583e..000000000
--- a/docs/leetcode/cpp/0046._Permutations.md
+++ /dev/null
@@ -1,99 +0,0 @@
-# 46. Permutations
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/permutations/
-
-> ��������
-
-```
-Given a collection of distinct integers, return all possible permutations.
-
-Example:
-
-Input: [1,2,3]
-Output:
-[
- [1,2,3],
- [1,3,2],
- [2,1,3],
- [2,3,1],
- [3,1,2],
- [3,2,1]
-]
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n!*n)******- �ռ临�Ӷ�: O(n)******
-
-�ܲ����Ŀ���ݹ��һ���⣬ÿ�ζ�����һ����֮������������ɡ�
-
-```cpp
-class Solution {
-public:
- vector> permute(vector& nums) {
- vector > ans;
- if(!nums.size())
- return ans;
- if(nums.size() == 1)
- ans.push_back(nums);
- for(int i = 0;i < nums.size();++i)
- {
- swap(nums[0],nums[i]);
- vector v(nums.begin() + 1,nums.end());
- vector > ret = permute(v);
- for(int i = 0;i < ret.size();++i)
- {
- ret[i].push_back(nums[0]);
- ans.push_back(ret[i]);
- }
- swap(nums[0],nums[i]);
- }
- return ans;
- }
-};
-```
-> ˼·2
-******- ʱ�临�Ӷ�: O(n!)******- �ռ临�Ӷ�: O(n)******
-
-���ǿ��Զ�������㷨�����Ż�����DFS�ķ�����ÿ�μ�¼�Ѿ������������ֽ��еݹ鼴��
-
-```cpp
-class Solution {
-public:
-void DFS(int* visited,vector& nums,vector >& ans,vector temp)
-{
- int count1 = 0;
- for(int i = 0;i < nums.size();++i)
- if(!visited[i])
- {
- temp.push_back(nums[i]);
- visited[i] = 1;
- DFS(visited,nums,ans,temp);
- temp.pop_back();
- visited[i] = 0;
- count1 = 1;
- }
- if(!count1)
- ans.push_back(temp);
-}
-vector> permute(vector& nums) {
- vector > ans;
- int visited[nums.size()];
- memset(visited,0,sizeof(visited));
- vector temp;
- for(int i = 0; i < nums.size();++i)
- {
- visited[i] = 1;
- temp.push_back(nums[i]);
- DFS(visited,nums,ans,temp);
- temp.pop_back();
- visited[i] = 0;
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0047._Permutations_II.md b/docs/leetcode/cpp/0047._Permutations_II.md
deleted file mode 100644
index ed5ec1283..000000000
--- a/docs/leetcode/cpp/0047._Permutations_II.md
+++ /dev/null
@@ -1,102 +0,0 @@
-# 47. Permutations II
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/permutations-ii/
-
-> ��������
-
-```
-Given a collection of numbers that might contain duplicates, return all possible unique permutations.
-
-Example:
-
-Input: [1,1,2]
-Output:
-[
- [1,1,2],
- [1,2,1],
- [2,1,1]
-]
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n!*nlgn)******- �ռ临�Ӷ�: O(n)******
-
-��ǰ����ǵ����е����ƣ����Բο�֮ǰ�Ľⷨ����������֮ǰ����Ŀ����ֱ�Ӿ���setȥ���ˣ���Ȼͨ���ˣ�����ʱ�临�ӶȱȽϸߣ������Ҫ�����Ż�
-
-```cpp
-class Solution {
-public:
- void DFS(int* visited,vector& nums,set >& ans,vector temp)
- {
- int count1 = 0;
- for(int i = 0;i < nums.size();++i)
- if(!visited[i])
- {
- temp.push_back(nums[i]);
- visited[i] = 1;
- DFS(visited,nums,ans,temp);
- temp.pop_back();
- visited[i] = 0;
- count1 = 1;
- }
- if(!count1)
- ans.insert(temp);
- }
- vector> permuteUnique(vector& nums) {
- vector > ans;
- int visited[nums.size()];
- memset(visited,0,sizeof(visited));
- set > s;
- vector temp;
- for(int i = 0; i < nums.size();++i)
- {
- visited[i] = 1;
- temp.push_back(nums[i]);
- DFS(visited,nums,s,temp);
- temp.pop_back();
- visited[i] = 0;
- }
- for(auto pos = s.begin();pos != s.end();++pos)
- ans.push_back(*pos);
- return ans;
- }
-};
-```
-> ˼·2
-******- ʱ�临�Ӷ�: O(n!)******- �ռ临�Ӷ�: O(n)******
-
-����֮ǰ�ǵ���ľ��顣����Ҳ����ͨ��DFS�ķ���ȥ�⣬�����и����⣬����ͬ�����־ͻ�����ظ�������ȶ������������������ͬ�����־ͻ������һ��Ȼ�����DFSʱ�����������Ǵ������ҽ��еģ���˵�һ������֮ǰ������Ȳ���֮ǰ�������Ѿ��������ˣ���ô���ǾͲ����������������
-
-```cpp
-class Solution {
-public:
- vector> permuteUnique(vector& nums) {
- const int n = nums.size();
- sort(nums.begin(), nums.end());
- vector> ret;
- vector visited(n, 0), arr;
- dfs(nums, ret, arr, visited);
- return ret;
- }
- void dfs(vector& nums, vector>& ret, vector& arr, vector& visited) {
- if (arr.size() == nums.size()) {
- ret.push_back(arr);
- return;
- }
- for (int i = 0; i < nums.size(); ++i) {
- if (visited[i]) {continue;}
- if (i -1 >= 0 && nums[i] == nums[i-1] && !visited[i-1]) {continue;}
- arr.push_back(nums[i]);
- visited[i] = 1;
- dfs(nums, ret, arr, visited);
- arr.pop_back();
- visited[i] = 0;
- }
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0048._Rotate_Image.md b/docs/leetcode/cpp/0048._Rotate_Image.md
deleted file mode 100644
index 30feef74b..000000000
--- a/docs/leetcode/cpp/0048._Rotate_Image.md
+++ /dev/null
@@ -1,71 +0,0 @@
-# 49. Group Anagrams
-
- **难度: Medium **
-
- ## 刷题内容
-
- > 原题连接
-
-* https://leetcode.com/problems/rotate-image/submissions/
-
- > 内容描述
-
- ```
-给你一个矩阵,让你顺时针旋转90° 思路: 不讨论复制一个数组然后在旋转的方法,因为太简单了。 下面的方法都是in-place的:。
-
-示例:
-
-输入:
-[
- [1,2,3],
- [4,5,6],
- [7,8,9]
-],
-
-输出:
-[
- [7,4,1],
- [8,5,2],
- [9,6,3]
-]
-说明:
-
-必须直接修改输入的2D矩阵。
-不要分配另一个2D矩阵并进行旋转。
- ```
-
-## 解题方案
-> 思路 1
-```
-直接设置top, bottom, left, right四个变量,表示圈定当前要旋转的正方形范围,
-然后按偏移计算位置,比如左上角的先和右上角交换,然后继续左上角和右下角交换这样即可.
-```
-
-```cpp
-class Solution {
-public:
- void rotate(vector>& matrix) {
- if(matrix.empty())
- return;
- int top = 0, bottom = matrix.size() - 1;
- int left = 0, right = matrix[0].size() - 1;
- for(;top < bottom && left < right; ++top, ++left, --bottom, --right){
- for(int i = left; i < right; ++i){
- int dis = i - left;
-
- int row = top + dis;
- int col = right;
- swap(matrix[top][i], matrix[row][col]);
-
- row = bottom;
- col = right - dis;
- swap(matrix[top][i], matrix[row][col]);
-
- row = bottom - dis;
- col = left;
- swap(matrix[top][i], matrix[row][col]);
- }
- }
- }
-};
-```
diff --git a/docs/leetcode/cpp/0049._Group_Anagrams.md b/docs/leetcode/cpp/0049._Group_Anagrams.md
deleted file mode 100644
index e7cb3c461..000000000
--- a/docs/leetcode/cpp/0049._Group_Anagrams.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# 49. Group Anagrams
-
- **难度: Medium **
-
- ## 刷题内容
-
- > 原题连接
-
-* https://leetcode-cn.com/problems/group-anagrams/submissions/
-
- > 内容描述
-
- ```
-给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。
-
-示例:
-
-输入: ["eat", "tea", "tan", "ate", "nat", "bat"],
-输出:
-[
- ["ate","eat","tea"],
- ["nat","tan"],
- ["bat"]
-]
-说明:
-
-所有输入均为小写字母。
-不考虑答案输出的顺序。
- ```
-
-## 解题方案
-> 思路 1
-```
-不同的组别字符串元素相同,顺序不同,所以排序后相同
-把排序后相同的元素映射到同一个vector
-所有vector的组合就是结果
-```
-
-```cpp
-vector> groupAnagrams(vector& strs) {
- vector> ans;
- map> maps;
- for(int i=0;i难度:Medium **
-
-## 刷题内容
-
-> 原题连接
-
-* https://leetcode.com/problems/powx-n/
-
-> 内容描述
-
-```
-mplement pow(x, n), which calculates x raised to the power n (xn).
-
-Example 1:
-
-Input: 2.00000, 10
-Output: 1024.00000
-Example 2:
-
-Input: 2.10000, 3
-Output: 9.26100
-Example 3:
-
-Input: 2.00000, -2
-Output: 0.25000
-Explanation: 2-2 = 1/22 = 1/4 = 0.25
-Note:
-
--100.0 < x < 100.0
-n is a 32-bit signed integer, within the range [?2^31, 2^31 ? 1]
-```
-
-> 思路1
-******- 时间复杂度: O(lgN)******- 空间复杂度: O(1)******
-
-求一个数的n次方是我们经常用的函数,一般刚开始可能会用暴力的方法去求,做了n次循环,但由于这里的n非常大,单纯的暴力会TLE,这里可以用分治的思想,比如``2*2*2*2``,我们前面已经计算过``2*2``了,那么后面就不用再计算依次,就相当于``2*2*(2*2)``,这样时间复杂度就变成了lgN,接下来只要主要幂次是负数的情况即可
-
-```cpp
-class Solution {
-public:
- double Pow(double x, long long n)
- {
- if(!n)
- return 1;
- if(n == 1)
- return x;
- double temp = Pow(x,(n)/ 2);
- double ret;
- if(n&1)
- ret = temp * temp * x;
- else
- ret = temp * temp;
- return ret;
- }
- double myPow(double x, int n) {
- long long k = n;
- if(n < 0)
- x = 1 / x;
- return Pow(x,n);
- }
-};
-```
diff --git a/docs/leetcode/cpp/0051._N-Queens.md b/docs/leetcode/cpp/0051._N-Queens.md
deleted file mode 100644
index b190f1e96..000000000
--- a/docs/leetcode/cpp/0051._N-Queens.md
+++ /dev/null
@@ -1,91 +0,0 @@
-# 51. N-Queens
-
-**�Ѷ�:Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/n-queens/
-
-> ��������
-
-```
-The n-queens puzzle is the problem of placing n queens on an n��n chessboard such that no two queens attack each other.
-
-
-
-Given an integer n, return all distinct solutions to the n-queens puzzle.
-
-Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space respectively.
-
-Example:
-
-Input: 4
-Output: [
- [".Q..", // Solution 1
- "...Q",
- "Q...",
- "..Q."],
-
- ["..Q.", // Solution 2
- "Q...",
- "...Q",
- ".Q.."]
-]
-Explanation: There exist two distinct solutions to the 4-queens puzzle as shown above.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(2^n)******- �ռ临�Ӷ�: O(n)******
-
-�û��ݷ�ȥ�����⡣�������ʵľͼ��������������ʵľͻ��ˣ���������������ֱ��¼��ֱ������б�Ϸ�����б�Ϸ��Ƿ��лʺ�
-
-```cpp
-class Solution {
-public:
- void travel(int* d,vector& ret,int level,int n,vector >& ans,int* l,int* r)
- {
- if(level >= n)
- ans.push_back(ret);
- for(int i = 0;i < n;++i)
- if(!d[i] && !r[level + i] && !l[i - level + n])
- {
- d[i] = 1;
- r[level + i] = 1;
- l[i- level + n] = 1;
- ret[level][i] = 'Q';
- travel(d,ret,level + 1,n,ans,l,r);
- d[i] = 0;
- r[level + i] = 0;
- l[i- level + n] = 0;
- ret[level][i] = '.';
- }
- }
- vector> solveNQueens(int n) {
- int d[n];
- int l[2 * n];
- int r[2 * n];
- memset(d,0,sizeof(d));
- memset(l,0,sizeof(l));
- memset(r,0,sizeof(r));
- vector temp;
- vector > ans;
- string s(n,'.');
- for(int i = 0;i < n;++i)
- temp.push_back(s);
- for(int i = 0;i < n;++i)
- {
- temp[0][i] ='Q';
- d[i] = 1;
- r[i] = 1;
- l[i + n] = 1;
- travel(d,temp,1,n,ans,l,r);
- temp[0][i] = '.';
- d[i] = 0;
- r[i] = 0;
- l[i + n] = 0;
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0052._N-Queens_II.md b/docs/leetcode/cpp/0052._N-Queens_II.md
deleted file mode 100644
index d3fe42dab..000000000
--- a/docs/leetcode/cpp/0052._N-Queens_II.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# 52. N-Queens II
-
-**�Ѷ�:Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/n-queens-ii/
-
-> ��������
-
-```
-The n-queens puzzle is the problem of placing n queens on an n��n chessboard such that no two queens attack each other.
-
-
-
-Given an integer n, return the number of distinct solutions to the n-queens puzzle.
-
-Example:
-
-Input: 4
-Output: 2
-Explanation: There are two distinct solutions to the 4-queens puzzle as shown below.
-[
- [".Q..", // Solution 1
- "...Q",
- "Q...",
- "..Q."],
-
- ["..Q.", // Solution 2
- "Q...",
- "...Q",
- ".Q.."]
-]
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(2^n)******- �ռ临�Ӷ�: O(n)******
-
-�������һ�������һ����ֻ������������Ķ�һ�¾ͺã�����IJ���˵��
-
-```cpp
-class Solution {
-public:
- int travel(int* d,int level,int n,int* l,int* r)
- {
- if(level >= n)
- return 1;
- int ans = 0;
- for(int i = 0;i < n;++i)
- if(!d[i] && !r[level + i] && !l[i - level + n])
- {
- d[i] = 1;
- r[level + i] = 1;
- l[i- level + n] = 1;
- ans += travel(d,level + 1,n,l,r);
- d[i] = 0;
- r[level + i] = 0;
- l[i- level + n] = 0;
- }
- return ans;
- }
- int totalNQueens(int n) {
- int d[n];
- int l[2 * n];
- int r[2 * n];
- memset(d,0,sizeof(d));
- memset(l,0,sizeof(l));
- memset(r,0,sizeof(r));
- int ans = 0;
- for(int i = 0;i < n;++i)
- {
- d[i] = 1;
- r[i] = 1;
- l[i + n] = 1;
- ans += travel(d,1,n,l,r);
- d[i] = 0;
- r[i] = 0;
- l[i + n] = 0;
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0053._Maximum_Subarray.md b/docs/leetcode/cpp/0053._Maximum_Subarray.md
deleted file mode 100644
index 1ce150902..000000000
--- a/docs/leetcode/cpp/0053._Maximum_Subarray.md
+++ /dev/null
@@ -1,79 +0,0 @@
-# 053. Maximum Subarray
-
-**�Ѷ�Easy**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/maximum-subarray/
-
-> ��������
-
-```
-Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
-
-Example:
-
-Input: [-2,1,-3,4,-1,2,1,-5,4],
-Output: 6
-Explanation: [4,-1,2,1] has the largest sum = 6.
-Follow up:
-
-If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(lgn)*****- �ռ临�Ӷ�: O(1)******
-
-����ñ����ķ���ȥ�⣬���˶����뵽���������ǿ��Զ��㷨�����Ż������������÷��η���˼�룬��������Ϊ���������飬������������ֵ������[left,mid]���䣬[mid + 1,right]��������ں��mid�������ڣ�ֻҪȡ��������������ֵ���ɡ�
-```cpp
-class Solution {
-public:
- int findArray(vector& nums,int beg,int en)
- {
- if(beg == en)
- return nums[en];
- int mid = (beg + en) / 2;
- int temp = max(findArray(nums,beg,mid),findArray(nums,mid + 1,en));
- int sum = 0,max1 = INT_MIN,max2 = INT_MIN;
- for(int i = mid;i >= beg;--i)
- {
- sum += nums[i];
- max1 = max(max1,sum);
- }
- sum = 0;
- for(int i = mid + 1;i <= en;++i)
- {
- sum += nums[i];
- max2 = max(max2,sum);
- }
- return max(temp,max1 + max2);
- }
- int maxSubArray(vector& nums) {
- return findArray(nums,0,nums.size() - 1);
- }
-};
-```
-> ˼·2
-******- ʱ�临�Ӷ�: O(n)*****- �ռ临�Ӷ�: O(1)******
-
-���ﻹ������O(n)��ʱ�临�Ӷ���⣬�������飬��ret > 0,ret =nums[i]
-����ret += nums[i]
-
-```cpp
-class Solution {
-public:
- int maxSubArray(vector& nums) {
- int length = nums.size(),ret = nums[0],ans = nums[0];
- for(int i = 1;i < length;++i)
- {
- if(ret <= 0)
- ret = nums[i];
- else
- ret += nums[i];
- ans = max(ans,ret);
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0054._Spiral_Matrix.md b/docs/leetcode/cpp/0054._Spiral_Matrix.md
deleted file mode 100644
index 8fb997937..000000000
--- a/docs/leetcode/cpp/0054._Spiral_Matrix.md
+++ /dev/null
@@ -1,70 +0,0 @@
-# 54. Spiral Matrix
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/spiral-matrix/submissions/
-
-> ��������
-
-```
-Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
-
-Example 1:
-
-Input:
-[
- [ 1, 2, 3 ],
- [ 4, 5, 6 ],
- [ 7, 8, 9 ]
-]
-Output: [1,2,3,6,9,8,7,4,5]
-Example 2:
-
-Input:
-[
- [1, 2, 3, 4],
- [5, 6, 7, 8],
- [9,10,11,12]
-]
-Output: [1,2,3,4,8,12,11,10,9,5,6,7]
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(n*m)******- �ռ临�Ӷ�: O(1)******
-
-�����������飬�ҵ����ɾ��У�����ûʲô�Ѷ�
-
-```cpp
-class Solution {
-public:
- vector spiralOrder(vector>& matrix) {
- vector ans;
- if(!matrix.size())
- return ans;
- int row = matrix[0].size(),colunm = matrix.size();
- for(int i = 0;i < (matrix.size() + 1) / 2;++i)
- {
- if(row < 1 || colunm < 1)
- break;
- for(int j = 0;j < row;++j)
- ans.push_back(matrix[i][i + j]);
- if(colunm <= 1)
- break;
- for(int j = 1;j < colunm;++j)
- ans.push_back(matrix[i + j][row + i - 1]);
- if(row <= 1)
- break;
- for(int j = 1;j < row;++j)
- ans.push_back(matrix[i + colunm - 1][row + i - 1 - j]);
- for(int j = 1;j < colunm - 1;++j)
- ans.push_back(matrix[i + colunm - 1 - j][i]);
- row -= 2;
- colunm -= 2;
- }
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0055._Jump_Game.md b/docs/leetcode/cpp/0055._Jump_Game.md
deleted file mode 100644
index 165942077..000000000
--- a/docs/leetcode/cpp/0055._Jump_Game.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# 55. Jump Game
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/jump-game/submissions/
-
-> ��������
-
-```
-Given an array of non-negative integers, you are initially positioned at the first index of the array.
-
-Each element in the array represents your maximum jump length at that position.
-
-Determine if you are able to reach the last index.
-
-Example 1:
-
-Input: [2,3,1,1,4]
-Output: true
-Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.
-Example 2:
-
-Input: [3,2,1,0,4]
-Output: false
-Explanation: You will always arrive at index 3 no matter what. Its maximum
- jump length is 0, which makes it impossible to reach the last index.
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(1)******
-
-�տ�ʼ�뵽�ľ���DP�ķ�����������DP�Ļ�ʱ�临�Ӷ�ΪO(n^2)������Ȼ���ǿ��Զ��㷨�����Ż�,��ʱ�临�Ӷ�O(n)����ɡ�����ֻ��Ҫ�ж�ÿһ�����ߵ���Զ�ľ��뼴�ɣ���������[2,3,1,1,4]����һ��ֻ���ߵ�0���ڶ���������[1��2]������Զ�ľ���Ϊ4����������
-
-```cpp
-class Solution {
-public:
- bool canJump(vector& nums) {
- if(nums.size() <= 1)
- return 1;
- for(int i = 0,r = 0;i < nums.size() - 1;)
- {
- int max1 = 0;
- while(i <= r)
- {
- max1 = max(max1,i + nums[i]);
- ++i;
- }
- //cout << max1 << endl;
- if(max1 >= nums.size() - 1)
- return 1;
- if(max1 <= r)
- return 0;
- r = max1;
- }
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0056._Merge_Intervals.md b/docs/leetcode/cpp/0056._Merge_Intervals.md
deleted file mode 100644
index 0ee06bf72..000000000
--- a/docs/leetcode/cpp/0056._Merge_Intervals.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# 56. Merge Intervals
-
-**�Ѷ�:Medium**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/merge-intervals/
-
-> ��������
-
-```
-Given a collection of intervals, merge all overlapping intervals.
-
-Example 1:
-
-Input: [[1,3],[2,6],[8,10],[15,18]]
-Output: [[1,6],[8,10],[15,18]]
-Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
-Example 2:
-
-Input: [[1,4],[4,5]]
-Output: [[1,5]]
-Explanation: Intervals [1,4] and [4,5] are considered overlapping.
-```
-
-> ˼·1
-******- ʱ�临�Ӷ�: O(nlgn)******- �ռ临�Ӷ�: O(1)******
-
-��������Ҫ�ȶ��������������start�����������������ͱ�������õ����飬������ཻ�ͽ��������䶼����ans������ཻ�ͽ��ϲ��������IJ���ans��
-
-```cpp
-/**
- * Definition for an interval.
- * struct Interval {
- * int start;
- * int end;
- * Interval() : start(0), end(0) {}
- * Interval(int s, int e) : start(s), end(e) {}
- * };
- */
-class Solution {
-public:
- vector merge(vector& intervals) {
- vector ans;
- if(!intervals.size())
- return ans;
- sort(intervals.begin(),intervals.end(),[](Interval a, Interval b){return a.start < b.start;});
- for(int i = 0;i < intervals.size() - 1;++i)
- if(intervals[i + 1].start <= intervals[i].end)
- {
- intervals[i + 1].start = intervals[i].start;
- intervals[i].end = max(intervals[i].end,intervals[i + 1].end);
- intervals[i + 1].end = intervals[i].end;
- }
- else
- ans.push_back(intervals[i]);
- ans.push_back(intervals[intervals.size() - 1]);
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0057._Insert_Interval.md b/docs/leetcode/cpp/0057._Insert_Interval.md
deleted file mode 100644
index b910a1a0f..000000000
--- a/docs/leetcode/cpp/0057._Insert_Interval.md
+++ /dev/null
@@ -1,93 +0,0 @@
-# 57. Insert Interval
-
-**�Ѷ�:Hard**
-
-## ˢ������
-> ԭ������
-
-* https://leetcode.com/problems/insert-interval/
-
-> ��������
-
-```
-Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
-
-You may assume that the intervals were initially sorted according to their start times.
-
-Example 1:
-
-Input: intervals = [[1,3],[6,9]], newInterval = [2,5]
-Output: [[1,5],[6,9]]
-Example 2:
-
-Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
-Output: [[1,2],[3,10],[12,16]]
-Explanation: Because the new interval [4,8] overlaps with [3,5],[6,7],[8,10].
-```
-
-> ˼·
-******- ʱ�临�Ӷ�: O(N)******- �ռ临�Ӷ�: O(N)******
-
-�ȼ������������ԭ�����������е�λ�á��������飬���αȽ��������䡣��¼ l ��r���ֱ������Ҫ���ӵ�����������յ㡣�õ�λ��֮���ҵ� intervals[i].end < l,���ӽ��������飬��������������[l,r]��������� intervals[i].start > r�����䡣
-
-```cpp
-/**
- * Definition for an interval.
- * struct Interval {
- * int start;
- * int end;
- * Interval() : start(0), end(0) {}
- * Interval(int s, int e) : start(s), end(e) {}
- * };
- */
-class Solution {
-public:
- vector insert(vector& intervals, Interval newInterval) {
- int beg = newInterval.start,en = newInterval.end,l = beg,r = en;
- int comp = beg;
- for(int i = 0;i < intervals.size();++i)
- {
- if(comp < intervals[i].start)
- {
- comp == beg ? l = beg : r = en;
- comp = comp == beg ? en : beg;
- if(comp == en && en < intervals[i].start)
- {
- r = en;
- break;
- }
- if(comp == beg)
- break;
- }
- if(comp <= intervals[i].end)
- {
-
- comp == beg ? l = intervals[i].start : r = intervals[i].end;
- comp = comp == beg ? en : beg;
- if(comp == en && en <= intervals[i].end)
- {
- r = intervals[i].end;
- break;
- }
- if(comp == beg)
- break;
- }
- }
- int i = 0;
- vector ans;
- for(;i < intervals.size();++i)
- if(intervals[i].end < l)
- ans.push_back(intervals[i]);
- else
- break;
- Interval i1(l,r);
- ans.push_back(i1);
- for(;i < intervals.size();++i)
- if(intervals[i].start > r)
- break;
- for(;i < intervals.size();++i)
- ans.push_back(intervals[i]);
- return ans;
- }
-};
-```
\ No newline at end of file
diff --git a/docs/leetcode/cpp/0058._Length_of_Last_Word.md b/docs/leetcode/cpp/0058._Length_of_Last_Word.md
deleted file mode 100644
index 5586aa9f2..000000000
--- a/docs/leetcode/cpp/0058._Length_of_Last_Word.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# 058. Length of Last Word
-
-**难度Easy**
-
-## 刷题内容
-> 原题连接
-
-* https://leetcode.com/problems/length-of-last-word/
-
-> 内容描述
-
-```
-Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
-
-If the last word does not exist, return 0.
-```
-
-> 思路
-******- 时间复杂度: O(n)*****- 空间复杂度: O(1)******
-
-这题我们只要从字符串的末尾开始向前找到第一个单词即可
-```cpp
-class Solution {
-public:
- int lengthOfLastWord(string s) {
- int i = s.length() - 1,length = s.length() - 1;
- while((s[i] == ' ') &&(i >= 0))
- {
- --i;
- --length;
- }
- while((s[i] != ' ') && (i >= 0))
- --i;
- return length- i;
- }
-};
-```
diff --git a/docs/leetcode/cpp/0059._Spiral_Matrix_II.md b/docs/leetcode/cpp/0059._Spiral_Matrix_II.md
deleted file mode 100644
index a77e1d205..000000000
--- a/docs/leetcode/cpp/0059._Spiral_Matrix_II.md
+++ /dev/null
@@ -1,60 +0,0 @@
-# 59. Spiral Matrix II
-
-**