Are you over 18 and want to see adult content?
More Annotations
A complete backup of healingfromgmos.com
Are you over 18 and want to see adult content?
A complete backup of livingonadime.com
Are you over 18 and want to see adult content?
A complete backup of reuniondelenguas.com
Are you over 18 and want to see adult content?
A complete backup of eaglequestgolf.com
Are you over 18 and want to see adult content?
A complete backup of ellysdirectory.com
Are you over 18 and want to see adult content?
A complete backup of pokemonfloraskyrom.com
Are you over 18 and want to see adult content?
A complete backup of attheendofasuffolklane.blogspot.com
Are you over 18 and want to see adult content?
A complete backup of crazytechtricks.com
Are you over 18 and want to see adult content?
Favourite Annotations
A complete backup of turganovanv.narod.ru
Are you over 18 and want to see adult content?
A complete backup of retirementpartner.com
Are you over 18 and want to see adult content?
A complete backup of freshersworld.com
Are you over 18 and want to see adult content?
A complete backup of gameslearnchinese.com
Are you over 18 and want to see adult content?
A complete backup of fluechtlinge-frankfurt.de
Are you over 18 and want to see adult content?
A complete backup of rette-sich-wer-kann.com
Are you over 18 and want to see adult content?
A complete backup of o0o-chibaken-o0o.tumblr.com
Are you over 18 and want to see adult content?
Text
LEETCODE#1 TWO SUM
為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。加油! 題目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 on LEETCODE#620 NOT BORING MOVIES 題目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 學習 ANDROID RXJAVA 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID 依賴注入 DEPENDENCY INJECTION (DI) JAY'S CODE - GITHUB PAGES 題目. Given a pattern and a string str, find if str follows the samepattern
JAY'S CODETRANSLATE THIS PAGE 題目. Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.LEETCODE#1 TWO SUM
為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。加油! 題目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 on LEETCODE#620 NOT BORING MOVIES 題目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 學習 ANDROID RXJAVA 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID 依賴注入 DEPENDENCY INJECTION (DI) JAY'S CODE - GITHUB PAGES 題目. Given a pattern and a string str, find if str follows the samepattern
CATEGORIES | JAY'S CODETRANSLATE THIS PAGE 目前共計 58 個分類 Android 6; Git 1; LeetCode 121. MySQL 3; SQL 3; Swift 115. Array 22. Binary Search 1; Divide and Conquer 2. Bit Manipulation 1; Dynamic Programming 1; Dynamic Programming 1; Greedy 1; Hash Table 2; Math 3. Bit Manipulation 1; Two Pointers 4. Binary Search 1; Backtracking 1. Bit Manipulation 1; Binary Search 1. Hash Table 1. Two Pointers 1. Sort 1; Binary Search Tree 1 LEETCODE#167 TWO SUM II 題目. Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less thanindex2.
LEETCODE#620 NOT BORING MOVIES 題目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output moviesLEETCODE#1 TWO SUM
為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。加油! 題目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 on LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#183 CUSTOMERS WHO NEVER ORDER 題目Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything. 給你兩個表格代表客人和點單記錄 (Customers & Orders) ,寫出一個 LEETCODE#206 REVERSE LINKED LIST 題目Reverse a singly linked list. 反轉連結串列。 解題使用遞迴讀取每一組 ListNode ,將 Node 不斷往後推。 也就是把前一次讀取的 LEETCODE#226 INVERT BINARY TREE 題目Invert a binary tree. 翻轉二元樹。 12345 4 / \ 2 7 / \ / \1 3 6 9 to 12345 4 / \ 7 2 / \ / \9 6 3 1 TriviaThis problem was inspired by this original tweet by Max Howe 學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple de 學習 RXJAVA 結合 RETROFIT 個別學習完 RxJava 與 Retrofit 之後,是令人期待的合體了呢 ! 前面的文章學習 Android Retrofit 2學習 Android RxJava 這篇文章僅僅是記錄如何將兩個框架結合在一起,不對兩者進行深入探討。 Setup設置 Gradle 除了 RxJava 與 Retrofit 的 Library 以外,還要再多設置讓兩者能夠結合的 adapter 套件。 JAY'S CODETRANSLATE THIS PAGE Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and jLEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#167 TWO SUM II The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice. LEETCODE#290 WORD PATTERN 題目Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.給定一個字串
LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#438 FIND ALL ANAGRAMS IN A STRING 題目. Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID RXJAVA JAY'S CODETRANSLATE THIS PAGE Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and jLEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#167 TWO SUM II The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice. LEETCODE#290 WORD PATTERN 題目Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.給定一個字串
LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#438 FIND ALL ANAGRAMS IN A STRING 題目. Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID RXJAVA LEETCODE#167 TWO SUM II 題目. Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less thanindex2.
LEETCODE#1 TWO SUM
為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。加油! 題目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 on LEETCODE#290 WORD PATTERN 題目Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.給定一個字串
LEETCODE#496 NEXT GREATER ELEMENT I 題目You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places ofnums2.
LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#13 ROMAN TO INTEGER 題目. Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 將羅馬文字的數字轉換為一般數字。 LEETCODE#566 RESHAPE THE MATRIX 題目In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data. You’re given a matrix represented by a two-dime LEETCODE#620 NOT BORING MOVIES LeetCode#620 Not Boring Movies - in MySQL. 發表於 2017-08-02 | 分類於 LeetCode , SQL | 0 Comments. 題目. X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies with an odd numbered ID anda
LEETCODE#20 VALID PARENTHESES 解題. 這題題目提示是一題 Stack 的題目, Swift 雖然沒有 Stack 類別 ,但 Array 也有提供 popLast的用法。
只要遇到三種括號的開頭,就將該括號的結尾加進陣列中 學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple de JAY'S CODETRANSLATE THIS PAGE Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and j LEETCODE#111 MINIMUM DEPTH OF BINARY TREE 題目Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 給定二元樹,找出最小深度。 最小深度代表由根節點至某個最近的葉節點所畫出的最 LEETCODE#496 NEXT GREATER ELEMENT I 題目You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places ofnums2.
LEETCODE#345 REVERSE VOWELS OF A STRING 題目Write a function that takes a string as input and reverse only the vowels of a string. 反轉字串,但只反轉母音的部分。 範例12Example 1:Given s = "hello", return "holle". hello 中的 eo轉換為
練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 學習 ANDROID RXJAVA 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID 依賴注入 DEPENDENCY INJECTION (DI) 學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple de JAY'S CODETRANSLATE THIS PAGE Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and j LEETCODE#111 MINIMUM DEPTH OF BINARY TREE 題目Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 給定二元樹,找出最小深度。 最小深度代表由根節點至某個最近的葉節點所畫出的最 LEETCODE#496 NEXT GREATER ELEMENT I 題目You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places ofnums2.
LEETCODE#345 REVERSE VOWELS OF A STRING 題目Write a function that takes a string as input and reverse only the vowels of a string. 反轉字串,但只反轉母音的部分。 範例12Example 1:Given s = "hello", return "holle". hello 中的 eo轉換為
練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 學習 ANDROID RXJAVA 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID 依賴注入 DEPENDENCY INJECTION (DI) 學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple de LEETCODE#496 NEXT GREATER ELEMENT I 題目You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places ofnums2.
LEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#111 MINIMUM DEPTH OF BINARY TREE 題目Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 給定二元樹,找出最小深度。 最小深度代表由根節點至某個最近的葉節點所畫出的最 LEETCODE#345 REVERSE VOWELS OF A STRING 題目Write a function that takes a string as input and reverse only the vowels of a string. 反轉字串,但只反轉母音的部分。 範例12Example 1:Given s = "hello", return "holle". hello 中的 eo轉換為
LEETCODE#206 REVERSE LINKED LIST 題目Reverse a singly linked list. 反轉連結串列。 解題使用遞迴讀取每一組 ListNode ,將 Node 不斷往後推。 也就是把前一次讀取的 LEETCODE#167 TWO SUM II The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice. LEETCODE#620 NOT BORING MOVIES LeetCode#620 Not Boring Movies - in MySQL. 發表於 2017-08-02 | 分類於 LeetCode , SQL | 0 Comments. 題目. X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies with an odd numbered ID anda
LEETCODE#217 CONTAINS DUPLICATE 題目Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element LEETCODE#453 MINIMUM MOVES TO EQUAL ARRAY …TRANSLATE THIS PAGE 題目Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1. 給數字陣列,找出最少的步數可以把全部的元素變成相等。每一步 學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple de JAY'S CODETRANSLATE THIS PAGE Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and jLEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#167 TWO SUM II The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice. LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#13 ROMAN TO INTEGER 題目. Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 將羅馬文字的數字轉換為一般數字。 LEETCODE#290 WORD PATTERN 題目Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.給定一個字串
學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習 ANDROID RXJAVA 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? JAY'S CODETRANSLATE THIS PAGE Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and jLEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#167 TWO SUM II The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice. LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#13 ROMAN TO INTEGER 題目. Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 將羅馬文字的數字轉換為一般數字。 LEETCODE#290 WORD PATTERN 題目Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.給定一個字串
學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習 ANDROID RXJAVA 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? LEETCODE#167 TWO SUM II 題目. Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less thanindex2.
LEETCODE#1 TWO SUM
為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。加油! 題目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 on LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#290 WORD PATTERN 題目Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.給定一個字串
LEETCODE#13 ROMAN TO INTEGER 題目. Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 將羅馬文字的數字轉換為一般數字。 LEETCODE#401 BINARY WATCH 題目A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on LEETCODE#566 RESHAPE THE MATRIX 題目In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data. You’re given a matrix represented by a two-dime LEETCODE#438 FIND ALL ANAGRAMS IN A STRING 題目. Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of LEETCODE#620 NOT BORING MOVIES LeetCode#620 Not Boring Movies - in MySQL. 發表於 2017-08-02 | 分類於 LeetCode , SQL | 0 Comments. 題目. X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies with an odd numbered ID anda
學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple deJAY'S CODE
Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and j LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with aLEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#206 REVERSE LINKED LIST 題目Reverse a singly linked list. 反轉連結串列。 解題使用遞迴讀取每一組 ListNode ,將 Node 不斷往後推。 也就是把前一次讀取的 LEETCODE#438 FIND ALL ANAGRAMS IN A STRING 題目. Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID RXJAVA 學習 ANDROID 依賴注入 DEPENDENCY INJECTION (DI)JAY'S CODE
Jay's Code. LeetCode#219 Contains Duplicate II - in Swift. 發表於 2017-11-13 | 分類於 LeetCode , Swift , Array , Hash Table | 0 Comments. 題目. Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and j LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with aLEETCODE#1 TWO SUM
LeetCode#1 Two Sum - in Swift. 發表於 2017-07-22 | 分類於 LeetCode , Swift | 0 Comments. 為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。. 加油!. 題目. Given an array of integers, return indices of the two numbers such that they add up to a specific LEETCODE#206 REVERSE LINKED LIST 題目Reverse a singly linked list. 反轉連結串列。 解題使用遞迴讀取每一組 ListNode ,將 Node 不斷往後推。 也就是把前一次讀取的 LEETCODE#438 FIND ALL ANAGRAMS IN A STRING 題目. Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of 學習版本控制基礎 版本控制是什麼,為什麼要學剛開始踏入軟體工程師的工作,懵懵懂懂的開發了兩個App,很菜的還真的自己新建了好多資料夾,複製了好幾次更新的Project,開新文字檔標示每個的差異。這時才發現原來有版本控制這種東西。 上網查了一下,版本控制已經有一段歷史,從集中式版本控制的CVS、Subversion 練習在 ANDROID 設計上的 MVC, MVP, MVVM 架構 一個人單打獨鬥設計 App ,可能不需要太講究架構,而是注重 App 的完整性與功能性,但是太凌亂的設計開發,反而會降低開發的效率,在未來的維護也會造成很大的麻煩。 層次分明、架構清楚漂亮的代碼,能夠實現低耦合的模組化,不但看起來賞心悅目,也讓自己在開發測試上變得更容易。 學習 ANDROID RETROFIT 2 Retrofit 是什麼 ? 我也是學習 RxJava 途中才知道, Retrofit 跟 Volley 一樣是 Android 一種 HTTP 請求的框架,但實際操作了一遍,感覺比 Volley 還要更簡便,而且能夠支援 RxJava 的關係,必須要學習一下。 好文參考【Android】Retrofit 2.0 的使用Android Retrofit 2.0使用你真的会用Retrofit2吗? 學習 ANDROID RXJAVA 學習 ANDROID 依賴注入 DEPENDENCY INJECTION (DI)LEETCODE#1 TWO SUM
為了增進自己的基礎,從今天開始每天使用Swift解一題LeetCode。加油! 題目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 on LEETCODE#627 SWAP SALARY 題目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermedia LEETCODE#167 TWO SUM II The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution and you may not use the same element twice. LEETCODE#206 REVERSE LINKED LIST 題目Reverse a singly linked list. 反轉連結串列。 解題使用遞迴讀取每一組 ListNode ,將 Node 不斷往後推。 也就是把前一次讀取的 LEETCODE#620 NOT BORING MOVIES LeetCode#620 Not Boring Movies - in MySQL. 發表於 2017-08-02 | 分類於 LeetCode , SQL | 0 Comments. 題目. X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies with an odd numbered ID anda
LEETCODE#20 VALID PARENTHESES 解題. 這題題目提示是一題 Stack 的題目, Swift 雖然沒有 Stack 類別 ,但 Array 也有提供 popLast的用法。
只要遇到三種括號的開頭,就將該括號的結尾加進陣列中 LEETCODE#226 INVERT BINARY TREE 題目Invert a binary tree. 翻轉二元樹。 12345 4 / \ 2 7 / \ / \1 3 6 9 to 12345 4 / \ 7 2 / \ / \9 6 3 1 TriviaThis problem was inspired by this original tweet by Max Howe LEETCODE#438 FIND ALL ANAGRAMS IN A STRING 題目. Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of LEETCODE#521 LONGEST UNCOMMON SUBSEQUENCE I 注意這應該是個愚人節題目。 題目Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence 學習在 XCODE 8 進行 IOS 上架 第一次要挑戰將 App 上架到 App Store,可是卻發現更新到 Xcode 8 之後,Xcode 預設進行了 Automatically Manage Signing 的動作,自動生成了 App ID 、 Certificate 、 provisioning profiles 。在還沒搞懂 Apple 上架流程的情況,網路上又找不太到相關的教學,搞得頭昏眼花 最後還是回到 Apple de__ Jay's Code __
Study Recording
* __
首頁
* __
分類
* __
歸檔
* __
標籤
* __
檢索
__ __
LEETCODE#219 CONTAINS DUPLICATE II - IN SWIFT __ 發表於 2017-11-13 | __ 分類於 LeetCode, Swift ,
Array , Hash Table| __ 0 Comments
題目
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums = nums and the absolute difference between i and j is at most k. 給一組整數陣列,找出陣列是否包含重複的數字,且重複的數字未在 i 和 j 索引的距離,不超過 k 。 -------------------------範例
Example 1:
1
2
Input: , 3
Output: true
陣列中 2 出現重複,且第一個索引 1 與第二個索引 4 的距離不超過 3 ,返回 true 。Example 2:
1
2
Input: , 2
Output: false
陣列中 2 出現重複,且第一個索引 1 與第二個索引 4 的距離超過 2 ,返回 false 。 -------------------------解題
將 nums 每一個值依序加進 set 裡面,如果 set 無法新增,代表已經重複。 如果指針 i 超過 k 之後,就開始刪除 set 裡面超過距離的值。1
2
3
4
5
6
7
8
func containsNearbyDuplicate(_ nums: , _ k: Int) -> Bool { var set = Set}
return false
}
LEETCODE#203 REMOVE LINKED LIST ELEMENTS - IN SWIFT __ 發表於 2017-11-12 | __ 分類於 LeetCode, Swift ,
Linked List | __ 0 Comments題目
Remove all elements from a linked list of integers that have valueval.
刪除鏈結串列中,題目所指定的值。 -------------------------範例
Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5 題目指定從鏈結串列中刪除所有 6 的值。 -------------------------解題
檢查每一個節點的值是否和目標值相同,如果相同則返回 next ,不同則返回該節點。 利用該判斷遞迴,就可以將所有不為目標值的節點,接在一起。1
2
3
4
5
func removeElements(_ head: ListNode?, _ val: Int) -> ListNode? { guard let head = head else { return nil } head.next = removeElements(head.next, val) return head.val == val ? head.next : head}
LEETCODE#687 LONGEST UNIVALUE PATH - IN SWIFT __ 發表於 2017-11-11 | __ 分類於 LeetCode, Swift ,
Tree , Recursion
| __ 0 Comments
題目
Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not passthrough the root.
給一個二元樹,找出一條最長,且連續出現一樣節點值的路徑,這條路徑可能通過節點也可能沒通過節點。 -------------------------範例
Example 1:
1
2
3
4
5
6
7
8
9
10
11
Input:
5
/ \
4 5
/ \ \
1 1 5
Output: 2
5 -> 5 -> 5 的長度為 2Example 2:
1
2
3
4
5
6
7
8
9
10
11
Input:
1
/ \
4 5
/ \ \
4 4 5
Output: 2
4 -> 4 -> 4 的長度為 2 -------------------------解題
利用遞迴比對每個節點的左右兩節點,如果與該節點相同值,就會回傳已累積的長度+ 1 。
並且定義一個最大長度 len ,在每節點的比對中,刷新 len 的最大值。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
func longestUnivaluePath(_ root: TreeNode?) -> Int { guard let root = root else { return 0 }var len = 0
func getLength(_ root: TreeNode?, _ val : Int) -> Int{ guard let root = root else { return 0 } let left = getLength(root.left, root.val) let right = getLength(root.right, root.val) len = max(len, left + right) if val == root.val { return max(left, right) + 1 }return 0
}
getLength(root, root.val)return len
}
LEETCODE#234 PALINDROME LINKED LIST - IN SWIFT __ 發表於 2017-11-10 | __ 分類於 LeetCode, Swift ,
Linked List , Two Pointers| __ 0 Comments
題目
Given a singly linked list, determine if it is a palindrome. 給一個鏈結串列,判斷他是否回文。Follow up:
Could you do it in O(n) time and O(1) space? 你可以使用 O(n) 的時間與 O(1) 的空間來解出題目嗎 ? -------------------------解題
題目要求 O(1)
的空間,所以不使用多餘的字串或陣列來驗證。 利用 slow 和 fast 指針,將 slow 指向串列的中間點,1
2
1->2->3->2->1
s f
這時候將 s 進行反轉,獲得 rev 串列1
3->2->1 = 1->2->3
再來比對 rev 和 head 是否相等,若有不相等,返回false
若執行至 rev 結束,都是相等,返回 true1
2
rev : 1->2->3
head : 1->2->3->4->5 -------------------------主程式碼 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
func isPalindrome(_ head: ListNode?) -> Bool { var fast = head, slow = head, head = head while fast != nil && fast!.next != nil { fast = fast?.next?.nextslow = slow?.next
}
var rev = reverse(slow) while rev != nil && head != nil { if rev?.val != head?.val {return false
}
head = head?.next
rev = rev?.next
}
return true
}
反轉串列函式 :1
2
3
4
5
6
7
8
9
10
11
func reverse(_ head: ListNode?) -> ListNode? { var pre: ListNode?var cur = head
while cur != nil { let next = cur?.nextcur?.next = pre
pre = cur
cur = next
}
return pre
}
LEETCODE#67 ADD BINARY - IN SWIFT __ 發表於 2017-11-09 | __ 分類於 LeetCode, Swift ,
Math , String
| __ 0 Comments
題目
Given two binary strings, return their sum (also a binary string). 給兩個二元字串,返回他們的加總 (也是一個二元字串)。 -------------------------範例
a = “11”
b = “1”
Return “100”.
“11” 十進位為 3 , “1” 十進位為 1 ,相加為 4 ,二進位為 “100” -------------------------解題
將兩個字串轉為字元陣列,定義一個 sum 擺放加總結果,與 carry 判斷是否進位。 從兩個陣列尾端開始做相加,如果加總大於等於 2 ,將加總減去 2 ,且代表需要進位,將 carry 值帶至下一次加總。 每次加總完畢,放入 sum 的第一個位置。 最後結束迴圈時,若還有剩下的 carry 值,放進 sum ,返回 sum 的字串。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
func addBinary(_ a: String, _ b: String) -> String {let a = Array(a)
let b = Array(b)
var i = a.count, j = b.countvar sum = ()
var carry = 0
while i != 0 || j != 0 { var first = 0, second = 0 if i - 1 >= 0 { first = Int(String(a))! } if j - 1 >= 0 { second = Int(String(b))! } var temp = first + second + carrycarry = 0
if temp >= 2 {
temp -= 2
carry += 1
}
sum.insert(Character(String(temp)), at: 0) if i != 0 { i -= 1 } if j != 0 { j -= 1 }}
if carry == 1 { sum.insert(Character(String(carry)), at: 0) }return String(sum)
}
LEETCODE#290 WORD PATTERN - IN SWIFT __ 發表於 2017-11-08 | __ 分類於 LeetCode, Swift ,
Hash Table | __ 0 Comments題目
Given a pattern and a string str, find if str follows the samepattern.
Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. 給定一個字串格式 pattern 和字串 str ,驗證 str 是否符合 pattern 的格式。Notes:
You may assume pattern contains only lowercase letters, and str contains lowercase letters separated by a single space. pattern 字串只包含小寫字母, str 字串包含小寫字母,和用空白分隔段落。 -------------------------範例
pattern = “abba”, str = “dog cat cat dog” should return true. pattern = “abba”, str = “dog cat cat fish” should returnfalse.
pattern = “aaaa”, str = “dog cat cat dog” should return false. pattern = “abba”, str = “dog dog dog dog” should return false. “dog cat cat dog” 符合 “abba” 的格式,返回 true “dog cat cat fish” 不符合 “abba” 的格式 ,應為 “abbc” ,返回 false “dog cat cat dog” 不符合 “aaaa” 的格式,應為 “abba” ,返回 false “dog dog dog dog” 不符合 “abba” 的格式,應為 “aaaa” ,返回 false -------------------------解題
將 str 用空白切割與 pattern 一同轉為 Array ,如果兩個 Array 不同長度代表不合格式。 開始遍歷兩個陣列各取 p 和 s ,如果 p 已經出現在 hashTable 的 key 裡,查看他的 val 是否與 s 相同,不同就代表不合格式。 如果沒出現過,則查看 s 是否已經出現在 hashTable 的 val 裡,如果有,代表他已經與不同的 key 配對過了,不合格式。 如果上面兩關都通過,將 p 對應 s 加進 hashTable 裡。 遍歷結束都沒有返回 false 代表格式正確。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
func wordPattern(_ pattern: String, _ str: String) -> Bool { if pattern.isEmpty && str.isEmpty { return false } let p = Array(pattern) let s = str.split(separator: " ")var dict = ()
if p.count != s.count { return false }var i = 0
while i != p.count { if let pre = dict { if pre != String(s) { return false }} else {
if dict.values.contains(String(s)) { return false }dict = String(s)
}
i += 1
}
return true
}
LEETCODE#111 MINIMUM DEPTH OF BINARY TREE - IN SWIFT __ 發表於 2017-11-07 | __ 分類於 LeetCode, Swift ,
Tree , Depth-first Search| __ 0 Comments
題目
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 給定二元樹,找出最小深度。 最小深度代表由根節點至某個最近的葉節點所畫出的最短路徑。 -------------------------範例
1
2
3
4
5
6
7
8
Input:
1
/ \
2 3
/ \
4 5
Output: 2
有一條最短路徑為 1 -> 3 ,其深度為 2 。 -------------------------解題
對樹進行 dps ,並且每下一層就將 depth 值 + 1 ,直到走到葉節點時, 比對這條路徑的深度跟答案的最小值,即可求出最終答案。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
func minDepth(_ root: TreeNode?) -> Int { if root == nil { return 0 } var res = Int.max func dig(_ root: TreeNode?, _ depth: Int) { guard let root = root else { return } var depth = depthdepth += 1
if root.left == nil && root.right == nil { res = min(depth, res)}
dig(root.left, depth) dig(root.right, depth)}
dig(root, 0)
return res
}
LEETCODE#20 VALID PARENTHESES - IN SWIFT __ 發表於 2017-11-06 | __ 分類於 LeetCode, Swift ,
String , Stack
| __ 0 Comments
題目
Given a string containing just the characters '(', ')', '{', '}', '', determine if the input string is valid. The brackets must close in the correct order, "()" and "(){}" are all valid but "(]" and "(" are not. 給一個字串,裡面只會包含 '(', ')', '{', '}', '' ,現在驗證字串是否符合格式。 這些括號,必須要按照正確的順序合起來, "()" 或 "(){}" 就是正確的,但 "(]" 或 "(" 就不是。 -------------------------範例
Example 1:
1
2
Input : "({})"
Output : True
這是正確的括號開始跟結尾的用法。Example 2:
1
2
Input: "{{]}"
Output: False
這是錯誤的括號用法。 -------------------------解題
這題題目提示是一題 Stack 的題目, Swift 雖然沒有 Stack 類別 ,但 Array 也有提供 popLast 的用法。 只要遇到三種括號的開頭,就將該括號的結尾加進陣列中 若遇到三種括號的結尾時,陣列為空代表根本沒出現過開頭,回傳false 。
若陣列的 popLast 回傳的第一個元素,不等於自己,代表開頭不對稱,也回傳false 。
最後若跑完字串,陣列被 pop 到空的,就是一個 valid 的字串,回傳 true 。1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
func isValid(_ s: String) -> Bool {let s = Array(s)
var stack = ()
for c in s {
switch c {
case "(":
stack.append(")")
case "{":
stack.append("}")
case "")
default:
if stack.isEmpty { return false } if let pop = stack.popLast(), pop != String(c) {return false
}
}
}
return stack.isEmpty}
LEETCODE#507 PERFECT NUMBER - IN SWIFT __ 發表於 2017-11-05 | __ 分類於 LeetCode, Swift ,
Math | __ 0 Comments題目
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write a function that returns true when it is a perfect number and false when it is not. 我們定義一個「完美數」是一個正整數,且他的全部因數除了自己本身,加起來等於他自己。 現在給你一整數 n ,寫出一個函式驗證該數是否為完美數。 -------------------------範例
1
2
3
4
5
Input: 28
Output: True
Explanation: 28 = 1 + 2 + 4 + 7 + 14 28 的全部因數有 1, 2, 4, 7, 14, 28 ,排除 28 ,其他加起來又等於 28 ,所以返回 true -------------------------解題
先求 num 的所有因子,由於 1 為每個數的因子,所以將 1 先加進 sum 裡面 判斷 s 的因子只需要從範圍 下手,判斷這個範圍內的 i 是否可以被 num 整除 如果可以整除,代表 i 和 num/i 都是 num 的因子,加進sum 中
最後判斷 sum 是否等於 num 即可1
2
3
4
5
6
7
8
9
10
11
12
import Foundation
func checkPerfectNumber(_ num: Int) -> Bool { if num <= 1 { return false } var sum = 1, i = 2, s = Int(sqrt(Double(num)))while i <= s {
if num % i == 0 { sum += i + (num / i) }i += 1
}
return sum == num}
LEETCODE#438 FIND ALL ANAGRAMS IN A STRING - IN SWIFT __ 發表於 2017-11-04 | __ 分類於 LeetCode, Swift ,
Hash Table | __ 0 Comments題目
Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100. The order of output does not matter. 給定字串 s 和不為空的字串 p ,找出所有 s 中可能包含 p 的重組字。 兩個字串 s, p 皆只存在小寫英文字母,且長度不超過20,100 。
答案的順序不同沒關係。 -------------------------範例
Example 1:
1
2
3
4
5
6
7
8
9
Input:
s: "cbaebabacd" p: "abc"Output:
Explanation:
The substring with start index = 0 is "cba", which is an anagram of "abc". The substring with start index = 6 is "bac", which is an anagram of "abc". “cbaebabacd” 中,從 0 開始的 cba 是 abc 的重組字,從 6 開始的 bac 也是 abc 的重組字。所以回傳
Example 2:
1
2
3
4
5
6
7
8
9
10
Input:
s: "abab" p: "ab"Output:
Explanation:
The substring with start index = 0 is "ab", which is an anagram of "ab". The substring with start index = 1 is "ba", which is an anagram of "ab". The substring with start index = 2 is "ab", which is an anagram of "ab". “abab” 中,從 0 開始的 ab 是 ab 的重組字,從 1 開始的 ba 是 ab 的重組字,從 2 開始的 ab 也是 ab的重組字。
所以回傳
-------------------------解題
解題中需要找到字元所對應的 ASCII 編號 , Swift 中要找到編號運用下方的函式1
2
3
func getHash(_ c: Character) -> Int { return Int(c.unicodeScalars.first!.value)}
接著運用 Sliding Window algorithm template 來解決這一個問題 :1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
func findAnagrams(_ s: String, _ p: String) -> {var res = ()
var s = Array(s), p = Array(p) // 用來定義 ASCII 256 個字元符號的 Hash 表 var hash = (repeating: 0, count: 256) // 將 p 的字元裝進 Hash 表中for c in p {
hash += 1
}
// 定義 Two Pointers , left 代表重組字的起始位置, right 代表重組字的尾巴 // 以及 p 的長度 (用來代表在 p 寬度內要完成所有的配對才算一個重組字) var left = 0 , right = 0 , count = p.count // 將 s 由 0 開始每次往右移 1 格 while right < s.count { // 如果 hash 表中有存在該字元,就將 count - 1 代表越來越接近重組字。if hash >= 1 {
count -= 1
}
// 對該字元對應在 hash 表 - 1 , s 右移 1 格hash -= 1
right += 1
// 如果該次 count == 0 ,代表 count 內的字元皆可替換,找到一個重組字 // 在答案中放入 left 的值 if count == 0 { res.append(left) } // 如果 s 的字元已經走到一組 p 的長度了, left 也需要往右移一格 if right - left == p.count { // 查看 hash 表的 left 是否有大於等於 0 ,如果有代表剛剛該 left 有被算入正確的重組字中 // 所以要把 count + 1 平衡回去if hash >= 0 {
count += 1
}
// 因為前面有將 hash 表該字元 - 1 ,所以要平衡回去hash += 1
// left 往右移 1 格left += 1
}
}
return res
}
12 …14 __
Jay Wang
慢慢學習。
131 文
58 分類
44 標籤
__ RSS
2017 __ Jay Wang
由 Hexo 強力驅動主題 - NexT.Mist
__
Details
Copyright © 2024 ArchiveBay.com. All rights reserved. Terms of Use | Privacy Policy | DMCA | 2021 | Feedback | Advertising | RSS 2.0