-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 打家劫舍 | ||
// https://leetcode.cn/problems/house-robber | ||
// INLINE ../../images/array/house_robber.jpeg | ||
|
||
pub struct Solution; | ||
|
||
impl Solution { | ||
pub fn rob(nums: Vec<i32>) -> i32 { | ||
let mut dp = vec![0; nums.len() + 1]; | ||
dp[0] = 0; | ||
dp[1] = nums[0]; | ||
for i in 2..=nums.len() { | ||
dp[i] = dp[i - 1].max(dp[i - 2] + nums[i - 1]); | ||
} | ||
dp[nums.len()] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use rust_practice::array::house_robber::Solution; | ||
|
||
#[test] | ||
fn rob() { | ||
// 示例 1: | ||
// 输入:[1,2,3,1] | ||
// 输出:4 | ||
// 解释:偷窃 1 号房屋 (金额 = 1) ,然后偷窃 3 号房屋 (金额 = 3)。 | ||
// 偷窃到的最高金额 = 1 + 3 = 4 。 | ||
assert_eq!(Solution::rob(vec![1, 2, 3, 1]), 4); | ||
|
||
// 示例 2: | ||
// 输入:[2,7,9,3,1] | ||
// 输出:12 | ||
// 解释:偷窃 1 号房屋 (金额 = 2), 偷窃 3 号房屋 (金额 = 9),接着偷窃 5 号房屋 (金额 = 1)。 | ||
// 偷窃到的最高金额 = 2 + 9 + 1 = 12 。 | ||
assert_eq!(Solution::rob(vec![2, 7, 9, 3, 1]), 12); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,11 @@ fs.realpath@^1.0.0: | |
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" | ||
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== | ||
|
||
[email protected]: | ||
version "2.3.2" | ||
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" | ||
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== | ||
|
||
get-stream@^5.1.0: | ||
version "5.2.0" | ||
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" | ||
|
@@ -372,14 +377,14 @@ lcov-parse@^1.0.0: | |
resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-1.0.0.tgz#eb0d46b54111ebc561acb4c408ef9363bdc8f7e0" | ||
integrity sha512-aprLII/vPzuQvYZnDRU78Fns9I2Ag3gi4Ipga/hxnVMCZC8DnR2nI7XBqrPoywGfxqIx/DgarGvDJZAD3YBTgQ== | ||
|
||
leetcode-test-helper@^0.4.6: | ||
version "0.4.6" | ||
resolved "https://registry.yarnpkg.com/leetcode-test-helper/-/leetcode-test-helper-0.4.6.tgz#2d67d4b03f618b7cfccda8d175aa9857f3a658b5" | ||
integrity sha512-IGkpJTZLek6sc0bKH6NfbXBhilut2jn0QYUT53PuhNewggZY0GvKrNiD7y0sXLv450lnXuj20YCiUPw4j4vO3g== | ||
leetcode-test-helper@^0.4.7: | ||
version "0.4.7" | ||
resolved "https://registry.yarnpkg.com/leetcode-test-helper/-/leetcode-test-helper-0.4.7.tgz#7798cdf1c322f1ed452b8b26d56b769a5c732aed" | ||
integrity sha512-ULRnWlvIMhduzAvUdxAh1moyrraOLsm5CmA0chYXZYo7OSfpnp176B6JDca+lFGvrPvRLicDzB+3rmi1uHz0xg== | ||
dependencies: | ||
playwright "^1.26.0" | ||
playwright-extra "^4.3.5" | ||
puppeteer-extra-plugin-stealth "^2.11.1" | ||
playwright "^1.38.0" | ||
playwright-extra "^4.3.6" | ||
puppeteer-extra-plugin-stealth "^2.11.2" | ||
|
||
locate-path@^5.0.0: | ||
version "5.0.0" | ||
|
@@ -482,24 +487,26 @@ [email protected]: | |
dependencies: | ||
find-up "^4.0.0" | ||
|
||
playwright-core@1.26.0: | ||
version "1.26.0" | ||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.26.0.tgz#850228f0638d410a5cdd69800d552f60e4d295cd" | ||
integrity sha512-p8huU8eU4gD3VkJd3DA1nA7R3XA6rFvFL+1RYS96cSljCF2yJE9CWEHTPF4LqX8KN9MoWCrAfVKP5381X3CZqg== | ||
playwright-core@1.38.0: | ||
version "1.38.0" | ||
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.38.0.tgz#cb8e135da1c0b1918b070642372040ed9aa7009a" | ||
integrity sha512-f8z1y8J9zvmHoEhKgspmCvOExF2XdcxMW8jNRuX4vkQFrzV4MlZ55iwb5QeyiFQgOFCUolXiRHgpjSEnqvO48g== | ||
|
||
playwright-extra@^4.3.5: | ||
version "4.3.5" | ||
resolved "https://registry.yarnpkg.com/playwright-extra/-/playwright-extra-4.3.5.tgz#696512cc2c0750a5e2d420522152b8dd46ba9fbd" | ||
integrity sha512-YPYsoJFK46h2FqNpD8//ucutSf3c84C0KVYX19gUr0rErajrWZcnfoNfm/okzc8z6/EfTWS3xWb76jDbYI8Qew== | ||
playwright-extra@^4.3.6: | ||
version "4.3.6" | ||
resolved "https://registry.yarnpkg.com/playwright-extra/-/playwright-extra-4.3.6.tgz#3e132e88b88fd5e046b8a73f724b3f2712fb2c3f" | ||
integrity sha512-q2rVtcE8V8K3vPVF1zny4pvwZveHLH8KBuVU2MoE3Jw4OKVoBWsHI9CH9zPydovHHOCDxjGN2Vg+2m644q3ijA== | ||
dependencies: | ||
debug "^4.3.4" | ||
|
||
playwright@^1.26.0: | ||
version "1.26.0" | ||
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.26.0.tgz#b351990ff03a7e422bf585233eb53651fc363896" | ||
integrity sha512-XxTVlvFEYHdatxUkh1KiPq9BclNtFKMi3BgQnl/aactmhN4G9AkZUXwt0ck6NDAOrDFlfibhbM7A1kZwQJKSBw== | ||
playwright@^1.38.0: | ||
version "1.38.0" | ||
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.38.0.tgz#0ee19d38512b7b1f961c0eb44008a6fed373d206" | ||
integrity sha512-fJGw+HO0YY+fU/F1N57DMO+TmXHTrmr905J05zwAQE9xkuwP/QLDk63rVhmyxh03dYnEhnRbsdbH9B0UVVRB3A== | ||
dependencies: | ||
playwright-core "1.26.0" | ||
playwright-core "1.38.0" | ||
optionalDependencies: | ||
fsevents "2.3.2" | ||
|
||
[email protected]: | ||
version "2.0.3" | ||
|
@@ -519,7 +526,7 @@ pump@^3.0.0: | |
end-of-stream "^1.1.0" | ||
once "^1.3.1" | ||
|
||
puppeteer-extra-plugin-stealth@^2.10.2, puppeteer-extra-plugin-stealth@^2.11.1: | ||
puppeteer-extra-plugin-stealth@^2.10.2: | ||
version "2.11.1" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin-stealth/-/puppeteer-extra-plugin-stealth-2.11.1.tgz#7d56a27a986cb5eb69dca3c65695ad6444f4e822" | ||
integrity sha512-n0wdC0Ilc9tk5L6FWLyd0P2gT8b2fp+2NuB+KB0oTSw3wXaZ0D6WNakjJsayJ4waGzIJFCUHkmK9zgx5NKMoFw== | ||
|
@@ -528,6 +535,15 @@ puppeteer-extra-plugin-stealth@^2.10.2, puppeteer-extra-plugin-stealth@^2.11.1: | |
puppeteer-extra-plugin "^3.2.2" | ||
puppeteer-extra-plugin-user-preferences "^2.4.0" | ||
|
||
puppeteer-extra-plugin-stealth@^2.11.2: | ||
version "2.11.2" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin-stealth/-/puppeteer-extra-plugin-stealth-2.11.2.tgz#bd3f5a1781cac8a98c983d148086585a84fcc8f1" | ||
integrity sha512-bUemM5XmTj9i2ZerBzsk2AN5is0wHMNE6K0hXBzBXOzP5m5G3Wl0RHhiqKeHToe/uIH8AoZiGhc1tCkLZQPKTQ== | ||
dependencies: | ||
debug "^4.1.1" | ||
puppeteer-extra-plugin "^3.2.3" | ||
puppeteer-extra-plugin-user-preferences "^2.4.1" | ||
|
||
puppeteer-extra-plugin-user-data-dir@^2.4.0: | ||
version "2.4.0" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin-user-data-dir/-/puppeteer-extra-plugin-user-data-dir-2.4.0.tgz#20e87582482b61e497abd96fec452f63bd2d9123" | ||
|
@@ -538,6 +554,16 @@ puppeteer-extra-plugin-user-data-dir@^2.4.0: | |
puppeteer-extra-plugin "^3.2.2" | ||
rimraf "^3.0.2" | ||
|
||
puppeteer-extra-plugin-user-data-dir@^2.4.1: | ||
version "2.4.1" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin-user-data-dir/-/puppeteer-extra-plugin-user-data-dir-2.4.1.tgz#4ea9d56d20455672a54fe086309a102a5126411c" | ||
integrity sha512-kH1GnCcqEDoBXO7epAse4TBPJh9tEpVEK/vkedKfjOVOhZAvLkHGc9swMs5ChrJbRnf8Hdpug6TJlEuimXNQ+g== | ||
dependencies: | ||
debug "^4.1.1" | ||
fs-extra "^10.0.0" | ||
puppeteer-extra-plugin "^3.2.3" | ||
rimraf "^3.0.2" | ||
|
||
puppeteer-extra-plugin-user-preferences@^2.4.0: | ||
version "2.4.0" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin-user-preferences/-/puppeteer-extra-plugin-user-preferences-2.4.0.tgz#8b75bc39c3de9913e236ae1d982a24711d84ba6f" | ||
|
@@ -548,6 +574,16 @@ puppeteer-extra-plugin-user-preferences@^2.4.0: | |
puppeteer-extra-plugin "^3.2.2" | ||
puppeteer-extra-plugin-user-data-dir "^2.4.0" | ||
|
||
puppeteer-extra-plugin-user-preferences@^2.4.1: | ||
version "2.4.1" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin-user-preferences/-/puppeteer-extra-plugin-user-preferences-2.4.1.tgz#db8ec63c04a6a10a8f8997e15fdffdf13272161d" | ||
integrity sha512-i1oAZxRbc1bk8MZufKCruCEC3CCafO9RKMkkodZltI4OqibLFXF3tj6HZ4LZ9C5vCXZjYcDWazgtY69mnmrQ9A== | ||
dependencies: | ||
debug "^4.1.1" | ||
deepmerge "^4.2.2" | ||
puppeteer-extra-plugin "^3.2.3" | ||
puppeteer-extra-plugin-user-data-dir "^2.4.1" | ||
|
||
puppeteer-extra-plugin@^3.2.2: | ||
version "3.2.2" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin/-/puppeteer-extra-plugin-3.2.2.tgz#3c02c0a10f8eadf32e7debb7ee24105a53afc17b" | ||
|
@@ -557,6 +593,15 @@ puppeteer-extra-plugin@^3.2.2: | |
debug "^4.1.1" | ||
merge-deep "^3.0.1" | ||
|
||
puppeteer-extra-plugin@^3.2.3: | ||
version "3.2.3" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra-plugin/-/puppeteer-extra-plugin-3.2.3.tgz#50c9f0749c005bbc7b8b208bcd00a9d46a15b585" | ||
integrity sha512-6RNy0e6pH8vaS3akPIKGg28xcryKscczt4wIl0ePciZENGE2yoaQJNd17UiEbdmh5/6WW6dPcfRWT9lxBwCi2Q== | ||
dependencies: | ||
"@types/debug" "^4.1.0" | ||
debug "^4.1.1" | ||
merge-deep "^3.0.1" | ||
|
||
puppeteer-extra@^3.3.1: | ||
version "3.3.4" | ||
resolved "https://registry.yarnpkg.com/puppeteer-extra/-/puppeteer-extra-3.3.4.tgz#e0ecf021783d1112b6b0db20546d5022e632ed55" | ||
|