-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPalendromeFind.txt
46 lines (28 loc) · 1.43 KB
/
PalendromeFind.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Given a string of random characters, write code that will find the longest palendrome.
Example input:
GHDUFNEICJSODLFJGHFYDNDJSKDNCHFGEJDBDJEGFHCNDKYATRSMZPLOBSRQNSB
Extra credit:
Please analyze the runtime of your solution. Can you improve on it?
Notes:
With emphasis on the "longest" palendrome one idea would be first to start spliting the string and looking for long palendromes.
What is a palendrome?
http://en.wikipedia.org/wiki/Palindrome
challenges:
- is the string a palendrome?
- strategy for evaluating sub strings in a large string
- generate randome stings
- what if the string was larger than what could fit in RAM?
- profile
examples:
ABBA
CDC
ABCDEFGFEDCBA
notice that you don't start recognizing the palendrome until the mirror starts
idea: to start in the middle of the string and work your way towards the ends
idea: start with len of string, decrement and shift the sub string across the entire string.
idea: why not just reverse the entire string and compare it against itself... for large strings this would mean double memory? splitting the string first means less ops in the reverse?
if the string is too large to fit in memory, we could build a hash of the chars as they are read off disk then compare the hashes.
how should multiples be handled?
do we always just return the first largest or should we continue checking for others of the same size?
profile:
how many slots will need to be evaluated for each test string?