常见 Git 工作流程

一、简单的 Git 工作流程

简单的 Git 工作流程图

阅读全文

说说 Vuex

一、为什么要说 Vuex

上周在做项目的时候,有一个模块用到了一个章节组件,一个 content 组件,其中章节组件调用了一个 tree 组价用来递归章节列表。选中章节组件中的项,需要更新到 content 的已选章节部分,取消章节选项,已选章节也需要删除对应的项,此外,删除已选章节中的某一项,也需要更新左侧章节列表,比如这样:

阅读全文

原地删除数组中的指定元素

Problem

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]);
}

阅读全文

找出两个有序数组的中值

Problem

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

阅读全文

HTTP 服务器

一、HTTP 服务是什么

1、一个网页请求包含两次 HTTP 包交换

(1) 浏览器向 HTTP 服务器发送请求 HTTP 包

阅读全文

Two Sum

Problem

Given an array of integers, return indices of the 
two numbers such that they add up to a specific
target.

You may assume that each input would have exactly
one solution, and you may not use the same element
twice.

Example:
Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,

return [0, 1].

阅读全文

小程序 Tabs-Sticky

小程序 sticky 的正确使用姿势

阅读全文

自定义 Github 动态

自定义 github 动态

阅读全文

6 个常见的网站可用性问题及其修正方法

6 个常见的网站可用性问题及其修正方法

阅读全文

好玩的 Console

一切要从昨天打开知乎控制台说起,昨天打开知乎控制台看到了 acii 图形的打印,比较好奇怎么画出来的,首先想肯定要用 console 吧,那么到底使用什么姿势 console 出来的呢?emmm,然后就有了这个

阅读全文