Skip to content

Commit 6220492

Browse files
committed
1
1 parent 29fcfc3 commit 6220492

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.DS_Store
44
.idea
55
cargo.lock
6+
*/target/*
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "S17-19-missing-two-lcci"
3+
version = "0.1.0"
4+
authors = ["Xargin <cao1988228@163.com>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
struct Solution;
2+
3+
impl Solution {
4+
pub fn missing_two(nums: Vec<i32>) -> Vec<i32> {
5+
let mut res = vec![];
6+
(0..nums.len()).for_each(|i|{
7+
if nums[i] == i as i32 + 2 && res.len() == 0 {
8+
res.push(nums[i] - 1);
9+
}
10+
if nums[i] == i as i32 + 3 && res.len() == 0 {
11+
res.push(nums[i] - 2);
12+
res.push(nums[i] - 1);
13+
}
14+
if nums[i] == i as i32 + 3 && res.len() == 1 {
15+
res.push(nums[i] - 1);
16+
}
17+
});
18+
19+
if res.len() == 0 {
20+
res.push(nums.len() as i32+1);
21+
res.push(nums.len() as i32+2);
22+
}
23+
if res.len() == 1 {
24+
res.push(nums.len() as i32 + 2);
25+
}
26+
res
27+
}
28+
}
29+
30+
fn main() {
31+
dbg!(Solution::missing_two(vec![1]));
32+
dbg!(Solution::missing_two(vec![2, 3]));
33+
}
34+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"rustc_fingerprint":15434876304888546455,"outputs":{"4476964694761187371":["___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/xargin/.rustup/toolchains/stable-x86_64-apple-darwin\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n",""],"1164083562126845933":["rustc 1.40.0 (73528e339 2019-12-16)\nbinary: rustc\ncommit-hash: 73528e339aae0f17a15ffa49a8ac608f50c6cf14\ncommit-date: 2019-12-16\nhost: x86_64-apple-darwin\nrelease: 1.40.0\nLLVM version: 9.0\n",""],"10915535544655558915":["rustdoc [options] <input>\n\nOptions:\n -h, --help show this help message\n -V, --version print rustdoc's version\n -v, --verbose use verbose output\n -r, --input-format [rust]\n the input type of the specified file\n -w, --output-format [html]\n the output type to write\n -o, --output PATH where to place the output\n --crate-name NAME\n specify the name of this crate\n --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]\n Comma separated list of types of crates\n for the compiler to emit\n -L, --library-path DIR\n directory to add to crate search path\n --cfg pass a --cfg to rustc\n --extern NAME=PATH\n pass an --extern to rustc\n --extern-html-root-url NAME=URL\n base URL to use for dependencies\n --plugin-path DIR\n removed\n -C, --codegen OPT[=VALUE]\n pass a codegen option to rustc\n --passes PASSES list of passes to also run, you might want to pass it\n multiple times; a value of `list` will print available\n passes\n --plugins PLUGINS\n removed\n --no-defaults don't run the default passes\n --document-private-items \n document private items\n --test run code examples as tests\n --test-args ARGS\n arguments to pass to the test runner\n --target TRIPLE target triple to document\n --markdown-css FILES\n CSS files to include via <link> in a rendered Markdown\n file\n --html-in-header FILES\n files to include inline in the <head> section of a\n rendered Markdown file or generated documentation\n --html-before-content FILES\n files to include inline between <body> and the content\n of a rendered Markdown file or generated documentation\n --html-after-content FILES\n files to include inline between the content and\n </body> of a rendered Markdown file or generated\n documentation\n --markdown-before-content FILES\n files to include inline between <body> and the content\n of a rendered Markdown file or generated documentation\n --markdown-after-content FILES\n files to include inline between the content and\n </body> of a rendered Markdown file or generated\n documentation\n --markdown-playground-url URL\n URL to send code snippets to\n --markdown-no-toc \n don't include table of contents\n -e, --extend-css PATH\n To add some CSS rules with a given file to generate\n doc with your own theme. However, your theme might\n break if the rustdoc's generated HTML changes, so be\n careful!\n -Z FLAG internal and debugging options (only on nightly build)\n --sysroot PATH Override the system root\n --playground-url URL\n URL to send code snippets to, may be reset by\n --markdown-playground-url or\n `#![doc(html_playground_url=...)]`\n --display-warnings \n to print code warnings when testing doc\n --crate-version VERSION\n crate version to print into documentation\n --sort-modules-by-appearance \n sort modules by where they appear in the program,\n rather than alphabetically\n --themes FILES additional themes which will be added to the generated\n docs\n --theme-checker FILES\n check if given theme is valid\n --resource-suffix PATH\n suffix to add to CSS and JavaScript files, e.g.,\n \"light.css\" will become \"light-suffix.css\"\n --edition EDITION\n edition to use when compiling rust code (default:\n 2015)\n --color auto|always|never\n Configure coloring of output:\n auto = colorize, if output goes to a tty (default);\n always = always colorize output;\n never = never colorize output\n --error-format human|json|short\n How errors and other messages are produced\n --json CONFIG Configure the structure of JSON diagnostics\n --disable-minification \n Disable minification applied on JS files\n -W, --warn OPT Set lint warnings\n -A, --allow OPT Set lint allowed\n -D, --deny OPT Set lint denied\n -F, --forbid OPT Set lint forbidden\n --cap-lints LEVEL\n Set the most restrictive lint level. More restrictive\n lints are capped at this level. By default, it is at\n `forbid` level.\n --index-page PATH\n Markdown file to be used as index page\n --enable-index-page \n To enable generation of the index page\n --static-root-path PATH\n Path string to force loading static files from in\n output pages. If not set, uses combinations of '../'\n to reach the documentation root.\n --disable-per-crate-search \n disables generating the crate selector on the search\n box\n --persist-doctests PATH\n Directory to persist doctest executables into\n --generate-redirect-pages \n Generate extra pages to support legacy URLs and tool\n links\n --show-coverage \n calculate percentage of public items with\n documentation\n --enable-per-target-ignores \n parse ignore-foo for ignoring doctests on a per-target\n basis\n --runtool The tool to run tests with when building for a different target than host\n \n --runtool-arg One (of possibly many) arguments to pass to the runtool\n \n --test-builder specified the rustc-like binary to use as the test\n builder\n\n",""]},"successes":{}}

0 commit comments

Comments
 (0)