-
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
2 changed files
with
137 additions
and
1 deletion.
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
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,136 @@ | ||
--- | ||
layout: post | ||
title: "LeetCode-1004.(Max Consecutive Ones III) 题解" | ||
description: "" | ||
category: LeetCode | ||
tags: [LeetCode,Two-Pointers,Sliding-Window] | ||
--- | ||
|
||
## LeetCode-1004 题解 | ||
|
||
### [Problem Description](https://leetcode.com/problems/max-consecutive-ones-iii/)([中文版](https://leetcode-cn.com/problems/max-consecutive-ones-iii/)) | ||
|
||
Given an array A of 0s and 1s, we may change up to K values from 0 to 1. | ||
Return the length of the longest (contiguous) subarray that contains only 1s. | ||
|
||
#### Example 1: | ||
Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2 | ||
|
||
Output: 6 | ||
|
||
Explanation: | ||
[1,1,1,0,0,1,1,1,1,1,1] | ||
|
||
Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. | ||
|
||
#### Example 2: | ||
Input: A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], K = 3 | ||
|
||
Output: 10 | ||
|
||
Explanation: | ||
[0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1] | ||
|
||
Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. | ||
|
||
|
||
--- | ||
|
||
### 二. Jekyll的安装 | ||
|
||
Jekyll本身是用Ruby语言编写,需要先安装Ruby的开发环境。通过以下几步来完成Jekyll的安装: | ||
|
||
#### 1.安装Ruby | ||
|
||
去Ruby的[官网](https://www.ruby-lang.org/en/downloads/), 根据不同的操作系统选择合适的安装包进行安装。官网比较推荐在Linux平台进行安装。如果是在Windows上安装的话,安装过程中,要**勾选所有的**,默认只勾选前两项。 | ||
|
||
```ruby | ||
安装后通过查看版本来确认安装成功: | ||
ruby -v | ||
ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32] | ||
``` | ||
|
||
#### 2. 安装RubyGems | ||
|
||
>The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” which contains a packaged Ruby application or library. | ||
> | ||
>Gems can be used to extend or modify functionality in Ruby applications. Commonly they’re used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work. | ||
RubyGems是Ruby的包管理器,它会将Ruby的应用程序打包的一个Gem里,在**最新版本的Ruby安装程序中,已经包含了RubyGems**。 | ||
|
||
**Gem又是什么鬼?** Gem是封装起来的Ruby应用程序或代码库,可以理解为Java中已经JDK自带的库。 | ||
|
||
```ruby | ||
安装后通过查看版本来确认安装成功: | ||
gem -v | ||
3.0.3 | ||
``` | ||
|
||
有一个默认的sources,用于下载更新,sources默认的地址是国外,速度非常慢,需要替换成国内的sources。 | ||
|
||
```ruby | ||
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ | ||
``` | ||
|
||
#### 3. 安装Jekyll | ||
|
||
```ruby | ||
安装命令: gem install jekyll | ||
安装后通过查看版本来确认安装成功: | ||
jekyll -v | ||
jekyll 3.8.6 | ||
``` | ||
|
||
#### 4. 安装Bundler(可选,但强烈建议安装) | ||
|
||
>Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. | ||
> | ||
Bundler是一个可以批量执行gem的工具。它的存在是为了解决安装Gem时软件之间的版本冲突。 | ||
|
||
|
||
```ruby | ||
安装命令: gem install bundler | ||
安装后通过查看版本来确认安装成功: | ||
bundler -v | ||
Bundler version 2.0.2 | ||
``` | ||
|
||
#### 5. 启动Jekyll | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
|
||
|
||
### 三. Jekyll的使用 | ||
|
||
|
||
|
||
|
||
|
||
--- | ||
###### 参考: | ||
|
||
[整理Ruby相关的各种概念(rvm, gem, bundle, rake, rails等)](https://henter.me/post/ruby-rvm-gem-rake-bundle-rails.html) | ||
|
||
[RubyGems维基百科](https://zh.wikipedia.org/wiki/RubyGems#) | ||
|
||
[Ruby的Gem是什么](https://blog.csdn.net/guyue35/article/details/54898439) | ||
|
||
[Bundler官网](https://bundler.io/) | ||
|
||
[RubyGems官网](https://rubygems.org/?locale=zh-CN) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|