sunbrice / LeetCode-Solutions-in-Swift

Get prepared for your next iOS job interview by studying high quality LeetCode solutions in Swift 2.0.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WWDC 2015 Session: What's New in Swift 2.0

####LeetCode Solutions in Swift 2.0

  • Designed for your next iOS job interview.
  • Optimal solutions handpicked from the LeetCode community.
  • Best time/space complexity guaranteed.
  • Written with the latest Swift 2.0 language features in mind.
  • Comprehensive test cases guarding against wrong answers and timeouts.
  • A work in progress. Now at 80 / ( 273 Totol - 32 Paid Subscription ) = 33.2%.

Requires Xcode 7 Beta 6 (Build 7A192o).

  1. Two Sum - Medium - Solution - Test Cases - t=O(N), s=O(N)
  2. Add Two Numbers - Medium - Solution - Test Cases - t=O(N), s=O(1)
  3. Longest Substring Without Repeating Characters - Medium - Solution - Test Cases - t=O(N), s=O(1)
  4. Median of Two Sorted Arrays - Hard - Solution - Test Cases - t=O(log(min(m,n))), s=O(1)
  5. Longest Palindromic Substring - Medium - Solution - Test Cases - t=O(N^2), s=O(1)
  6. ZigZag Conversion - Easy - Solution - Test Cases - t=O(N), s=O(N)
  7. Reverse Integer - Easy - Solution - Test Cases - t=O(N), s=O(1)
  8. String to Integer (atoi) - Easy - Solution - Test Cases - t=O(N), s=O(1)
  9. Palindrome Number - Easy - Solution - Test Cases, t=O(N), s=O(1)
  10. Regular Expression Matching - Hard - Solution - Test Cases - DP, t=O(M*N), s=O(M*N)
  11. Container With Most Water - Medium - Solution - Test Cases - t=O(N), s=O(1)
  12. Integer To Roman - Medium - Solution - Test Cases - t=O(1), s=O(1)
  13. Roman To Integer - Easy - Solution - Test Cases - t=O(N), s=O(1)
  14. Longest Common Prefix - Easy - Solution - Test Cases - t=O(N*M), s=O(1)
  15. 3Sum - Medium - Solution - Test Cases - t=O(N^2), s=O(N)
  16. 3Sum Closest - Medium - Solution - Test Cases - t=O(N^2), s=O(N)
  17. Letter Combinations of A Phone Number - Medium - Solution - Test Cases - t=(3^N), s=O(3^N)
  18. 4Sum - Medium - Solution - Test Cases - t=O(N^3), s=O(N)
  19. Remove Nth Node From End of List - Easy - Solution - Test Cases - t=O(N), s=O(1)
  20. Valid Parentheses - Easy - Solution - Test Cases - t=O(N), s=O(N)
  21. Merge Two Sorted Lists - Easy - Solution - Test Cases - t=O(max(M,N)), s=O(1)
  22. Generate Parentheses - Medium - Solution - Test Cases - t=O(N^2), s=O(N^2)
  23. Merge K Sorted Lists - Hard - Solution - Test Cases - t=O(N*logK), s=O(logK), where where N is the total number of elements, K is the number of lists
  24. Swap Nodes in Pairs - Medium - Solution - Test Cases, t=O(N), s=O(1)
  25. Reverse Nodes in k-Group - Hard - Solution - Test Cases - t=O(N), s=O(1)
  26. Remove Duplicates from Sorted Array - Easy - Solution - Test Cases - t=O(N), s=O(1)
  27. Remove Element- Easy - Solution - Test Cases - t=O(N), s=O(1)
  28. Implement strStr() - Easy - Solution - Test Cases - KMP: t=O(M+N), s=O(N). Brute-force: t=O(M*N), s=O(1).
  29. Divide Two Integers - Medium - Solution - Test Cases - t=O((logN)^2), s=O(1)
  30. Substring with Concatenation of All Words - Hard - Solution - Test Cases - t=O(N*W), s=O(L*W), where N is the length of the string, W is the length of a word, L is the length of the words list.
  31. Next Permutation - Medium - Solution - Test Cases - t=O(N), s=O(1)
  32. Longest Valid Parentheses - Hard - Solution - Test Cases - One pass, t=O(N), s=O(N)
  33. Search in Rotated Sorted Array - Hard - Solution - Test Cases - t=O(logN), s=O(1)
  34. Search for a Range - Medium - Solution - Test Cases - t=O(logN), s=O(1)
  35. Search Insert Position - Medium - Solution - Test Cases - t=O(logN), s=O(1)
  36. Valid Sudoku - Medium - Solution - Test Cases - t=O(1), s=O(1)
  37. Sudoku Solver - Hard - Solution - Test Cases - DFS
  38. Count and Say - Easy - Solution - Test Cases - t=(2^N), s=O(2^N)
  39. Combination Sum - Medium - Solution - Test Cases - t=O(N*M), s=O(M), where N is the length of the candidates array, M is the value of the target integer.
  40. Combination Sum II - Medium - Solution - Test Cases - t=O(N*M), s=O(M), where N is the length of the candidates array, M is the value of the target integer.
  41. First Missing Positive - Hard - Solution - Test Cases - t=O(N), s=O(1)
  42. Trapping Rain Water - Hard - Solution - Test Cases - t=O(N), s=O(1)
  43. Multiply Strings - Medium - Solution - Test Cases - t=O(N*M), s=O(N+M)
  44. Wildcard Matching - Hard - Solution - Test Cases - t=O(N), s=O(1)
  45. Jump Game II - Hard - Solution - Test Cases - t=O(N), s=O(1)
  46. Permutations - Medium - Solution - Test Cases - t=O(N!), s=O(N!)
  47. Permutations II - Hard - Solution - Test Cases - t=O(N!), s=O(N!)
  48. Rotate Image - Medium - Solution - Test Cases - t=O(N*N), s=O(1)
  49. Anagrams - Medium - Solution - Test Cases - t=O(N), s=O(N)
  50. Pow(x, n) - Medium - Solution - Test Cases - t=O(logN), s=O(logN)
  51. N-Queens - Hard - Solution - Test Cases - t=O(N^2), s=O(N^2)
  52. N-Queens II - Hard - Solution - Test Cases - t= well it's complicated...
  53. Maximum Subarray - Medium - Solution - Test Cases - t=O(N), s=O(1)
  54. Spiral Matrix - Medium - Solution - Test Cases - t=O(N), s=O(N)
  55. Jump Game - Medium - Solution - Test Cases - t=O(N), s=O(1)
  56. Merge Intervals - Hard - Solution - Test Cases - t=O(N*logN), s=O(N)
  57. Insert Interval - Hard - Solution - Test Cases - t=O(N), s=O(N)
  58. Length of Last Word - Easy - Solution - Test Cases - t=O(N), s=O(1)
  59. Spiral Matrix II - Medium - Solution - Test Cases - t=O(N^2), s=O(N^2)
  60. Permutation Sequence - Medium - Solution - Test Cases - t=O(N^2), s=O(N)
  61. Rotate List - Medium - Solution - Test Cases - t=O(N), s=O(1)
  62. Unique Paths - Medium - Solution - Test Cases - t=O(min(M, N)), s=O(1)
  63. Unique Paths II - Medium - Solution - Test Cases - t=O(M*N), s=O(1)
  64. Minimum Path Sum - Medium - Solution - Test Cases - t=O(M*N), s=O(1)
  65. Valid Number - Hard - Solution - Test Cases - t=O(N), s=O(1)
  66. Plus One - Easy - Solution - Test Cases - t=O(N), s=O(1)
  67. Add Binary - Easy - Solution - Test Cases - t=O(max(M,N)), s=O(max(M,N))
  68. Text Justification - Hard - Solution - Test Cases - t<=O(N*L), s<=O(N*L), where N is the length of the input words array, L is the required justified length
  69. Sqrt(x) - Medium - Solution - Test Cases - t=O(logN), s=O(1)
  70. Climbing Stairs - Easy - Solution - Test Cases - t=O(N), s=O(1)
  71. Simplify Path - Medium - Solution - Test Cases - t=O(N), s=O(N)
  72. Edit Distance - Hard - Solution - Test Cases - t=O(M*N), s=O(min(M,N))
  73. Set Matrix Zeroes - Medium - Solution - Test Cases - t=O(M*N), s=O(1)
  74. Search a 2D Matrix - Medium - Solution - Test Cases - t=O(logN), s=O(1)
  75. Sort Colors - Medium - Solution - Test Cases - t=O(N), s=O(1), one pass
  76. Minimum Window Substring - Hard - Solution - Test Cases - t=O(N), s=O(N)
  77. Combinations - Medium - Solution - Test Cases - t=O(Combination(n, k)+2^(k-1)), s is complicated.
  78. Subsets - Medium - Solution - Test Cases - t=O(N*2^N), s=O(n*2^N)
  79. Word Search - Medium - Solution - Test Cases - t=O(M*N*L), s=O(L), where L is the length of the word.
  80. Remove Duplicates from Sorted Array II - Medium - Solution - Test Cases - t=O(N), s=O(1)

Optional chaining, closure, subscript, enumeration, generic, extension, access control, automatic reference counting, string, character, nested type, type casting, protocol, xctestcase, xctest, online judge, oj, xcode, cocoa, cocoa touch, foundation, ios, 面试, 算法, 递归, 迭代, 找工作, 手机, 苹果, wwdc.

About

Get prepared for your next iOS job interview by studying high quality LeetCode solutions in Swift 2.0.

License:MIT License


Languages

Language:Swift 100.0%