is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
import UIKit
- mvdizel February 29, 2020final class PTTSolution {
static let words: Set = ["a", "aa", "is", "name"]
// static let words: Set = ["a"]
class func Verify(_ input:String?) -> String? {
guard let input = input, input.count > 0 else {
return nil;
}
var lengths: Set<Int> = []
words.forEach { word in
lengths.insert(word.count)
}
var result: Array<(i: Int, w: String)> = Array(repeating: (0, ""), count: input.count + 1)
result[0] = (i: 1, w: "")
for i in 1...input.count {
lengths.forEach { length in
let startIndex = i - length
if startIndex < 0 {
return
}
let steps = result[startIndex]
if steps.i == 0 {
return
}
let start = input.index(input.startIndex, offsetBy: startIndex)
let end = input.index(input.startIndex, offsetBy: i)
let substring = String(input[start..<end])
if !words.contains(substring) {
return
}
let fullWord = steps.w.count == 0 ? substring : steps.w + " " + substring;
if (result[i].i == 0) || (result[i].i > steps.i + 1) {
result[i] = (i: steps.i + 1, w: fullWord)
}
}
}
return result.last!.w;
}
}
let input = "aaaisaname";
print(PTTSolution.Verify(input) ?? "no result");
// O(w + n*l) - where w - is number of words, n - is a number of characters in the input, l - is different lengths of word in the dictionary