成长路上

不断放弃舒适区


  • Home

  • About

  • Tags

  • Categories

  • Archives

  • Search

iOS-MVC

Posted on 2018-11-10 | In iOS

mvc框架的目标是将应用分成三个功能部分,每个部分都包含数据和逻辑

模型

负责管理用户使用的数据

领域模型

包含了应用的数据与相应的操作,及包含转换、创建、存储和操作数据的规则,通常称为模型逻辑

领域模型

  • 包含

    • 领域数据
    • 创建、管理和修改领域数据的逻辑
    • 提供清晰的,可访问和操作模型数据的API
  • 不包含

    • 暴露模型数据的获取方式或者管理方式
    • 根据用户操作修改模型的逻辑(控制器职责)
    • 将数据展示给用户的逻辑(视图职责)

视图模型

从控制器传递到视图的数据,视图将这类数据展示给用户

视图

视图模型展示给用户
  • 包含

    • 将数据呈现给用户的逻辑或者标记
  • 不包含

    • 复杂的逻辑(控制器)
    • 创建、存储和操作模型的逻辑

控制器

负责响应用户交互,同时扮演者模型与视图之间的桥梁角色
  • 包含

    • 初始化模型的逻辑
    • 视图展示模型中的数据的逻辑和行为
    • 根据用户操作更新模型的逻辑和行为
  • 不包含

    • 向用户展示数据的逻辑(视图职责)
    • 处理数据持久化的逻辑(模型职责)
    • 操作自己领域之外的数据

交叉部分

  • 日志功能
  • 授权功能

leetCode-0098_验证二叉搜索树

Posted on 2018-11-08 | In 算法

题目描述

英文题目

Given a binary tree, determine if it is a valid binary search tree (BST).

Assume a BST is defined as follows:

  • The left subtree of a node contains only nodes with keys less than the node’s key.
  • The right subtree of a node contains only nodes with keys greater than the node’s key.
  • Both the left and right subtrees must also be binary search trees.

Example 1:

1
2
3
4
5
Input:
2
/ \
1 3
Output: true

Example 2:

1
2
3
4
5
6
7
8
    5
/ \
1 4
/ \
3 6
Output: false
Explanation: The input is: [5,1,4,null,null,3,6]. The root node's value
is 5 but its right child's value is 4.
中文题目

假设一个二叉搜索树具有如下特征:

  • 节点的左子树只包含小于当前节点的数。
  • 节点的右子树只包含大于当前节点的数。
  • 所有左子树和右子树自身必须也是二叉搜索树。

示例 1:

1
2
3
4
5
输入:
2
/ \
1 3
输出: true

示例 2:

1
2
3
4
5
6
7
8
9
输入:
5
/ \
1 4
/ \
3 6
输出: false
解释: 输入为: [5,1,4,null,null,3,6]。
根节点的值为 5 ,但是其右子节点值为 4 。
Read more »

leetCode-0018_四数之和

Posted on 2018-11-06 | In 算法

题目描述

英文题目

Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c+ d = target? Find all unique quadruplets in the array which gives the sum of target.

Note:

The solution set must not contain duplicate quadruplets.

Example:

1
2
3
4
5
6
7
8
Given array nums = [1, 0, -1, 0, -2, 2], and target = 0.

A solution set is:
[
[-1, 0, 0, 1],
[-2, -1, 1, 2],
[-2, 0, 0, 2]
]
中文题目

给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,**b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。

注意:

答案中不可以包含重复的四元组。

示例:

1
2
3
4
5
6
7
8
给定数组 nums = [1, 0, -1, 0, -2, 2],和 target = 0。

满足要求的四元组集合为:
[
[-1, 0, 0, 1],
[-2, -1, 1, 2],
[-2, 0, 0, 2]
]
Read more »

leetCode-0015_三数之和

Posted on 2018-11-06 | In 算法

题目描述

英文题目

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

Note:

The solution set must not contain duplicate triplets.

Example:

1
2
3
4
5
6
7
Given array nums = [-1, 0, 1, 2, -1, -4],

A solution set is:
[
[-1, 0, 1],
[-1, -1, 2]
]
中文题目

给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。

注意:答案中不可以包含重复的三元组。

1
2
3
4
5
6
7
例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4],

满足要求的三元组集合为:
[
[-1, 0, 1],
[-1, -1, 2]
]
Read more »

leetCode-0001_两数之和

Posted on 2018-11-06 | In 算法

题目描述

英文题目

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:

1
2
3
4
Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
中文题目

给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。

你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。

示例:

1
2
3
4
给定 nums = [2, 7, 11, 15], target = 9

因为 nums[0] + nums[1] = 2 + 7 = 9
所以返回 [0, 1]
Read more »

leetCode-0239_滑动窗口最大值

Posted on 2018-11-04 | In 算法

题目描述

英文题目

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
Input: nums = [1,3,-1,-3,5,3,6,7], and k = 3
Output: [3,3,5,5,6,7]
Explanation:

Window position Max
--------------- -----
[1 3 -1] -3 5 3 6 7 3
1 [3 -1 -3] 5 3 6 7 3
1 3 [-1 -3 5] 3 6 7 5
1 3 -1 [-3 5 3] 6 7 5
1 3 -1 -3 [5 3 6] 7 6
1 3 -1 -3 5 [3 6 7] 7

Note:
You may assume k is always valid, 1 ≤ k ≤ input array’s size for non-empty array.

Follow up:
Could you solve it in linear time?

中文题目

给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口 k 内的数字。滑动窗口每次只向右移动一位。

返回滑动窗口最大值。

示例:

1
2
3
4
5
6
7
8
9
10
11
12
输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3
输出: [3,3,5,5,6,7]
解释:

滑动窗口的位置 最大值
--------------- -----
[1 3 -1] -3 5 3 6 7 3
1 [3 -1 -3] 5 3 6 7 3
1 3 [-1 -3 5] 3 6 7 5
1 3 -1 [-3 5 3] 6 7 5
1 3 -1 -3 [5 3 6] 7 6
1 3 -1 -3 5 [3 6 7] 7

注意:

你可以假设 k 总是有效的,1 ≤ k ≤ 输入数组的大小,且输入数组不为空。

Read more »

leetCode-0242_有效的字母异位词

Posted on 2018-11-04 | In 算法

题目描述

英文题目

Given two strings s and t , write a function to determine if t is an anagram of s.

Example 1:

1
2
Input: s = "anagram", t = "nagaram"
Output: true

Example 2:

1
2
Input: s = "rat", t = "car"
Output: false

Note:
You may assume the string contains only lowercase alphabets.

Follow up:
What if the inputs contain unicode characters? How would you adapt your solution to such case?

中文题目

给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词。

示例 1:

1
2
输入: s = "anagram", t = "nagaram"
输出: true

示例 2:

1
2
输入: s = "rat", t = "car"
输出: false

说明:
你可以假设字符串只包含小写字母。

进阶:
如果输入字符串包含 unicode 字符怎么办?你能否调整你的解法来应对这种情况?

Read more »

leetCode-0215_数组中的第K个最大元素

Posted on 2018-11-04 | In 算法

题目描述

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

Example 1:

1
2
Input: [3,2,1,5,6,4] and k = 2
Output: 5

Example 2:

1
2
Input: [3,2,3,1,2,4,5,5,6] and k = 4
Output: 4

Note:
You may assume k is always valid, 1 ≤ k ≤ array’s length.

中文题目

在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。

示例 1:

1
2
输入: [3,2,1,5,6,4] 和 k = 2
输出: 5

示例 2:

1
2
输入: [3,2,3,1,2,4,5,5,6] 和 k = 4
输出: 4

说明:

你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。

Read more »

Untitled

Posted on 2018-11-04

Homebrew 包管理器 系统方面工具

image-20181104091020104

vi ~/.bash_profile

ban.ninja

Source ~/.bash_profile

Node js方面的工具

不要使用cnpm,在reactNative

Yarn

reactnative-cli

必装

Watchman

不建议安装Flow

不建议安装Nuclide

数据结构-图

Posted on 2018-10-30 | In 数据结构

图:是由顶点的有穷非空集合和顶点之间边的集合组成,通常表示为:G(V,E),其中,G表示一个图,V是图G中顶点的集合,E是图G中边的集合。

线性表:数据元素叫元素,空表

树:数据元素叫结点,空树

图:数据元素叫顶点,不允许没有顶点

无向边:若顶点vi到vj之间的边没有方向,则称这边为无向边,用无需偶对(vi,vj)来表示。任意两个顶点之间都是无向边,称为无向图。

有向边:若从顶点vi到vj的边有方向,则称这边为有向边,也称为弧,用有序偶<vi,vj>来表示,vi为弧尾,vj为弧头。任意两个顶点之间都是有向边,称为有向图。

在图中,若不存在顶点到其自身的边,且同一条边不重复出现,则称这样的图为简单图。

在无向图中,如果任意两个顶点之间都存在边,则称该图为无向完全图。n个顶点有n(n-1)/2条边

在有向图中,如果任意两个顶点之间都存在方向相互相反的两条弧,则称该图为有向完全图。n个顶点有n(n-1)条边

有很少条边或弧的图称为稀疏图,反之称为稠密图。

与图的边或弧相关的树叫做权

带权的图称为网

假设有两个图G=(V,{E})和G’=(V’,{E’}),如果V’∈V且E’∈E,则称G’为G的子图

TD(v)无向图的度,及关联边的数目

ID(v)有向图的入度,顶点v为弧头的数目

OD(v)有向图的出度,顶点v为弧尾的数目

TD(v) = ID(v)+OD(v)

路径的长度就是路径上的边或弧的数目

第一个顶点到最后一个顶点相同的路径称为回路或环。序列中顶点不重复出现的路径称为简单路径。简单回路和简单环

123…6
LiYouCheng2014

LiYouCheng2014

iOS\算法\项目管理

56 posts
8 categories
29 tags
GitHub E-Mail
© 2018 LiYouCheng2014
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4