1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
C++
01-matrix.cpp
1-bit-and-2-bit-characters.cpp
132-pattern.cpp
2-keys-keyboard.cpp
24-game.cpp
3sum-closest.cpp
3sum-smaller.cpp
3sum-with-multiplicity.cpp
3sum.cpp
4-keys-keyboard.cpp
4sum-ii.cpp
4sum.cpp
accounts-merge.cpp
add-and-search-word-data-structure-design.cpp
add-binary.cpp
add-bold-tag-in-string.cpp
add-digits.cpp
add-one-row-to-tree.cpp
add-strings.cpp
add-to-array-form-of-integer.cpp
add-two-numbers-ii.cpp
add-two-numbers.cpp
adding-two-negabinary-numbers.cpp
additive-number.cpp
advantage-shuffle.cpp
alien-dictionary.cpp
all-nodes-distance-k-in-binary-tree.cpp
all-oone-data-structure.cpp
all-paths-from-source-lead-to-destination.cpp
all-paths-from-source-to-target.cpp
all-possible-full-binary-trees.cpp
ambiguous-coordinates.cpp
android-unlock-patterns.cpp
arithmetic-slices-ii-subsequence.cpp
arithmetic-slices.cpp
arranging-coins.cpp
array-nesting.cpp
array-of-doubled-pairs.cpp
array-partition-i.cpp
assign-cookies.cpp
asteroid-collision.cpp
available-captures-for-rook.cpp
average-of-levels-in-binary-tree.cpp
backspace-string-compare.cpp
bag-of-tokens.cpp
base-7.cpp
baseball-game.cpp
basic-calculator-ii.cpp
basic-calculator-iii.cpp
basic-calculator-iv.cpp
basic-calculator.cpp
battleships-in-a-board.cpp
beautiful-arrangement-ii.cpp
beautiful-arrangement.cpp
beautiful-array.cpp
best-meeting-point.cpp
best-sightseeing-pair.cpp
best-time-to-buy-and-sell-stock-ii.cpp
best-time-to-buy-and-sell-stock-with-cooldown.cpp
best-time-to-buy-and-sell-stock-with-transaction-fee.cpp
best-time-to-buy-and-sell-stock.cpp
binary-gap.cpp
binary-number-with-alternating-bits.cpp
binary-prefix-divisible-by-5.cpp
binary-search-tree-iterator.cpp
binary-search-tree-to-greater-sum-tree.cpp
binary-search.cpp
binary-string-with-substrings-representing-1-to-n.cpp
binary-subarrays-with-sum.cpp
binary-tree-cameras.cpp
binary-tree-inorder-traversal.cpp
binary-tree-level-order-traversal-ii.cpp
binary-tree-level-order-traversal.cpp
binary-tree-longest-consecutive-sequence-ii.cpp
binary-tree-longest-consecutive-sequence.cpp
binary-tree-paths.cpp
binary-tree-postorder-traversal.cpp
binary-tree-preorder-traversal.cpp
binary-tree-pruning.cpp
binary-tree-tilt.cpp
binary-tree-vertical-order-traversal.cpp
binary-trees-with-factors.cpp
binary-watch.cpp
bitwise-and-of-numbers-range.cpp
bitwise-ors-of-subarrays.cpp
boats-to-save-people.cpp
bold-words-in-string.cpp
bomb-enemy.cpp
boundary-of-binary-tree.cpp
brick-wall.cpp
bricks-falling-when-hit.cpp
broken-calculator.cpp
buddy-strings.cpp
bulb-switcher-ii.cpp
bulb-switcher.cpp
bulls-and-cows.cpp
burst-balloons.cpp
bus-routes.cpp
camelcase-matching.cpp
campus-bikes-ii.cpp
campus-bikes.cpp
can-i-win.cpp
can-place-flowers.cpp
canCompleteCircuit.cpp
canJump.cpp
candy-crush.cpp
candy.cpp
capacity-to-ship-packages-within-d-days.cpp
car-fleet.cpp
card-flipping-game.cpp
cat-and-mouse.cpp
chalkboard-xor-gam.cpp
champagne-tower.cpp
cheapest-flights-within-k-stops.cpp
check-completeness-of-a-binary-tree.cpp
check-if-word-is-valid-after-substitutions.cpp
cherry-pickup.cpp
circular-array-loop.cpp
climbing-stairs.cpp
cloneGraph.cpp
closest-binary-search-tree-value-ii.cpp
closest-binary-search-tree-value.cpp
closest-leaf-in-a-binary-tree.cpp
clumsy-factorial.cpp
coin-change-2.cpp
coin-change.cpp
coin-path.cpp
coloring-a-border.cpp
combination-sum-iii.cpp
combination-sum-iv.cpp
combinationSum.cpp
combinationSum2.cpp
combine.cpp
compare-version-numbers.cpp
complement-of-base-10-integer.cpp
complete-binary-tree-inserter.cpp
complex-number-multiplication.cpp
concatenated-words.cpp
confusing-number.cpp
connect.cpp
consecutive-numbers-sum.cpp
construct-binary-search-tree-from-preorder-traversal.cpp
construct-binary-tree-from-inorder-and-postorder-traversal.cpp
construct-binary-tree-from-preorder-and-inorder-traversal.cpp
construct-binary-tree-from-preorder-and-postorder-traversal.cpp
construct-binary-tree-from-string.cpp
construct-quad-tree.cpp
construct-string-from-binary-tree.cpp
construct-the-rectangle.cpp
contain-virus.cpp
container-with-most-water.cpp
contains-duplicate-ii.cpp
contains-duplicate-iii.cpp
contains-duplicate.cpp
contiguous-array.cpp
continuous-subarray-sum.cpp
convert-a-number-to-hexadecimal.cpp
convert-binary-search-tree-to-sorted-doubly-linked-list.cpp
convert-bst-to-greater-tree.cpp
convert-sorted-array-to-binary-search-tree.cpp
convert-sorted-list-to-binary-search-tree.cpp
convert-to-base-2.cpp
convert.cpp
convex-polygon.cpp
copy-list-with-random-pointer.cpp
count-and-say.cpp
count-binary-substrings.cpp
count-complete-tree-nodes.cpp
count-different-palindromic-subsequences.cpp
count-numbers-with-unique-digits.cpp
count-of-range-sum.cpp
count-of-smaller-numbers-after-self.cpp
count-primes.cpp
count-the-repetitions.cpp
count-univalue-subtrees.cpp
counting-bits.cpp
couples-holding-hands.cpp
course-schedule-ii.cpp
course-schedule-iii.cpp
course-schedule.cpp
cousins-in-binary-tree.cpp
cracking-the-safe.cpp
create-maximum-number.cpp
custom-sort-string.cpp
cut-off-trees-for-golf-event.cpp
daily-temperatures.cpp
data-stream-as-disjoint-intervals.cpp
decode-string.cpp
decode-ways-ii.cpp
decode-ways.cpp
decoded-string-at-index.cpp
degree-of-an-array.cpp
delete-and-earn.cpp
delete-columns-to-make-sorted-ii.cpp
delete-columns-to-make-sorted-iii.cpp
delete-columns-to-make-sorted.cpp
delete-node-in-a-bst.cpp
delete-node-in-a-linked-list.cpp
delete-operation-for-two-strings.cpp
design-circular-deque.cpp
design-circular-queue.cpp
design-compressed-string-iterator.cpp
design-excel-sum-formula.cpp
design-hashmap.cpp
design-hashset.cpp
design-hit-counter.cpp
design-in-memory-file-system.cpp
design-linked-list.cpp
design-log-storage-system.cpp
design-phone-directory.cpp
design-search-autocomplete-system.cpp
design-snake-game.cpp
design-tic-tac-toe.cpp
design-twitter.cpp
detect-capital.cpp
di-string-match.cpp
diagonal-traverse.cpp
diameter-of-binary-tree.cpp
different-ways-to-add-parentheses.cpp
digit-count-in-range.cpp
distant-barcodes.cpp
distinct-subsequences-ii.cpp
distribute-candies.cpp
distribute-coins-in-binary-tree.cpp
divide-two-integers.cpp
divisor-game.cpp
domino-and-tromino-tiling.cpp
dota2-senate.cpp
elimination-game.cpp
employee-free-time.cpp
employee-importance.cpp
encode-and-decode-strings.cpp
encode-and-decode-tinyurl.cpp
encode-n-ary-tree-to-binary-tree.cpp
encode-string-with-shortest-length.cpp
equal-rational-numbers.cpp
equal-tree-partition.cpp
erect-the-fence.cpp
escape-a-large-maze.cpp
escape-the-ghosts.cpp
evaluate-division.cpp
evaluate-reverse-polish-notation.cpp
exam-room.cpp
excel-sheet-column-number.cpp
excel-sheet-column-title.cpp
exclusive-time-of-functions.cpp
exist.cpp
expression-add-operators.cpp
expressive-words.cpp
factor-combinations.cpp
factorial-trailing-zeroes.cpp
fair-candy-swap.cpp
falling-squares.cpp
fibonacci-number.cpp
find-all-anagrams-in-a-string.cpp
find-all-duplicates-in-an-array.cpp
find-all-numbers-disappeared-in-an-array.cpp
find-anagram-mappings.cpp
find-and-replace-in-string.cpp
find-and-replace-pattern.cpp
find-bottom-left-tree-value.cpp
find-common-characters.cpp
find-duplicate-file-in-system.cpp
find-duplicate-subtrees.cpp
find-eventual-safe-states.cpp
find-k-closest-elements.cpp
find-k-pairs-with-smallest-sums.cpp
find-k-th-smallest-pair-distance.cpp
find-largest-value-in-each-tree-row.cpp
find-leaves-of-binary-tree.cpp
find-median-from-data-stream.cpp
find-minimum-in-rotated-sorted-array-ii.cpp
find-minimum-in-rotated-sorted-array.cpp
find-mode-in-binary-search-tree.cpp
find-peak-element.cpp
find-permutation.cpp
find-pivot-index.cpp
find-right-interval.cpp
find-smallest-letter-greater-than-target.cpp
find-the-celebrity.cpp
find-the-closest-palindrome.cpp
find-the-derangement-of-an-array.cpp
find-the-difference.cpp
find-the-duplicate-number.cpp
find-the-shortest-superstring.cpp
find-the-town-judge.cpp
first-bad-version.cpp
first-missing-positive.cpp
first-unique-character-in-a-string.cpp
fixed-point.cpp
fizz-buzz.cpp
flatten-2d-vector.cpp
flatten-a-multilevel-doubly-linked-list.cpp
flatten-nested-list-iterator.cpp
flatten.cpp
flip-binary-tree-to-match-preorder-traversal.cpp
flip-columns-for-maximum-number-of-equal-rows.cpp
flip-equivalent-binary-trees.cpp
flip-game-ii.cpp
flip-game.cpp
flip-string-to-monotone-increasing.cpp
flipping-an-image.cpp
flood-fill.cpp
flower-planting-with-no-adjacent.cpp
fraction-addition-and-subtraction.cpp
fraction-to-recurring-decimal.cpp
freedom-trail.cpp
friend-circles.cpp
friends-of-appropriate-ages.cpp
frog-jump.cpp
fruit-into-baskets.cpp
game-of-life.cpp
generalized-abbreviation.cpp
generate-random-point-in-a-circle.cpp
generateParenthesis.cpp
getRow.cpp
global-and-local-inversions.cpp
goat-latin.cpp
graph-valid-tree.cpp
gray-code.cpp
greatest-common-divisor-of-strings.cpp
grid-illumination.cpp
group-anagrams.cpp
group-shifted-strings.cpp
groups-of-special-equivalent-strings.cpp
grumpy-bookstore-owner.cpp
guess-number-higher-or-lower-ii.cpp
guess-number-higher-or-lower.cpp
guess-the-word.cpp
h-index-ii.cpp
h-index.cpp
hamming-distance.cpp
hand-of-straights.cpp
happy-number.cpp
hasPathSum.cpp
heaters.cpp
height-checker.cpp
house-robber-ii.cpp
house-robber-iii.cpp
house-robber.cpp
image-overlap.cpp
image-smoother.cpp
implement-magic-dictionary.cpp
implement-queue-using-stacks.cpp
implement-rand10-using-rand7.cpp
implement-stack-using-queues.cpp
implement-strstr.cpp
implement-trie-prefix-tree.cpp
increasing-order-search-tree.cpp
increasing-subsequences.cpp
increasing-triplet-subsequence.cpp
index-pairs-of-a-string.cpp
inorder-successor-in-bst-ii.cpp
inorder-successor-in-bst.cpp
insert-delete-getrandom-o1-duplicates-allowed.cpp
insert-delete-getrandom-o1.cpp
insert-interval.cpp
insert-into-a-binary-search-tree.cpp
insert-into-a-cyclic-sorted-list.cpp
insertion-sort-list.cpp
insufficient-nodes-in-root-to-leaf-paths.cpp
integer-break.cpp
integer-replacement.cpp
integer-to-english-words.cpp
integer-to-roman.cpp
intersection-of-two-arrays-ii.cpp
intersection-of-two-arrays.cpp
intersection-of-two-linked-lists.cpp
interval-list-intersections.cpp
invert-binary-tree.cpp
ip-to-cidr.cpp
ipo.cpp
is-graph-bipartite.cpp
is-subsequence.cpp
isInterleave.cpp
isMatch.cpp
isScramble.cpp
isValidBST2.cpp
island-perimeter.cpp
isomorphic-strings.cpp
jewels-and-stones.cpp
judge-route-circle.cpp
jump.cpp
k-closest-points-to-origin.cpp
k-diff-pairs-in-an-array.cpp
k-empty-slots.cpp
k-inverse-pairs-array.cpp
k-similar-strings.cpp
k-th-smallest-in-lexicographical-order.cpp
k-th-smallest-prime-fraction.cpp
k-th-symbol-in-grammar.cpp
keyboard-row.cpp
keys-and-rooms.cpp
kill-process.cpp
knight-dialer.cpp
knight-probability-in-chessboard.cpp
koko-eating-bananas.cpp
kth-largest-element-in-a-stream.cpp
kth-largest-element-in-an-array.cpp
kth-smallest-element-in-a-bst.cpp
kth-smallest-element-in-a-sorted-matrix.cpp
kth-smallest-number-in-multiplication-table.cpp
ladderLength.cpp
largest-bst-subtree.cpp
largest-component-size-by-common-factor.cpp
largest-divisible-subset.cpp
largest-number-at-least-twice-of-others.cpp
largest-number.cpp
largest-palindrome-product.cpp
largest-perimeter-triangle.cpp
largest-plus-sign.cpp
largest-rectangle-in-histogram.cpp
largest-sum-of-averages.cpp
largest-time-for-given-digits.cpp
largest-triangle-area.cpp
last-stone-weight-ii.cpp
last-stone-weight.cpp
leaf-similar-trees.cpp
least-operators-to-express-number.cpp
lemonade-change.cpp
length-of-last-word.cpp
length-of-longest-fibonacci-subsequence.cpp
letter-case-permutation.cpp
letter-tile-possibilities.cpp
letterCombinations.cpp
lexicographical-numbers.cpp
lexicographically-smallest-equivalent-string.cpp
lfu-cache.cpp
license-key-formatting.cpp
line-reflection.cpp
linked-list-components.cpp
linked-list-cycle-ii.cpp
linked-list-cycle.cpp
linked-list-random-node.cpp
logger-rate-limiter.cpp
lonely-pixel-i.cpp
lonely-pixel-ii.cpp
long-pressed-name.cpp
longest-absolute-file-path.cpp
longest-arithmetic-sequence.cpp
longest-common-prefix.cpp
longest-consecutive-sequence.cpp
longest-continuous-increasing-subsequence.cpp
longest-duplicate-substring.cpp
longest-harmonious-subsequence.cpp
longest-increasing-path-in-a-matrix.cpp
longest-increasing-subsequence.cpp
longest-line-of-consecutive-one-in-matrix.cpp
longest-mountain-in-array.cpp
longest-palindrome.cpp
longest-palindromic-subsequence.cpp
longest-palindromic-substring.cpp
longest-repeating-character-replacement.cpp
longest-repeating-substring.cpp
longest-string-chain.cpp
longest-substring-with-at-least-k-repeating-characters.cpp
longest-substring-with-at-most-k-distinct-characters.cpp
longest-substring-with-at-most-two-distinct-characters.cpp
longest-substring-without-repeating-characters.cpp
longest-turbulent-subarray.cpp
longest-uncommon-subsequence-i.cpp
longest-uncommon-subsequence-ii.cpp
longest-univalue-path.cpp
longest-valid-parentheses.cpp
longest-word-in-dictionary-through-deleting.cpp
longest-word-in-dictionary.cpp
longestCommonLength.cpp
loud-and-rich.cpp
lowest-common-ancestor-of-a-binary-search-tree.cpp
lowest-common-ancestor-of-a-binary-tree.cpp
lru-cache.cpp
magic-squares-in-grid.cpp
magical-string.cpp
majority-element-ii.cpp
majority-element.cpp
making-a-large-island.cpp
map-sum-pairs.cpp
masking-personal-information.cpp
matchsticks-to-square.cpp
matrix-cells-in-distance-order.cpp
max-area-of-island.cpp
max-chunks-to-make-sorted-ii.cpp
max-chunks-to-make-sorted.cpp
max-consecutive-ones-ii.cpp
max-consecutive-ones-iii.cpp
max-consecutive-ones.cpp
max-increase-to-keep-city-skyline.cpp
max-points-on-a-line.cpp
max-stack.cpp
max-sum-of-sub-matrix-no-larger-than-k.cpp
maxPathSum.cpp
maxProfitII.cpp
maxProfitIII.cpp
maximal-rectangle.cpp
maximal-square.cpp
maximize-distance-to-closest-person.cpp
maximize-sum-of-array-after-k-negations.cpp
maximum-average-subarray-i.cpp
maximum-average-subarray-ii.cpp
maximum-binary-tree-ii.cpp
maximum-binary-tree.cpp
maximum-depth-of-binary-tree.cpp
maximum-depth-of-n-ary-tree.cpp
maximum-difference-between-node-and-ancestor.cpp
maximum-distance-in-arrays.cpp
maximum-frequency-stack.cpp
maximum-gap.cpp
maximum-length-of-pair-chain.cpp
maximum-length-of-repeated-subarray.cpp
maximum-product-of-three-numbers.cpp
maximum-product-of-word-lengths.cpp
maximum-size-subarray-sum-equals-k.cpp
maximum-subarray.cpp
maximum-sum-circular-subarray.cpp
maximum-sum-of-3-non-overlapping-subarrays.cpp
maximum-sum-of-two-non-overlapping-subarrays.cpp
maximum-swap.cpp
maximum-vacation-days.cpp
maximum-width-of-binary-tree.cpp
maximum-width-ramp.cpp
maximum-xor-of-two-numbers-in-an-array.cpp
median-of-two-sorted-arrays.cpp
meeting-rooms-ii.cpp
meeting-rooms.cpp
merge-intervals.cpp
merge-k-sorted-lists.cpp
merge-sorted-array.cpp
merge-two-binary-trees.cpp
merge-two-sorted-lists.cpp
merge2.cpp
middle-of-the-linked-list.cpp
min-cost-climbing-stairs.cpp
min-stack.cpp
minCut.cpp
minDepth.cpp
minDistance.cpp
minPathSum.cpp
minesweeper.cpp
mini-parser.cpp
minimize-malware-spread-ii.cpp
minimize-malware-spread.cpp
minimize-max-distance-to-gas-station.cpp
minimize-rounding-error-to-meet-target.cpp
minimum-absolute-difference-in-bst.cpp
minimum-add-to-make-parentheses-valid.cpp
minimum-area-rectangle-ii.cpp
minimum-area-rectangle.cpp
minimum-ascii-delete-sum-for-two-strings.cpp
minimum-cost-for-tickets.cpp
minimum-cost-to-hire-k-workers.cpp
minimum-cost-to-merge-stones.cpp
minimum-distance-between-bst-nodes.cpp
minimum-domino-rotations-for-equal-row.cpp
minimum-factorization.cpp
minimum-falling-path-sum.cpp
minimum-genetic-mutation.cpp
minimum-height-trees.cpp
minimum-increment-to-make-array-unique.cpp
minimum-index-sum-of-two-lists.cpp
minimum-moves-to-equal-array-elements-ii.cpp
minimum-moves-to-equal-array-elements.cpp
minimum-number-of-arrows-to-burst-balloons.cpp
minimum-number-of-k-consecutive-bit-flips.cpp
minimum-number-of-refueling-stops.cpp
minimum-score-triangulation-of-polygon.cpp
minimum-size-subarray-sum.cpp
minimum-swaps-to-make-sequences-increasing.cpp
minimum-time-difference.cpp
minimum-unique-word-abbreviation.cpp
minimum-window-subsequence.cpp
minimum-window-substring.cpp
minimumTotal.cpp
minimumTotal2.cpp
mirror-reflection.cpp
missing-element-in-sorted-array.cpp
missing-number.cpp
missing-ranges.cpp
monotone-increasing-digits.cpp
monotonic-array.cpp
most-common-word.cpp
most-frequent-subtree-sum.cpp
most-profit-assigning-work.cpp
most-stones-removed-with-same-row-or-column.cpp
move-zeroes.cpp
moving-average-from-data-stream.cpp
moving-stones-until-consecutive-ii.cpp
moving-stones-until-consecutive.cpp
multiply-strings.cpp
my-calendar-i.cpp
my-calendar-ii.cpp
my-calendar-iii.cpp
n-ary-tree-level-order-traversal.cpp
n-ary-tree-postorder-traversal.cpp
n-ary-tree-preorder-traversal.cpp
n-repeated-element-in-size-2n-array.cpp
nested-list-weight-sum-ii.cpp
nested-list-weight-sum.cpp
network-delay-time.cpp
new-21-game.cpp
next-closest-time.cpp
next-greater-element-i.cpp
next-greater-element-ii.cpp
next-greater-element-iii.cpp
next-greater-node-in-linked-list.cpp
next-permutation.cpp
nim-game.cpp
non-decreasing-array.cpp
non-negative-integers-without-consecutive-ones.cpp
non-overlapping-intervals.cpp
nth-digit.cpp
nth-magical-number.cpp
numDistinct.cpp
number-complement.cpp
number-of-1-bits.cpp
number-of-atoms.cpp
number-of-boomerangs.cpp
number-of-connected-components-in-an-undirected-graph.cpp
number-of-corner-rectangles.cpp
number-of-digit-one.cpp
number-of-distinct-islands-ii.cpp
number-of-distinct-islands.cpp
number-of-enclaves.cpp
number-of-islands-ii.cpp
number-of-lines-to-write-string.cpp
number-of-longest-increasing-subsequence.cpp
number-of-matching-subsequences.cpp
number-of-music-playlists.cpp
number-of-recent-calls.cpp
number-of-segments-in-a-string.cpp
number-of-squareful-arrays.cpp
number-of-subarrays-with-bounded-maximum.cpp
number-of-submatrices-that-sum-to-target.cpp
number-of-valid-subarrays.cpp
numbers-at-most-n-given-digit-set.cpp
numbers-with-repeated-digits.cpp
numbers-with-same-consecutive-differences.cpp
occurrences-after-bigram.cpp
odd-even-jump.cpp
odd-even-linked-list.cpp
one-edit-distance.cpp
ones-and-zeroes.cpp
online-election.cpp
online-stock-span.cpp
open-the-lock.cpp
optimal-account-balancing.cpp
optimal-division.cpp
orderly-queue.cpp
out-of-boundary-paths.cpp
output-contest-matches.cpp
pacific-atlantic-water-flow.cpp
paint-fence.cpp
paint-house-ii.cpp
paint-house.cpp
pairs-of-songs-with-total-durations-divisible-by-60.cpp
palindrome-linked-list.cpp
palindrome-number.cpp
palindrome-pairs.cpp
palindrome-permutation-ii.cpp
palindrome-permutation.cpp
palindromePartition.cpp
palindromePartition2.cpp
palindromic-substrings.cpp
pancake-sorting.cpp
parse-lisp-expression.cpp
partition-array-for-maximum-sum.cpp
partition-array-into-disjoint-intervals.cpp
partition-array-into-three-parts-with-equal-sum.cpp
partition-equal-subset-sum.cpp
partition-labels.cpp
partition-list.cpp
partition-to-k-equal-sum-subsets.cpp
pascals-triangle-ii.cpp
pascals-triangle.cpp
patching-array.cpp
path-sum-iii.cpp
path-sum-iv.cpp
pathSum.cpp
peak-index-in-a-mountain-array.cpp
peeking-iterator.cpp
perfect-number.cpp
perfect-rectangle.cpp
perfect-squares.cpp
permutation-in-string.cpp
permutation-sequence.cpp
permuteUnique.cpp
plus-one-linked-list.cpp
plus-one.cpp
poor-pigs.cpp
positions-of-large-groups.cpp
possible-bipartition.cpp
pour-water.cpp
power-of-four.cpp
power-of-three.cpp
power-of-two.cpp
powerful-integers.cpp
powx-n.cpp
predict-the-winner.cpp
prefix-and-suffix-search.cpp
preimage-size-of-factorial-zeroes-function.cpp
previous-permutation-with-one-swap.cpp
prime-number-of-set-bits-in-binary-representation.cpp
prime-palindrome.cpp
print-binary-tree.cpp
prison-cells-after-n-days.cpp
product-of-array-except-self.cpp
profitable-schemes.cpp
projection-area-of-3d-shapes.cpp
push-dominoes.cpp
pyramid-transition-matrix.cpp
quad-tree-intersection.cpp
queue-reconstruction-by-height.cpp
rabbits-in-forest.cpp
race-car.cpp
random-flip-matrix.cpp
random-pick-index.cpp
random-pick-with-blacklist.cpp
random-pick-with-weight.cpp
random-point-in-non-overlapping-rectangles.cpp
range-addition-ii.cpp
range-addition.cpp
range-module.cpp
range-sum-of-bst.cpp
range-sum-query-2d-immutable.cpp
range-sum-query-2d-mutable.cpp
range-sum-query-immutable.cpp
range-sum-query-mutable.cpp
ransom-note.cpp
reach-a-number.cpp
reachable-nodes-in-subdivided-graph.cpp
reaching-points.cpp
read-n-characters-given-read4-ii-call-multiple-times.cpp
read-n-characters-given-read4.cpp
rearrange-string-k-distance-apart.cpp
reconstruct-itinerary.cpp
reconstruct-original-digits-from-english.cpp
recover-a-tree-from-preorder-traversal.cpp
recover-binary-search-tree.cpp
rectangle-area-ii.cpp
rectangle-area.cpp
rectangle-overlap.cpp
redundant-connection-ii.cpp
redundant-connection.cpp
regions-cut-by-slashes.cpp
relative-ranks.cpp
remove-9.cpp
remove-all-adjacent-duplicates-in-string.cpp
remove-boxes.cpp
remove-comments.cpp
remove-duplicate-letters.cpp
remove-duplicates-from-sorted-array-ii.cpp
remove-duplicates-from-sorted-array.cpp
remove-duplicates-from-sorted-list-ii.cpp
remove-duplicates-from-sorted-list.cpp
remove-element.cpp
remove-invalid-parentheses.cpp
remove-k-digits.cpp
remove-linked-list-elements.cpp
remove-nth-node-from-end-of-list.cpp
remove-outermost-parentheses.cpp
reorder-list.cpp
reorder-log-files.cpp
reordered-power-of-2.cpp
reorganize-string.cpp
repeated-string-match.cpp
repeated-substring-pattern.cpp
replace-words.cpp
reshape-the-matrix.cpp
restoreIpAddresses.cpp
reveal-cards-in-increasing-order.cpp
reverse-bits.cpp
reverse-integer.cpp
reverse-linked-list-ii.cpp
reverse-linked-list.cpp
reverse-nodes-in-k-group.cpp
reverse-only-letters.cpp
reverse-pairs.cpp
reverse-string-ii.cpp
reverse-string.cpp
reverse-vowels-of-a-string.cpp
reverse-words-in-a-string-ii.cpp
reverse-words-in-a-string-iii.cpp
reverse-words-in-a-string.cpp
rle-iterator.cpp
robot-bounded-in-circle.cpp
robot-room-cleaner.cpp
roman-to-integer.cpp
rotate-array.cpp
rotate-function.cpp
rotate-image.cpp
rotate-list.cpp
rotate-string.cpp
rotated-digits.cpp
rotting-oranges.cpp
russian-doll-envelopes.cpp
same-tree.cpp
satisfiability-of-equality-equations.cpp
score-after-flipping-matrix.cpp
score-of-parentheses.cpp
search-a-2d-matrix-ii.cpp
search-a-2d-matrix.cpp
search-for-a-range.cpp
search-in-a-binary-search-tree.cpp
search-in-a-sorted-array-of-unknown-size.cpp
search-in-rotated-sorted-array-ii.cpp
search-in-rotated-sorted-array.cpp
search-insert-position.cpp
searchMatrix2.cpp
second-minimum-node-in-a-binary-tree.cpp
self-crossing.cpp
self-dividing-numbers.cpp
sentence-screen-fitting.cpp
sentence-similarity-ii.cpp
sentence-similarity.cpp
sequence-reconstruction.cpp
serialize-and-deserialize-binary-tree.cpp
serialize-and-deserialize-bst.cpp
serialize-and-deserialize-n-ary-tree.cpp
set-intersection-size-at-least-two.cpp
set-matrix-zeroes.cpp
set-mismatch.cpp
shifting-letters.cpp
shopping-offers.cpp
short-encoding-of-words.cpp
shortest-bridge.cpp
shortest-completing-word.cpp
shortest-distance-from-all-buildings.cpp
shortest-distance-to-a-character.cpp
shortest-palindrome.cpp
shortest-path-to-get-all-keys.cpp
shortest-path-visiting-all-nodes.cpp
shortest-subarray-with-sum-at-least-k.cpp
shortest-unsorted-continuous-subarray.cpp
shortest-way-to-form-string.cpp
shortest-word-distance-ii.cpp
shortest-word-distance-iii.cpp
shortest-word-distance.cpp
shuffle-an-array.cpp
similar-rgb-color.cpp
similar-string-groups.cpp
simplify-path.cpp
single-element-in-a-sorted-array.cpp
single-number-ii.cpp
single-number-iii.cpp
single-number.cpp
sliding-puzzle.cpp
sliding-window-maximum.cpp
sliding-window-median.cpp
smallest-good-base.cpp
smallest-integer-divisible-by-k.cpp
smallest-range-i.cpp
smallest-range-ii.cpp
smallest-range.cpp
smallest-rectangle-enclosing-black-pixels.cpp
smallest-rotation-with-highest-score.cpp
smallest-string-starting-from-leaf.cpp
smallest-subsequence-of-distinct-characters.cpp
smallest-subtree-with-all-the-deepest-nodes.cpp
snakes-and-ladders.cpp
solve-the-equation.cpp
solveNQueens.cpp
solveSudoku.cpp
sort-an-array.cpp
sort-array-by-parity-ii.cpp
sort-array-by-parity.cpp
sort-characters-by-frequency.cpp
sort-colors.cpp
sort-list.cpp
sort-transformed-array.cpp
sortColors.cpp
soup-servings.cpp
sparse-matrix-multiplication.cpp
special-binary-string.cpp
spiral-matrix-ii.cpp
spiral-matrix-iii.cpp
spiral-matrix.cpp
split-array-into-consecutive-subsequences.cpp
split-array-into-fibonacci-sequence.cpp
split-array-largest-sum.cpp
split-array-with-equal-sum.cpp
split-array-with-same-average.cpp
split-bst.cpp
split-concatenated-strings.cpp
split-linked-list-in-parts.cpp
sqrtx.cpp
squares-of-a-sorted-array.cpp
squirrel-simulation.cpp
stamping-the-sequence.cpp
stickers-to-spell-word.cpp
stone-game.cpp
strange-printer.cpp
stream-of-characters.cpp
stream-of-characters2.cpp
string-compression.cpp
string-to-integer-atoi.cpp
string-without-aaa-or-bbb.cpp
strobogrammatic-number-ii.cpp
strobogrammatic-number-iii.cpp
strobogrammatic-number.cpp
strong-password-checker.cpp
student-attendance-record-i.cpp
student-attendance-record-ii.cpp
subarray-product-less-than-k.cpp
subarray-sum-equals-k.cpp
subarray-sums-divisible-by-k.cpp
subarrays-with-k-different-integers.cpp
subdomain-visit-count.cpp
subsets-ii.cpp
subsets.cpp
substring-with-concatenation-of-all-words.cpp
subtree-of-another-tree.cpp
sum-of-distances-in-tree.cpp
sum-of-even-numbers-after-queries.cpp
sum-of-left-leaves.cpp
sum-of-root-to-leaf-binary-numbers.cpp
sum-of-square-numbers.cpp
sum-of-subarray-minimums.cpp
sum-of-subsequence-widths.cpp
sum-of-two-integers.cpp
sumNumbers.cpp
summary-ranges.cpp
super-egg-drop.cpp
super-palindromes.cpp
super-pow.cpp
super-ugly-number.cpp
super-washing-machines.cpp
surface-area-of-3d-shapes.cpp
surrounded-regions.cpp
surroundedRegions.cpp
swap-adjacent-in-lr-string.cpp
swap-nodes-in-pairs.cpp
swim-in-rising-water.cpp
symmetric-tree.cpp
tag-validator.cpp
tallest-billboard.cpp
target-sum.cpp
task-scheduler.cpp
teemo-attacking.cpp
ternary-expression-parser.cpp
text-justification.cpp
the-maze-ii.cpp
the-maze-iii.cpp
the-maze.cpp
the-skyline-problem.cpp
third-maximum-number.cpp
three-equal-parts.cpp
threeSum2.cpp
time-based-key-value-store.cpp
to-lower-case.cpp
toeplitz-matrix.cpp
top-k-frequent-elements.cpp
top-k-frequent-words.cpp
total-hamming-distance.cpp
totalNQueens.cpp
transform-to-chessboard.cpp
transpose-matrix.cpp
trapping-rain-water-ii.cpp
trapping-rain-water.cpp
trim-a-binary-search-tree.cpp
triples-with-bitwise-and-equal-to-zero.cpp
two-city-scheduling.cpp
two-sum-ii-input-array-is-sorted.cpp
two-sum-iii-data-structure-design.cpp
two-sum-iv-input-is-a-bst.cpp
two-sum.cpp
ugly-number-ii.cpp
ugly-number.cpp
uncommon-words-from-two-sentences.cpp
uncrossed-lines.cpp
unique-binary-search-trees-ii.cpp
unique-email-addresses.cpp
unique-letter-string.cpp
unique-morse-code-words.cpp
unique-paths-iii.cpp
unique-substrings-in-wraparound-string.cpp
unique-word-abbreviation.cpp
uniquePathWithObstacles.cpp
uniquePaths.cpp
uniquePaths2.cpp
univalued-binary-tree.cpp
utf-8-validation.cpp
valid-anagram.cpp
valid-boomerang.cpp
valid-mountain-array.cpp
valid-number.cpp
valid-palindrome-ii.cpp
valid-palindrome.cpp
valid-parentheses.cpp
valid-parenthesis-string.cpp
valid-perfect-square.cpp
valid-permutations-for-di-sequence.cpp
valid-square.cpp
valid-sudoku.cpp
valid-tic-tac-toe-state.cpp
valid-triangle-number.cpp
valid-word-abbreviation.cpp
valid-word-square.cpp
validate-binary-search-tree.cpp
validate-ip-address.cpp
validate-stack-sequences.cpp
verify-preorder-sequence-in-binary-search-tree.cpp
剩余 1 项被截断
Golang
Java
MySQL
Python
Shell
.travis.yml
LICENSE.md
README.md
克隆/下载
maximize-distance-to-closest-person.cpp 510 Bytes
一键复制 编辑 原始数据 按行查看 历史
// Time: O(n)
// Space: O(1)
class Solution {
public:
int maxDistToClosest(vector<int>& seats) {
int prev = -1, result = 1;
for (int i = 0; i < seats.size(); ++i) {
if (seats[i]) {
if (prev < 0) {
result = i;
} else {
result = max(result, (i - prev) / 2);
}
prev = i;
}
}
return max(result, static_cast<int>(seats.size()) - 1 - prev);
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

搜索帮助