Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/wei #2

Merged
merged 3 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions TSWeiFramework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
57 changes: 57 additions & 0 deletions TSWeiFramework/Solution.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// Solution.swift
// TSWeiFramework
//
// Created by Wei Cao on 2019/2/19.
// Copyright © 2019 Ray Tso. All rights reserved.
//

import Foundation

public class Solution {
public init(){}
}

//MARK:- Easy
public extension Solution{

/**
414, Third Maximum Number
*/
func thirdMax(_ nums: [Int]) -> Int {
let r = nums.reduce(into: (Int.min, Int.min, Int.min)) { (r, v) in
switch v {
case _ where v == r.0 || v == r.1 || v == r.2:
break
case _ where v > r.0:
r = (v, r.0, r.1)
case _ where v > r.1:
(r.1, r.2) = (v, r.1)
case _ where v > r.2:
r.2 = v
default:
break
}
}
return (r.2 == Int.min) ? r.0 : r.2
}

/**
844, Backspace String Compare
*/
func backspaceCompare(_ S: String, _ T: String) -> Bool {
return removeBackspace(S) == removeBackspace(T)
}
private func removeBackspace(_ s: String) -> String{
return s.reduce(into: "") { (r, c) in
switch c {
case _ where c != "#":
r.append(c)
case "#" where r.count > 0:
_ = r.removeLast()
default:
break
}
}
}
}
19 changes: 19 additions & 0 deletions TSWeiFramework/TSWeiFramework.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// TSWeiFramework.h
// TSWeiFramework
//
// Created by Wei Cao on 2019/2/19.
// Copyright © 2019 Ray Tso. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for TSWeiFramework.
FOUNDATION_EXPORT double TSWeiFrameworkVersionNumber;

//! Project version string for TSWeiFramework.
FOUNDATION_EXPORT const unsigned char TSWeiFrameworkVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <TSWeiFramework/PublicHeader.h>


22 changes: 22 additions & 0 deletions TSWeiFrameworkTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
34 changes: 34 additions & 0 deletions TSWeiFrameworkTests/TSWeiFrameworkTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// TSWeiFrameworkTests.swift
// TSWeiFrameworkTests
//
// Created by Wei Cao on 2019/2/19.
// Copyright © 2019 Ray Tso. All rights reserved.
//

import XCTest
@testable import TSWeiFramework

class TSWeiFrameworkTests: XCTestCase {

override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}

}
Loading