Facebook算法swift实现

艾国安
2023-12-01

写作时间:2018-07~2018-08
Swift 4.2, IDE: Xcode 10

算法解决题目为 LeetCode 上 Facebook 的面试题目:

1,10,13,15,17,20,23,25,26,28,33,38,43,44,49,50,56,57,67,68,69,71,75,76
78,79,80,85,88,90,91,98,102,117,121,125,127,128,133,139,146,157,158,161
168,173,200,206,208,209,210,211,215,218,221,234,235,236,238,252,253,257
261,265,269,273,274,275,277,278,282,283,285,286,297,301,311,314,325,334
341,377,380,398,404,410,461,477,494,523,525,534,535,543,554

java 实现的代码: awesome-java-leetcode, 更新原有库一些没有实现的算法。

如果想知道更多公司 LeetCode 面试题,可以参看 Companies.md

代码下载:
https://github.com/zgpeace/awesome-swift-leetcode

Easy

#TitleTag
1Two SumArray, Hash Table
7Reverse IntegerMath
9Palindrome NumberMath
13Roman to IntegerMath, String
14Longest Common PrefixString
20Valid ParenthesesStack, String
21Merge Two Sorted ListsLinked List
26Remove Duplicates from Sorted ArrayArray, Two Pointers
27Remove ElementArray, Two Pointers
28Implement strStr()Two Pointers, String
35Search Insert PositionString
38Count and SayString
53Maximum SubarrayArray, Divide and Conquer, Dynamic Programming
58Length of Last WordString
66Plus OneArray, Math
67Add BinaryMath, String
69Sqrt(x)Binary Search, Math
70Climbing StairsDynamic Programming
83Remove Duplicates from Sorted ListLinked List
88Merge Sorted ArrayArray, Two Pointers
100Same TreeTree, Depth-first Search
101Symmetric TreeTree, Depth-first Search, Breadth-first Search
104Maximum Depth of Binary TreeTree, Depth-first Search
107Binary Tree Level Order Traversal IITree, Breadth-first Search
108Convert Sorted Array to Binary Search TreeTree, Depth-first Search
110Balanced Binary TreeTree, Depth-first Search
111Minimum Depth of Binary TreeTree, Depth-first Search, Breadth-first Search
112Path SumTree, Depth-first Search
118Pascal’s TriangleArray
119Pascal’s Triangle IIArray
121Best Time to Buy and Sell StockArray, Dynamic Programmin
122Best Time to Buy and Sell Stock IIArray, Greedy
543Diameter of Binary TreeTree

Medium

#TitleTag
2Add Two NumbersLinked List, Math
3Longest Substring Without Repeating CharactersHash Table, Two Pointers, String
5Longest Palindromic SubstringString, Dynamic Programming
6ZigZag ConversionString
8String to Integer (atoi)Math, String
11Container With Most WaterArray, Two Pointers
12Integer to RomanMath, String
153SumArray, Two Pointers
163Sum ClosestArray, Two Pointers
17Letter Combinations of a Phone NumberString, Backtracking
184SumArray, Hash Table, Two Pointers
19Remove Nth Node From End of ListLinked List, Two Pointers
22Generate ParenthesesString, Backtracking
24Swap Nodes in PairsLinked List
29Divide Two IntegersMath, Binary Search
33Search in Rotated Sorted ArrayArrays, Binary Search
43Multiply StringsMath, String
49Group AnagramsHash Table, String
50Pow(x, n)Math, Binary Search
56Merge IntervalsArray, Sort
554Brick WallHash Table

Hard

#TitleTag
4Median of Two Sorted ArraysArray, Binary Search, Divide and Conquer
10Regular Expression MatchingString, Dynamic Programming, Backtracking
23Merge k Sorted ListsLinked List, Divide and Conquer, Heap
25Reverse Nodes in k-GroupLinked List
30Substring with Concatenation of All WordsHash Table, Two Pointers, String
44Wildcard MatchingString, Dynamic Programming, Backtracking, Greedy
57Insert IntervalArray, Sort
68Text JustificationString

参考: Blankj/awesome-java-leetcode

 类似资料: