GithubHelp home page GithubHelp logo

marinehero / leetcode-solutions-in-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from diwu/leetcode-solutions-in-swift

0.0 2.0 0.0 850 KB

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

License: MIT License

Swift 100.00%

leetcode-solutions-in-swift's Introduction

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 79 / ( 256 Totol - 23 Paid Subscription ) = 33.9%.

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.

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.

leetcode-solutions-in-swift's People

Contributors

diwu avatar testpersonal avatar

Watchers

James Pereira avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.