This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol NetworkLoader { | |
func loadData(using request: URLRequest, with completion: @escaping (Data?, HTTPURLResponse?, Error?) -> Void) | |
} | |
extension URLSession: NetworkLoader { | |
/// Asyncronously load data using a URL Request | |
/// - Parameters: | |
/// - request: an unwrapped URLRequest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Album: Decodable { | |
let artist: String | |
let coverArt: [URL] | |
let genres: [String] | |
let id: UUID | |
let name: String | |
let songs: [Song] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*: | |
Given an array A of strings made only from lowercase letters, | |
return a list of all characters that show up in all strings within the list (including duplicates). | |
For example, if a character occurs 3 times in all strings but not 4 times, | |
you need to include that character three times in the final answer. | |
You may return the answer in any order. | |
``` | |
Example 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*: | |
## Given an array, rotate the array to the right by k steps, where k is non-negative. | |
``` | |
Example 1: | |
Input: [1,2,3,4,5,6,7] and k = 3 | |
Output: [5,6,7,1,2,3,4] | |
Explanation: | |
rotate 1 steps to the right: [7,1,2,3,4,5,6] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func findDisappearedNumbers(_ nums: inout [Int]) -> [Int] { | |
var outputArr = [Int]() | |
let numsCount = nums.count | |
guard let minNum = nums.min(), | |
let maxNum = nums.max() | |
else { return [] } | |
let range = minNum...maxNum | |
if numsCount == range.count { | |
return [] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If aConditionThatsEvaluatedForBoth > something { | |
if anotherConditionThatsTrue { | |
//do something | |
else { | |
//do something else | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ProtocolChallengeUnitTestsTests.swift | |
// ProtocolChallengeUnitTestsTests | |
// | |
// Created by Kenny on 3/18/20. | |
// Copyright © 2020 Hazy Studios. All rights reserved. | |
// | |
import XCTest | |
@testable import ProtocolChallengeUnitTests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Given two arrays, write a function to compute their intersection. | |
//Example 1: | |
// | |
//Input: nums1 = [1,2,2,1], nums2 = [2,2] | |
//Output: [2] | |
//Example 2: | |
// | |
//Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] | |
//Output: [9,4] | |
//Note: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CIFilter { | |
enum FilterName: String { | |
case CIAccordionFoldTransition = "CIAccordionFoldTransition" | |
case CIAdditionCompositing = "CIAdditionCompositing" | |
case CIAffineClamp = "CIAffineClamp" | |
case CIAffineTile = "CIAffineTile" | |
case CIAffineTransform = "CIAffineTransform" | |
case CIAreaAverage = "CIAreaAverage" | |
case CIAreaHistogram = "CIAreaHistogram" | |
case CIAreaMaximum = "CIAreaMaximum" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A solution set is: | |
[ | |
[-1, 0, 0, 1], | |
[-2, -1, 1, 2], | |
[-2, 0, 0, 2] | |
] | |
*/ | |
/// Given an array nums of n integers and an integer target, are there elements a, b, c, and d |
OlderNewer