UpperBound

UpperBound

Upper Bound 是使用二分查找的办法求 大于 i 的第一个位置

阅读更多

Wild Card Matching

题目

Wild Card Matchin

Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for ‘?’ and ‘*’.

‘?’ Matches any single character.
‘*’ Matches any sequence of characters (including the empty sequence).
The matching should cover the entire input string (not partial).

Note:

s could be empty and contains only lowercase letters a-z.
p could be empty and contains only lowercase letters a-z, and characters like ? or *.

Example 1:

1
2
3
4
5
Input:
s = "aa"
p = "a"
Output: false
Explanation: "a" does not match the entire string "aa".

Example 2:

1
2
3
4
5
Input:
s = "aa"
p = "*"
Output: true
Explanation: '*' matches any sequence.

Example 3:

1
2
3
4
5
Input:
s = "cb"
p = "?a"
Output: false
Explanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.

Example 4:

1
2
3
4
5
Input:
s = "adceb"
p = "*a*b"
Output: true
Explanation: The first '*' matches the empty sequence, while the second '*' matches the substring "dce".

Example 5:

1
2
3
4
Input:
s = "acdcb"
p = "a*c?b"
Output: false
阅读更多

Longest Valid Parentheses

题目

Longest Valid Parentheses
Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.

Example 1:

1
2
3
4
Input: "(()"
Output: 2
Explanation: The longest valid parentheses substring is "
()"

Example 2:

1
2
3
Input: ")()())"
Output: 4
Explanation: The longest valid parentheses substring is "()()"
阅读更多

SuperSign

超级签名

证书类型

整数类型 使用场景
开发(Development)证书和描述文件 用于开发测试,在Xcode中打包后,可在真机环境调试、安装
发布(Distribution)证书和描述文件 * 发布(Distribution)证书和描述文件:用于提交Appstore,在Xcode中打包后,可使用Xcode、Application Loader提交到Appstore审核发布
阅读更多

Weakly Contest 169

题目

Weakly Contest 169

题目一

5295. Find N Unique Integers Sum up to Zero

Given an integer n, return any array containing n unique integers such that they add up to 0.

Example 1:

1
2
3
Input: n = 5
Output: [-7,-1,1,3,4]
Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].

Example 2:

1
2
3
4
5
6
7
8
9
10
Input: n = 3
Output: [-1,0,1]
Example 3:

Input: n = 1
Output: [0]

Constraints:

1 <= n <= 1000
阅读更多

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

题目

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbours of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighboors if they share one edge.

Return the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.

Binary matrix is a matrix with all cells equal to 0 or 1 only.

Zero matrix is a matrix with all cells equal to 0.

Example 1:

1
2
3
Input: mat = [[0,0],[0,1]]
Output: 3
Explanation: One possible solution is to flip (1, 0) then (0, 1) and finally (1, 1) as shown.

Example 2:

1
2
3
Input: mat = [[0]]
Output: 0
Explanation: Given matrix is a zero matrix. We don't need to change it.

Example 3:

1
2
3
4
5
6
7
Input: mat = [[1,1,1],[1,0,1],[0,0,0]]
Output: 6
Example 4:

Input: mat = [[1,0,0],[1,0,0]]
Output: -1
Explanation: Given matrix can't be a zero matrix

Constraints:

1
2
3
4
5
m == mat.length
n == mat[0].length
1 <= m <= 3
1 <= n <= 3
mat[i][j] is 0 or 1.
阅读更多

探索 NSDictionary

Exposing NSDictinoary

The Class

相当多的类都是 class clusters,当然 NSDictionary 也不例外,曾经一段时间 NSDictinoary 使用了 CFDictionary 作为它的默认实现。然而,在 iOS 6以后事情改变了。。。

阅读更多

单例如何释放

iOS weak关键字

weak 关键字的运用在 iOS 当中属于基础知识,在面试的时候问 weak 的用处,就像两个 iOS 程序员见面寒暄问候一样普通了。

weak 的常见场景是在 delegate,block,NSTimer 中使用,以避免循环引用所带来的内存泄漏,这是教科书式的用法。

编程语言是工具,语言特性只是工具的特性,工具怎么用在于使用者。weak 关键字的方便之处绝不局限于避免循环引用,适当脑洞,可以在其他场景下带来一些有趣的应用。

weak 的用处用一句话可归纳为:弱引用,在对象释放后置为 nil,避免错误的内存访问。用更通俗的话来表述是:weak 可以在不增加对象的引用计数的同时,又使得指针的访问是安全的。

阅读更多
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×