[swift] LeetCode 75. Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.

Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.

Note:
You are not suppose to use the library’s sort function for this problem.

[swift] LeetCode 62. Unique Paths

A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).

How many possible unique paths are there?
Above is a 3 x 7 grid. How many possible unique paths are there?

Note: m and n will be at most 100.

 

[swift] LeetCode 53. Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
For example, given the array [−2,1,−3,4,−1,2,1,−5,4],
the contiguous subarray [4,−1,2,1] has the largest sum = 6.
click to show more practice.
More practice:
If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

【note】Swift初见笔记

 

Swift 3: let sortedNumbers = numbers.sort { $0 > $1 } print(sortedNumbers) 结果显示为()

会发现输出结果为( )
如果改成

会出现报错:’sort’ has been renamed to ‘sorted(by:)’

所以知道这段代码应该改为:

这样才能正确输出结果~

【iOS】使用SQLite3的时候Swift3.、XCode8报错:Unsupported architecture – ‘arm/arch.h’file not found – Could not build module ‘Darwin’ – Could not build module ‘sqlite3’ – Failed to import bridging header ‘…..’

如果出现了找不到模块的错误,并且有如下报错:

  • Unsupported architecture
  • ‘arm/arch.h’file not found
  • Could not build module ‘Darwin’
  • Could not build module ‘sqlite3’
  • Failed to import bridging header ‘…..’

snip20161202_80

snip20161202_82

解决方法:在自己编写的SQLiteManager文件里面不需要写import sqlite3这句话。。直接使用SQLite语句就行了