LikeABossApp

我養罷個,罷個養我

[LeetCode] 645. Set Mismatch

Description

The set  S originally contains numbers from 1 to  n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of one number and loss of another number.

Given an array  nums representing the data status of this set after the error. Your task is to firstly find the number occurs twice and then find the number that is missing. Return them in the form of an array.

Example 1:

Input: nums = [1,2,2,4]
Output: [2,3]

Note:

  1. The given array size will in the range [2, 10000].
  2. The given array’s numbers won’t have any order.

(繼續閱讀…)

[LeetCode] 1. Two Sum

Description

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].

(繼續閱讀…)

Streaks vs. Productive 兩款習慣養成app

 Streaks

頹廢人生中想培養一些好的習慣,曾經用過獲得Apple設計獎推薦的Streaks,

Streaks是一個介面乾淨、簡單易用的習慣追蹤app,新增任務有一些預設的選項,也可以自行輸入自訂的任務內容,

任務日分為「每天」、「每週」或是「每2天」,此外可以設定任務的完成數,用來追蹤一天需要服用數次的藥物或維他命也沒問題,

另外Streaks提供了大量的圖示可以選擇,方便使用者自訂各式情境的任務。 (繼續閱讀…)

The Core Data Stack學習記錄

The managed object model

NSManagedObjectModel表示app中每個物件類型的數據模式

Note:NSManagedObjectModel是怎麼聯繫數據模式的?我們可以在Xcdoe上創建與編輯xcdatamodel這個文件,有一個特別的compiler(編譯器)叫momc,它complies model文件成為一套文件,然後放進一個momd資料夾中。

Core Data用momd資料夾中的內容在runtime初始化NSManagedObjectModel (繼續閱讀…)

關於lazy variable

lazy variable從iOS 7.0開始加入

當你需要的時候才建立複雜的object在iOS中是非常普遍的,Swift有一個適合運用在即時複雜運算的機制 – lazyvariable,

這些variable會利用function來建立,只有在被呼叫時才會跑function裡的內容,

整體來說可以節省處理的時間。 (繼續閱讀…)