Skip to content

Discussing Sub-optimal Solutions To Puzzles #959

Open
@rpstro02

Description

@rpstro02

Would a pull request be accepted that discusses sub-optimal solutions to the puzzles? For example, the following solution for the Two-Sum Problem is the most concise (and perhaps one of the most obvious) but has O(n^2) complexity:

for x in 0..<array.count {
    
    let currentNumber = array[x]
    let numberNeeded = target - currentNumber
    if let targetIndex = array.firstIndex(of: numberNeeded) {
        return (x, targetIndex)
    }
    
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions