├── AlgorithmQuestions.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcshareddata
│ ├── xcbaselines
│ └── A29DB269214F747E00C05950.xcbaseline
│ │ ├── 859C08CA-88FD-46A9-8445-94CEE5922D37.plist
│ │ └── Info.plist
│ └── xcschemes
│ ├── AlgorithmQuestions.xcscheme
│ └── AlgorithmQuestionsTests.xcscheme
├── AlgorithmQuestions
├── Array
│ └── TwoSum
│ │ ├── TwoSum.swift
│ │ └── TwoSumTests.swift
├── String
│ └── LongestSubstringWithoutRepeatingCharacters
│ │ ├── LongestSubstringWithoutRepeatingCharacters.swift
│ │ └── LongestSubstringWithoutRepeatingCharactersTests.swift
└── main.swift
├── AlgorithmQuestionsTests
├── AlgorithmQuestionsTests.swift
└── Info.plist
├── Posts
├──
编程题手册 Vol.1<-center> .md
├── 编程题手册 Vol.2<-center>.md
├── Vol1.jpg
└── Vol2.jpg
└── README.md
/AlgorithmQuestions.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | A29DB26D214F747E00C05950 /* AlgorithmQuestionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29DB26C214F747E00C05950 /* AlgorithmQuestionsTests.swift */; };
11 | A29DB274214F750F00C05950 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29DB273214F750F00C05950 /* main.swift */; };
12 | A29DB277214F75B300C05950 /* TwoSum.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29DB276214F75B300C05950 /* TwoSum.swift */; };
13 | A29DB27A214F7C2600C05950 /* TwoSumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29DB279214F7C2600C05950 /* TwoSumTests.swift */; };
14 | A29DB27F214F873C00C05950 /* TwoSum.swift in Sources */ = {isa = PBXBuildFile; fileRef = A29DB276214F75B300C05950 /* TwoSum.swift */; };
15 | A2C6C67C215883FF0061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2C6C67B215883FF0061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift */; };
16 | A2C6C67D215884010061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2C6C67B215883FF0061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift */; };
17 | A2C6C67F215884370061C2FD /* LongestSubstringWithoutRepeatingCharactersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2C6C67E215884370061C2FD /* LongestSubstringWithoutRepeatingCharactersTests.swift */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXContainerItemProxy section */
21 | A29DB27D214F869C00C05950 /* PBXContainerItemProxy */ = {
22 | isa = PBXContainerItemProxy;
23 | containerPortal = A29DB254214F743B00C05950 /* Project object */;
24 | proxyType = 1;
25 | remoteGlobalIDString = A29DB25B214F743B00C05950;
26 | remoteInfo = AlgorithmQuestions;
27 | };
28 | /* End PBXContainerItemProxy section */
29 |
30 | /* Begin PBXCopyFilesBuildPhase section */
31 | A29DB25A214F743B00C05950 /* CopyFiles */ = {
32 | isa = PBXCopyFilesBuildPhase;
33 | buildActionMask = 2147483647;
34 | dstPath = /usr/share/man/man1/;
35 | dstSubfolderSpec = 0;
36 | files = (
37 | );
38 | runOnlyForDeploymentPostprocessing = 1;
39 | };
40 | /* End PBXCopyFilesBuildPhase section */
41 |
42 | /* Begin PBXFileReference section */
43 | A29DB25C214F743B00C05950 /* AlgorithmQuestions */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = AlgorithmQuestions; sourceTree = BUILT_PRODUCTS_DIR; };
44 | A29DB26A214F747E00C05950 /* AlgorithmQuestionsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AlgorithmQuestionsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
45 | A29DB26C214F747E00C05950 /* AlgorithmQuestionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlgorithmQuestionsTests.swift; sourceTree = ""; };
46 | A29DB26E214F747E00C05950 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
47 | A29DB273214F750F00C05950 /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; };
48 | A29DB276214F75B300C05950 /* TwoSum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoSum.swift; sourceTree = ""; };
49 | A29DB279214F7C2600C05950 /* TwoSumTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoSumTests.swift; sourceTree = ""; };
50 | A2C6C67B215883FF0061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongestSubstringWithoutRepeatingCharacters.swift; sourceTree = ""; };
51 | A2C6C67E215884370061C2FD /* LongestSubstringWithoutRepeatingCharactersTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongestSubstringWithoutRepeatingCharactersTests.swift; sourceTree = ""; };
52 | /* End PBXFileReference section */
53 |
54 | /* Begin PBXFrameworksBuildPhase section */
55 | A29DB259214F743B00C05950 /* Frameworks */ = {
56 | isa = PBXFrameworksBuildPhase;
57 | buildActionMask = 2147483647;
58 | files = (
59 | );
60 | runOnlyForDeploymentPostprocessing = 0;
61 | };
62 | A29DB267214F747E00C05950 /* Frameworks */ = {
63 | isa = PBXFrameworksBuildPhase;
64 | buildActionMask = 2147483647;
65 | files = (
66 | );
67 | runOnlyForDeploymentPostprocessing = 0;
68 | };
69 | /* End PBXFrameworksBuildPhase section */
70 |
71 | /* Begin PBXGroup section */
72 | A29DB253214F743B00C05950 = {
73 | isa = PBXGroup;
74 | children = (
75 | A29DB25E214F743B00C05950 /* AlgorithmQuestions */,
76 | A29DB26B214F747E00C05950 /* AlgorithmQuestionsTests */,
77 | A29DB25D214F743B00C05950 /* Products */,
78 | );
79 | sourceTree = "";
80 | };
81 | A29DB25D214F743B00C05950 /* Products */ = {
82 | isa = PBXGroup;
83 | children = (
84 | A29DB25C214F743B00C05950 /* AlgorithmQuestions */,
85 | A29DB26A214F747E00C05950 /* AlgorithmQuestionsTests.xctest */,
86 | );
87 | name = Products;
88 | sourceTree = "";
89 | };
90 | A29DB25E214F743B00C05950 /* AlgorithmQuestions */ = {
91 | isa = PBXGroup;
92 | children = (
93 | A2C6C679215883CC0061C2FD /* String */,
94 | A29DB275214F75A700C05950 /* Array */,
95 | A29DB273214F750F00C05950 /* main.swift */,
96 | );
97 | path = AlgorithmQuestions;
98 | sourceTree = "";
99 | };
100 | A29DB26B214F747E00C05950 /* AlgorithmQuestionsTests */ = {
101 | isa = PBXGroup;
102 | children = (
103 | A29DB26C214F747E00C05950 /* AlgorithmQuestionsTests.swift */,
104 | A29DB26E214F747E00C05950 /* Info.plist */,
105 | );
106 | path = AlgorithmQuestionsTests;
107 | sourceTree = "";
108 | };
109 | A29DB275214F75A700C05950 /* Array */ = {
110 | isa = PBXGroup;
111 | children = (
112 | A29DB2842150BA5200C05950 /* TwoSum */,
113 | );
114 | path = Array;
115 | sourceTree = "";
116 | };
117 | A29DB2842150BA5200C05950 /* TwoSum */ = {
118 | isa = PBXGroup;
119 | children = (
120 | A29DB276214F75B300C05950 /* TwoSum.swift */,
121 | A29DB279214F7C2600C05950 /* TwoSumTests.swift */,
122 | );
123 | path = TwoSum;
124 | sourceTree = "";
125 | };
126 | A2C6C679215883CC0061C2FD /* String */ = {
127 | isa = PBXGroup;
128 | children = (
129 | A2C6C67A215883D90061C2FD /* LongestSubstringWithoutRepeatingCharacters */,
130 | );
131 | path = String;
132 | sourceTree = "";
133 | };
134 | A2C6C67A215883D90061C2FD /* LongestSubstringWithoutRepeatingCharacters */ = {
135 | isa = PBXGroup;
136 | children = (
137 | A2C6C67B215883FF0061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift */,
138 | A2C6C67E215884370061C2FD /* LongestSubstringWithoutRepeatingCharactersTests.swift */,
139 | );
140 | path = LongestSubstringWithoutRepeatingCharacters;
141 | sourceTree = "";
142 | };
143 | /* End PBXGroup section */
144 |
145 | /* Begin PBXNativeTarget section */
146 | A29DB25B214F743B00C05950 /* AlgorithmQuestions */ = {
147 | isa = PBXNativeTarget;
148 | buildConfigurationList = A29DB263214F743B00C05950 /* Build configuration list for PBXNativeTarget "AlgorithmQuestions" */;
149 | buildPhases = (
150 | A29DB258214F743B00C05950 /* Sources */,
151 | A29DB259214F743B00C05950 /* Frameworks */,
152 | A29DB25A214F743B00C05950 /* CopyFiles */,
153 | );
154 | buildRules = (
155 | );
156 | dependencies = (
157 | );
158 | name = AlgorithmQuestions;
159 | productName = AlgorithmQuestions;
160 | productReference = A29DB25C214F743B00C05950 /* AlgorithmQuestions */;
161 | productType = "com.apple.product-type.tool";
162 | };
163 | A29DB269214F747E00C05950 /* AlgorithmQuestionsTests */ = {
164 | isa = PBXNativeTarget;
165 | buildConfigurationList = A29DB26F214F747E00C05950 /* Build configuration list for PBXNativeTarget "AlgorithmQuestionsTests" */;
166 | buildPhases = (
167 | A29DB266214F747E00C05950 /* Sources */,
168 | A29DB267214F747E00C05950 /* Frameworks */,
169 | A29DB268214F747E00C05950 /* Resources */,
170 | );
171 | buildRules = (
172 | );
173 | dependencies = (
174 | A29DB27E214F869C00C05950 /* PBXTargetDependency */,
175 | );
176 | name = AlgorithmQuestionsTests;
177 | productName = AlgorithmQuestionsTests;
178 | productReference = A29DB26A214F747E00C05950 /* AlgorithmQuestionsTests.xctest */;
179 | productType = "com.apple.product-type.bundle.unit-test";
180 | };
181 | /* End PBXNativeTarget section */
182 |
183 | /* Begin PBXProject section */
184 | A29DB254214F743B00C05950 /* Project object */ = {
185 | isa = PBXProject;
186 | attributes = {
187 | LastSwiftUpdateCheck = 1000;
188 | LastUpgradeCheck = 1000;
189 | ORGANIZATIONNAME = olddonkey;
190 | TargetAttributes = {
191 | A29DB25B214F743B00C05950 = {
192 | CreatedOnToolsVersion = 10.0;
193 | LastSwiftMigration = 1000;
194 | };
195 | A29DB269214F747E00C05950 = {
196 | CreatedOnToolsVersion = 10.0;
197 | };
198 | };
199 | };
200 | buildConfigurationList = A29DB257214F743B00C05950 /* Build configuration list for PBXProject "AlgorithmQuestions" */;
201 | compatibilityVersion = "Xcode 9.3";
202 | developmentRegion = en;
203 | hasScannedForEncodings = 0;
204 | knownRegions = (
205 | en,
206 | );
207 | mainGroup = A29DB253214F743B00C05950;
208 | productRefGroup = A29DB25D214F743B00C05950 /* Products */;
209 | projectDirPath = "";
210 | projectRoot = "";
211 | targets = (
212 | A29DB25B214F743B00C05950 /* AlgorithmQuestions */,
213 | A29DB269214F747E00C05950 /* AlgorithmQuestionsTests */,
214 | );
215 | };
216 | /* End PBXProject section */
217 |
218 | /* Begin PBXResourcesBuildPhase section */
219 | A29DB268214F747E00C05950 /* Resources */ = {
220 | isa = PBXResourcesBuildPhase;
221 | buildActionMask = 2147483647;
222 | files = (
223 | );
224 | runOnlyForDeploymentPostprocessing = 0;
225 | };
226 | /* End PBXResourcesBuildPhase section */
227 |
228 | /* Begin PBXSourcesBuildPhase section */
229 | A29DB258214F743B00C05950 /* Sources */ = {
230 | isa = PBXSourcesBuildPhase;
231 | buildActionMask = 2147483647;
232 | files = (
233 | A29DB277214F75B300C05950 /* TwoSum.swift in Sources */,
234 | A2C6C67C215883FF0061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift in Sources */,
235 | A29DB274214F750F00C05950 /* main.swift in Sources */,
236 | );
237 | runOnlyForDeploymentPostprocessing = 0;
238 | };
239 | A29DB266214F747E00C05950 /* Sources */ = {
240 | isa = PBXSourcesBuildPhase;
241 | buildActionMask = 2147483647;
242 | files = (
243 | A29DB27A214F7C2600C05950 /* TwoSumTests.swift in Sources */,
244 | A2C6C67F215884370061C2FD /* LongestSubstringWithoutRepeatingCharactersTests.swift in Sources */,
245 | A29DB26D214F747E00C05950 /* AlgorithmQuestionsTests.swift in Sources */,
246 | A29DB27F214F873C00C05950 /* TwoSum.swift in Sources */,
247 | A2C6C67D215884010061C2FD /* LongestSubstringWithoutRepeatingCharacters.swift in Sources */,
248 | );
249 | runOnlyForDeploymentPostprocessing = 0;
250 | };
251 | /* End PBXSourcesBuildPhase section */
252 |
253 | /* Begin PBXTargetDependency section */
254 | A29DB27E214F869C00C05950 /* PBXTargetDependency */ = {
255 | isa = PBXTargetDependency;
256 | target = A29DB25B214F743B00C05950 /* AlgorithmQuestions */;
257 | targetProxy = A29DB27D214F869C00C05950 /* PBXContainerItemProxy */;
258 | };
259 | /* End PBXTargetDependency section */
260 |
261 | /* Begin XCBuildConfiguration section */
262 | A29DB261214F743B00C05950 /* Debug */ = {
263 | isa = XCBuildConfiguration;
264 | buildSettings = {
265 | ALWAYS_SEARCH_USER_PATHS = NO;
266 | CLANG_ANALYZER_NONNULL = YES;
267 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
268 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
269 | CLANG_CXX_LIBRARY = "libc++";
270 | CLANG_ENABLE_MODULES = YES;
271 | CLANG_ENABLE_OBJC_ARC = YES;
272 | CLANG_ENABLE_OBJC_WEAK = YES;
273 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
274 | CLANG_WARN_BOOL_CONVERSION = YES;
275 | CLANG_WARN_COMMA = YES;
276 | CLANG_WARN_CONSTANT_CONVERSION = YES;
277 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
279 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
280 | CLANG_WARN_EMPTY_BODY = YES;
281 | CLANG_WARN_ENUM_CONVERSION = YES;
282 | CLANG_WARN_INFINITE_RECURSION = YES;
283 | CLANG_WARN_INT_CONVERSION = YES;
284 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
285 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
286 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
289 | CLANG_WARN_STRICT_PROTOTYPES = YES;
290 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
291 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
292 | CLANG_WARN_UNREACHABLE_CODE = YES;
293 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
294 | CODE_SIGN_IDENTITY = "Mac Developer";
295 | COPY_PHASE_STRIP = NO;
296 | DEBUG_INFORMATION_FORMAT = dwarf;
297 | ENABLE_STRICT_OBJC_MSGSEND = YES;
298 | ENABLE_TESTABILITY = YES;
299 | GCC_C_LANGUAGE_STANDARD = gnu11;
300 | GCC_DYNAMIC_NO_PIC = NO;
301 | GCC_NO_COMMON_BLOCKS = YES;
302 | GCC_OPTIMIZATION_LEVEL = 0;
303 | GCC_PREPROCESSOR_DEFINITIONS = (
304 | "DEBUG=1",
305 | "$(inherited)",
306 | );
307 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
308 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
309 | GCC_WARN_UNDECLARED_SELECTOR = YES;
310 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
311 | GCC_WARN_UNUSED_FUNCTION = YES;
312 | GCC_WARN_UNUSED_VARIABLE = YES;
313 | MACOSX_DEPLOYMENT_TARGET = 10.13;
314 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
315 | MTL_FAST_MATH = YES;
316 | ONLY_ACTIVE_ARCH = YES;
317 | SDKROOT = macosx;
318 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
319 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
320 | };
321 | name = Debug;
322 | };
323 | A29DB262214F743B00C05950 /* Release */ = {
324 | isa = XCBuildConfiguration;
325 | buildSettings = {
326 | ALWAYS_SEARCH_USER_PATHS = NO;
327 | CLANG_ANALYZER_NONNULL = YES;
328 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
330 | CLANG_CXX_LIBRARY = "libc++";
331 | CLANG_ENABLE_MODULES = YES;
332 | CLANG_ENABLE_OBJC_ARC = YES;
333 | CLANG_ENABLE_OBJC_WEAK = YES;
334 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
335 | CLANG_WARN_BOOL_CONVERSION = YES;
336 | CLANG_WARN_COMMA = YES;
337 | CLANG_WARN_CONSTANT_CONVERSION = YES;
338 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
340 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
341 | CLANG_WARN_EMPTY_BODY = YES;
342 | CLANG_WARN_ENUM_CONVERSION = YES;
343 | CLANG_WARN_INFINITE_RECURSION = YES;
344 | CLANG_WARN_INT_CONVERSION = YES;
345 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
346 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
347 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
348 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
349 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
350 | CLANG_WARN_STRICT_PROTOTYPES = YES;
351 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
352 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
353 | CLANG_WARN_UNREACHABLE_CODE = YES;
354 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
355 | CODE_SIGN_IDENTITY = "Mac Developer";
356 | COPY_PHASE_STRIP = NO;
357 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
358 | ENABLE_NS_ASSERTIONS = NO;
359 | ENABLE_STRICT_OBJC_MSGSEND = YES;
360 | GCC_C_LANGUAGE_STANDARD = gnu11;
361 | GCC_NO_COMMON_BLOCKS = YES;
362 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
363 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
364 | GCC_WARN_UNDECLARED_SELECTOR = YES;
365 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
366 | GCC_WARN_UNUSED_FUNCTION = YES;
367 | GCC_WARN_UNUSED_VARIABLE = YES;
368 | MACOSX_DEPLOYMENT_TARGET = 10.13;
369 | MTL_ENABLE_DEBUG_INFO = NO;
370 | MTL_FAST_MATH = YES;
371 | SDKROOT = macosx;
372 | SWIFT_COMPILATION_MODE = wholemodule;
373 | SWIFT_OPTIMIZATION_LEVEL = "-O";
374 | };
375 | name = Release;
376 | };
377 | A29DB264214F743B00C05950 /* Debug */ = {
378 | isa = XCBuildConfiguration;
379 | buildSettings = {
380 | CLANG_ENABLE_MODULES = YES;
381 | CODE_SIGN_STYLE = Automatic;
382 | DEVELOPMENT_TEAM = KACMQNFS8H;
383 | LD_RUNPATH_SEARCH_PATHS = (
384 | "$(inherited)",
385 | "@executable_path/../Frameworks",
386 | "@loader_path/../Frameworks",
387 | );
388 | PRODUCT_NAME = "$(TARGET_NAME)";
389 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
390 | SWIFT_VERSION = 4.2;
391 | };
392 | name = Debug;
393 | };
394 | A29DB265214F743B00C05950 /* Release */ = {
395 | isa = XCBuildConfiguration;
396 | buildSettings = {
397 | CLANG_ENABLE_MODULES = YES;
398 | CODE_SIGN_STYLE = Automatic;
399 | DEVELOPMENT_TEAM = KACMQNFS8H;
400 | LD_RUNPATH_SEARCH_PATHS = (
401 | "$(inherited)",
402 | "@executable_path/../Frameworks",
403 | "@loader_path/../Frameworks",
404 | );
405 | PRODUCT_NAME = "$(TARGET_NAME)";
406 | SWIFT_VERSION = 4.2;
407 | };
408 | name = Release;
409 | };
410 | A29DB270214F747E00C05950 /* Debug */ = {
411 | isa = XCBuildConfiguration;
412 | buildSettings = {
413 | CODE_SIGN_STYLE = Automatic;
414 | COMBINE_HIDPI_IMAGES = YES;
415 | DEVELOPMENT_TEAM = KACMQNFS8H;
416 | INFOPLIST_FILE = AlgorithmQuestionsTests/Info.plist;
417 | LD_RUNPATH_SEARCH_PATHS = (
418 | "$(inherited)",
419 | "@executable_path/../Frameworks",
420 | "@loader_path/../Frameworks",
421 | );
422 | PRODUCT_BUNDLE_IDENTIFIER = com.olddonkey.AlgorithmQuestionsTests;
423 | PRODUCT_NAME = "$(TARGET_NAME)";
424 | SWIFT_VERSION = 4.2;
425 | };
426 | name = Debug;
427 | };
428 | A29DB271214F747E00C05950 /* Release */ = {
429 | isa = XCBuildConfiguration;
430 | buildSettings = {
431 | CODE_SIGN_STYLE = Automatic;
432 | COMBINE_HIDPI_IMAGES = YES;
433 | DEVELOPMENT_TEAM = KACMQNFS8H;
434 | INFOPLIST_FILE = AlgorithmQuestionsTests/Info.plist;
435 | LD_RUNPATH_SEARCH_PATHS = (
436 | "$(inherited)",
437 | "@executable_path/../Frameworks",
438 | "@loader_path/../Frameworks",
439 | );
440 | PRODUCT_BUNDLE_IDENTIFIER = com.olddonkey.AlgorithmQuestionsTests;
441 | PRODUCT_NAME = "$(TARGET_NAME)";
442 | SWIFT_VERSION = 4.2;
443 | };
444 | name = Release;
445 | };
446 | /* End XCBuildConfiguration section */
447 |
448 | /* Begin XCConfigurationList section */
449 | A29DB257214F743B00C05950 /* Build configuration list for PBXProject "AlgorithmQuestions" */ = {
450 | isa = XCConfigurationList;
451 | buildConfigurations = (
452 | A29DB261214F743B00C05950 /* Debug */,
453 | A29DB262214F743B00C05950 /* Release */,
454 | );
455 | defaultConfigurationIsVisible = 0;
456 | defaultConfigurationName = Release;
457 | };
458 | A29DB263214F743B00C05950 /* Build configuration list for PBXNativeTarget "AlgorithmQuestions" */ = {
459 | isa = XCConfigurationList;
460 | buildConfigurations = (
461 | A29DB264214F743B00C05950 /* Debug */,
462 | A29DB265214F743B00C05950 /* Release */,
463 | );
464 | defaultConfigurationIsVisible = 0;
465 | defaultConfigurationName = Release;
466 | };
467 | A29DB26F214F747E00C05950 /* Build configuration list for PBXNativeTarget "AlgorithmQuestionsTests" */ = {
468 | isa = XCConfigurationList;
469 | buildConfigurations = (
470 | A29DB270214F747E00C05950 /* Debug */,
471 | A29DB271214F747E00C05950 /* Release */,
472 | );
473 | defaultConfigurationIsVisible = 0;
474 | defaultConfigurationName = Release;
475 | };
476 | /* End XCConfigurationList section */
477 | };
478 | rootObject = A29DB254214F743B00C05950 /* Project object */;
479 | }
480 |
--------------------------------------------------------------------------------
/AlgorithmQuestions.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AlgorithmQuestions.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AlgorithmQuestions.xcodeproj/xcshareddata/xcbaselines/A29DB269214F747E00C05950.xcbaseline/859C08CA-88FD-46A9-8445-94CEE5922D37.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | classNames
6 |
7 | TwoSumTests
8 |
9 | testPerformance()
10 |
11 | com.apple.XCTPerformanceMetric_WallClockTime
12 |
13 | baselineAverage
14 | 0.6
15 | baselineIntegrationDisplayName
16 | Local Baseline
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/AlgorithmQuestions.xcodeproj/xcshareddata/xcbaselines/A29DB269214F747E00C05950.xcbaseline/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | runDestinationsByUUID
6 |
7 | 859C08CA-88FD-46A9-8445-94CEE5922D37
8 |
9 | localComputer
10 |
11 | busSpeedInMHz
12 | 100
13 | cpuCount
14 | 1
15 | cpuKind
16 | Intel Core i7
17 | cpuSpeedInMHz
18 | 2700
19 | logicalCPUCoresPerPackage
20 | 8
21 | modelCode
22 | MacBookPro13,3
23 | physicalCPUCoresPerPackage
24 | 4
25 | platformIdentifier
26 | com.apple.platform.macosx
27 |
28 | targetArchitecture
29 | x86_64
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AlgorithmQuestions.xcodeproj/xcshareddata/xcschemes/AlgorithmQuestions.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
34 |
40 |
41 |
42 |
43 |
44 |
50 |
51 |
52 |
53 |
54 |
55 |
65 |
67 |
73 |
74 |
75 |
76 |
77 |
78 |
84 |
86 |
92 |
93 |
94 |
95 |
97 |
98 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/AlgorithmQuestions.xcodeproj/xcshareddata/xcschemes/AlgorithmQuestionsTests.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
14 |
15 |
17 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
39 |
40 |
41 |
42 |
48 |
49 |
51 |
52 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/AlgorithmQuestions/Array/TwoSum/TwoSum.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TwoSum.swift
3 | // AlgorithmQuestions
4 | //
5 | // Created by olddonkey on 2018/9/16.
6 | // Copyright © 2018年 olddonkey. All rights reserved.
7 | //
8 | import Foundation
9 |
10 | /*:
11 | ## Leetcode 1. Two Sum
12 | Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same element twice.
13 | Example:
14 | Given nums = [2, 7, 11, 15], target = 9,
15 | Because nums[0] + nums[1] = 2 + 7 = 9,
16 | return [0, 1].
17 | */
18 |
19 | /*:
20 | ## Solution
21 | ### Brute-Force:
22 | Scan through the given number from left to right twice, find the right answer.
23 | Time complexity: O(n^2)
24 |
25 | ### Dictionary:
26 | Scan from left to right, try to find target-currentNumber exist or not in dictionary, if yes, get the index from dictionary as value, if can't find, store the number-index pair into dictionary
27 | Time complexity: O(n)
28 | */
29 |
30 | class TwoSum {
31 | /// Optimized solution
32 | func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
33 | var dict = Dictionary()
34 | var result = [Int].init(repeating: 0, count: 2)
35 | for i in 0.. [Int] {
49 | let numsCount = nums.count
50 | for i in 0.. Int {
13 | let array = Array(s)
14 | var length = 0
15 | var left = 0, right = 0
16 | var i = 0
17 |
18 | while right < array.count {
19 | i = left
20 | while i < right {
21 | // If it is the same as the last character, move left forward.
22 | if array[i] == array[right] {
23 | left = i + 1
24 | break
25 | }
26 | i += 1
27 | }
28 | length = max(length, right - left + 1)
29 | right += 1
30 | }
31 | return length
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/AlgorithmQuestions/String/LongestSubstringWithoutRepeatingCharacters/LongestSubstringWithoutRepeatingCharactersTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LongestSubstringWithoutRepeatingCharactersTests.swift
3 | // AlgorithmQuestionsTests
4 | //
5 | // Created by olddonkey on 2018/9/23.
6 | // Copyright © 2018年 olddonkey. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class LongestSubstringWithoutRepeatingCharactersTests: XCTestCase {
12 | func testExample1() {
13 | let result = LongestSubstringWithoutRepeatingCharacters().lengthOfLongestSubstring("abcabcbb")
14 | XCTAssertTrue(result == 3, "Didn't find the right answer")
15 | }
16 |
17 | func testExample2() {
18 | let result = LongestSubstringWithoutRepeatingCharacters().lengthOfLongestSubstring("bbbbb")
19 | XCTAssertTrue(result == 1, "Didn't find the right answer")
20 | }
21 |
22 | func testExample3() {
23 | let result = LongestSubstringWithoutRepeatingCharacters().lengthOfLongestSubstring("pwwkew")
24 | XCTAssertTrue(result == 3, "Didn't find the right answer")
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AlgorithmQuestions/main.swift:
--------------------------------------------------------------------------------
1 | //
2 | // main.swift
3 | // AlgorithmQuestions
4 | //
5 | // Created by olddonkey on 2018/9/16.
6 | // Copyright © 2018年 olddonkey. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | print("Please run tests to see results")
12 |
13 |
--------------------------------------------------------------------------------
/AlgorithmQuestionsTests/AlgorithmQuestionsTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AlgorithmQuestionsTests.swift
3 | // AlgorithmQuestionsTests
4 | //
5 | // Created by olddonkey on 2018/9/16.
6 | // Copyright © 2018年 olddonkey. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class AlgorithmQuestionsTests: XCTestCase {
12 |
13 | override func setUp() {
14 | // Put setup code here. This method is called before the invocation of each test method in the class.
15 | }
16 |
17 | override func tearDown() {
18 | // Put teardown code here. This method is called after the invocation of each test method in the class.
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/AlgorithmQuestionsTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Posts/编程题手册 Vol.1<-center> .md:
--------------------------------------------------------------------------------
1 | # 编程题手册
2 | ###Vol.1
3 |
4 | ## 题目
5 |
6 | #### Two Sum (Leecode 1)
7 |
8 | Given an array of integers, return indices of the two numbers such that they add up to a specific target.
9 |
10 | You may assume that each input would have exactly one solution, and you may not use the same element twice.
11 |
12 | Example:
13 | ```
14 | Given nums = [2, 7, 11, 15], target = 9,
15 |
16 | Because nums[0] + nums[1] = 2 + 7 = 9,
17 | return [0, 1].
18 | ```
19 |
20 | -------
21 |
22 | 输入一个由整数构成的数组,同时给定一个目标值,要求返回相加和等于目标值的两个数字在数组中的位置。
23 |
24 | 可以假定输入只会有一个结果,同一个数字只能使用一次。
25 |
26 | 例:
27 | ```
28 | 输入 nums = [2, 7, 11, 15], 目标值 = 9,
29 |
30 | 因为 nums[0] + nums[1] = 2 + 7 = 9,
31 | 所以返回 [0, 1].
32 | ```
33 |
34 | ## 题目分析
35 |
36 | ` 经典题,LeetCode 第一题。`
37 |
38 | ##### 暴力解法:
39 |
40 | 两个 for-loop 嵌套,找出所有可能的情况,并对每对数字求和,与目标值对比,若相等则返回由这两个数字下标组成的数组。若遍历过所有情况都没有正确解,返回[0, 0]。
41 |
42 | **时间复杂度:**最差情况需要遍历所有可能的组合, O(n^2)
43 |
44 | ##### HashMap/字典解法:
45 |
46 | 扫一遍数组,每次去寻找 target - currentNumber 的值是否在 Map/字典 中存在,若不存在,则将其以数字为 Key,下标为 Value,添加到 Map/字典 当中去。若存在,则直接返回对应 Key 的 Value 和当前下标组成的数组。
47 |
48 | **时间复杂度:**因为从 HashMap 或字典中寻找一个 Key 是否存在的时间复杂度是 O(1), 所以整体的复杂度是 O(n)
49 |
50 | ## 代码
51 |
52 | ``` Swift
53 | class TwoSum {
54 | /// Optimized solution
55 | func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
56 | var dict = Dictionary()
57 | var result = [Int].init(repeating: 0, count: 2)
58 | for i in 0.. [Int] {
72 | let numsCount = nums.count
73 | for i in 0..编程题手册 Vol.2<-center>.md:
--------------------------------------------------------------------------------
1 | # 编程题手册
2 | ###Vol.2
3 |
4 | ## 题目
5 |
6 | #### Longest Substring Without Repeating Characters (LeetCode 3)
7 |
8 | Given a string, find the length of the longest substring without repeating characters.
9 |
10 | Example 1:
11 | ```
12 | Input: "abcabcbb"
13 | Output: 3
14 | Explanation: The answer is "abc", with the length of 3.
15 | ```
16 | Example 2:
17 | ```
18 | Input: "bbbbb"
19 | Output: 1
20 | Explanation: The answer is "b", with the length of 1.
21 | ```
22 | Example 3:
23 | ```
24 | Input: "pwwkew"
25 | Output: 3
26 | Explanation: The answer is "wke", with the length of 3.
27 | Note that the answer must be a substring,
28 | "pwke" is a subsequence and not a substring.
29 | ```
30 | -------
31 |
32 | 输入一个字符串,返回没有重复字符串的最长子字符串的长度
33 |
34 | 例 1:
35 | ```
36 | 输入: "abcabcbb"
37 | 输出: 3
38 | 解答: 不重复字符串的最长子串是 "abc" ,所以应该返回 "abc" 的长度3.
39 | ```
40 | 例 2:
41 | ```
42 | 输入: "bbbbb"
43 | 输出: 1
44 | 解答: 不重复字符串的最长子串是 "b" ,所以应该返回 "b" 的长度3.
45 | ```
46 | 例 3:
47 | ```
48 | 输入: "pwwkew"
49 | 输出: 3
50 | 解答: 不重复字符串的最长子串是 "wke" ,所以应该返回 "wke" 的长度3.
51 | 需要注意的是因为这里要求的是最小子串,而非子序列,所以
52 | ```
53 |
54 | ## 题目分析
55 |
56 | ` 经典题,LeetCode 第三题。`
57 |
58 | ##### 双指针:
59 |
60 | 这道题目算是一道非常经典的双指针问题。
61 |
62 | 类似的题目有 Sliding Window,之后应该也会讲到。
63 |
64 | 解法其实并不复杂。建立一个 Int,用来保存当前的最大长度。两个指针,一个指向 substring 的头,一个指向 substring 的尾部,初始均指向头部。
65 |
66 | 每次开始前,从 left 开始寻找,直到找到和 right 相同的字符,将 left 移动到那个字符的后一个,这样,就能保证不会出现重复字符。
67 |
68 | 没找到则不用理会。
69 |
70 | 之后将 right 向右移动一位。如此从左到右,就可以找到所有的情况。
71 |
72 | ## 代码
73 |
74 | ``` Swift
75 | class LongestSubstringWithoutRepeatingCharacters {
76 | func lengthOfLongestSubstring(_ s: String) -> Int {
77 | let array = Array(s)
78 | var length = 0
79 | var left = 0, right = 0
80 | var i = 0
81 |
82 | while right < array.count {
83 | i = left
84 | while i < right {
85 | // If it is the same as the last character,
86 | //move left forward.
87 | if array[i] == array[right] {
88 | left = i + 1
89 | break
90 | }
91 | i += 1
92 | }
93 | length = max(length, right - left + 1)
94 | right += 1
95 | }
96 | return length
97 | }
98 | }
99 | ```
--------------------------------------------------------------------------------
/Posts/Vol1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olddonkey/AlgorithmQuestionsHandBook/97a322b0d7cf55ee11235acf40f1095805d728ec/Posts/Vol1.jpg
--------------------------------------------------------------------------------
/Posts/Vol2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olddonkey/AlgorithmQuestionsHandBook/97a322b0d7cf55ee11235acf40f1095805d728ec/Posts/Vol2.jpg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AlgorithmQuestionsHandBook
2 | Weekly share some interesting interview question.
3 |
--------------------------------------------------------------------------------