Giter Site home page Giter Site logo

leedcode-swift's Introduction

LeedCode-Swift

LeedCode 刷题

第一部分 数组

1. func twoSun(_ nums: [Int], _ target: Int) ->[Int]

2. func ambiguousCoordinates(_ S: String) -> [String]

3. func arrangeCoins(_ n: Int) -> Int

4. func removeDuplicates(_ nums: inout [Int]) -> Int

5. func removeElement(_ nums: inout [Int], _ val: Int) -> Int

6. func searchInsert(_ nums: [Int], _ target: Int) -> Int

7. func maxSubArray(_ nums: [Int]) -> Int

8. func plusOne(_ digits: [Int]) -> [Int]

9. func merge(_ nums1: inout [Int], _ m: Int, _ nums2: [Int], _ n: Int)

10. func generate(_ numRows: Int) -> [[Int]]

11. func getRow(_ rowIndex: Int) -> [Int]

12. func maxProfit(_ prices: [Int]) -> Int

13. func maxProfit2(_ prices: [Int]) -> Int //未完成

14. func thirdMax(_ nums: [Int]) -> Int 

15. func findDisappearedNumbers(_ nums: [Int]) -> [Int]

16. func maximumProduct(_ nums: [Int]) -> Int

17. func findMaxConsecutiveOnes(_ nums: [Int]) -> Int

18. func findMaxAverage(_ nums: [Int], _ k: Int) -> Double 

19. func reverse(_ x: Int) -> Int

20. func arrayPairSum(_ nums: [Int]) -> Int

21. func groupAnagrams(_ strs: [String]) -> [[String]]

22. func singleNumber(_ nums: [Int]) -> Int

23. func twoSum(_ numbers: [Int], _ target: Int) -> [Int]

24.func majorityElement(_ nums: [Int]) -> Int

25. func containsDuplicate(_ nums: [Int]) -> Bool

26.func containsNearbyDuplicate(_ nums: [Int], _ k: Int) -> Bool

27.func missingNumber(_ nums: [Int]) -> Int

28.func moveZeroes(_ nums: inout [Int])

29.  func arrayPairSum(_ nums: [Int]) -> Int

第二部分 字符串操作

1. func isPalindrome(_ x: Int) -> Bool

2. func romanToInt(_ s: String) -> Int

3.isValid(_ s: String) -> Bool

3.func strStr(_ haystack: String, _ needle: String) -> Int

4.func lengthOfLongestSubstring(_ s: String) -> Int//未完成

5. func longestPalindrome(_ s: String) -> String

6. func maxArea(_ height: [Int]) -> Int

7. func intToRoman(_ num: Int) -> String

8. func countAndSay(_ n: Int) -> String

9. func multiply(_ num1: String, _ num2: String) -> String

10. func isPalindrome(_ s: String) -> Bool

11.public int titleToNumber(String s)

12.func addDigits(_ num: Int) -> Int

第三部分 链表操作

//在自己编译器运行没有问题 ,但是在线编译器编译不通过
1. func removeNthFromEnd(_ head: ListNode?, _ n: Int) -> ListNode? 

2. func mergeTwoLists(_ l1: ListNode?, _ l2: ListNode?) -> ListNode?

3. func swapPairs(_ head: ListNode?) -> ListNode? 

4. func hasCycle(_ head: ListNode?) ->Bool

5. func isSameTree(_ p: TreeNode?, _ q: TreeNode?) -> Bool

6. func isSymmetric(_ root: TreeNode?) -> Bool

7. func maxDepth(_ root: TreeNode?) -> Int

8 func levelOrderBottom(_ root: TreeNode?) -> [[Int]]

// 不支持Swift
9. public ListNode getIntersectionNode(ListNode headA, ListNode headB)

10.func removeElements(_ head: ListNode?, _ val: Int) -> ListNode?

第三部分 DFS

1. func generateParenthesis(_ n: Int) -> [String]

2. func combinationSum(_ candidates: [Int], _ target: Int) -> [[Int]]

3. func combinationSum2(_ candidates: [Int], _ target: Int) -> [[Int]]

4. func permute(_ nums: [Int]) -> [[Int]]

5.  func climbStairs(_ n: Int) -> Int  // DFS超时

5. func climbStairs1(_ n: Int) -> Int //递归超时

5. func climbStairs2(_ n: Int) -> Int 

第四部分 二分法

1. func mySqrt(_ x: Int) -> Int



第四部分 数据库

1.Select Email From Person Group By Email Having Count(*) > 1



leedcode-swift's People

Contributors

yangminios avatar

Watchers

James Cloos avatar  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.