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
///copy the implementation of NSObject.init and exchange it with some new fake init we are going to create. | |
///https://nshint.io/blog/2019/04/08/testing-the-camera-on-the-simulator/ | |
///https://pspdfkit.com/blog/2019/swizzling-in-swift/ | |
private struct Swizzler { | |
private let klass: AnyClass | |
init(_ klass: AnyClass) { | |
self.klass = klass | |
} |
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 UIKit | |
import PlaygroundSupport | |
func findAllSubArrayWhoseCountMatches(targetValue: Int, in array: [Int]) -> [[Int]] { | |
var sum = 0 | |
var hashMap = [Int: Int]() | |
var results = [[Int]]() | |
for index in 0..<array.count { | |
sum = sum + array[index] | |
if sum == target { |
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 UIKit | |
import PlaygroundSupport | |
func findSubArrayWhoseCountMatches(targetValue: Int, in array: [Int]) -> [Int] { | |
var sum = 0 | |
var hashMap = [Int: Int]() | |
for index in 0..<array.count { | |
sum = sum + array[index] | |
if sum == target { |
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 UIKit | |
import PlaygroundSupport | |
func findSubArrayWhoseCountMatches(targetValue: Int, in array: [Int]) -> [Int] { | |
var sum = 0 | |
var startIndex = 0 | |
for index in 0..<array.count { | |
sum = sum + array[index] | |
while sum > target { |
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 UIKit | |
import PlaygroundSupport | |
class TreeNode { | |
var data: Int | |
var left: TreeNode? | |
var right: TreeNode? | |
init(data: Int) { | |
self.data = data |
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 UIKit | |
import PlaygroundSupport | |
class TreeNode { | |
var data: Int | |
var left: TreeNode? | |
var right: TreeNode? | |
init(data: Int) { | |
self.data = data |
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 UIKit | |
import PlaygroundSupport | |
class TreeNode { | |
var data: Int | |
var left: TreeNode? | |
var right: TreeNode? | |
init(data: Int) { | |
self.data = data |
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 UIKit | |
import PlaygroundSupport | |
class Node { | |
var data: Int | |
var next: Node? | |
init(data: Int) { | |
self.data = data | |
} |
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 UIKit | |
import PlaygroundSupport | |
class Node { | |
var data: Int | |
var next: Node? | |
init(data: Int) { | |
self.data = data | |
} |
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 UIKit | |
import PlaygroundSupport | |
class Cell: UITableViewCell { | |
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | |
super.init(style: style, reuseIdentifier: reuseIdentifier) | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") |