<p>You are given a string <code>s</code>. You can convert <code>s</code> to a <span data-keyword="palindrome-string">palindrome</span> by adding characters in front of it.</p>

<p>Return <em>the shortest palindrome you can find by performing this transformation</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "aacecaaa"
<strong>Output:</strong> "aaacecaaa"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "abcd"
<strong>Output:</strong> "dcbabcd"
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>0 &lt;= s.length &lt;= 5 * 10<sup>4</sup></code></li>
	<li><code>s</code> consists of lowercase English letters only.</li>
</ul>

#Shortest pallindrome
#Pallindrome made by selecting pivot and placing all letters to the right in front of the word
#Verifying said word is a pallindrome and savinf this output to return
#Now this is kind of easy if we dont care about time complexity


class Solution:
    def shortestPalindrome(self, s: str) -> str:
        #Initialises list, for reversed() function
        if s == "":
            return ""
        
        letter_list = []
        
        #Appends every letter in order
        for i in range(len(s)):
            letter_list.append(s[i])

        #Now can we cut complexity
        #Consider the word 'hih' is already a pallindrome
        #Would it make more sense to move the pivot from right to left? Probably, yes

        #Also would we ever select the pivot at the second from the left?
        #Yes and should hold for every case

        #Initalise right to left indexing
        for i in range(len(letter_list)):
            #To slice letters right to left 
            # base case i = 0, probably a way to make redundant, reduce complexity
            if i == 0:
                if letter_list == list(reversed(letter_list)):
                    return s
            else:
                #Think that is the correct implementation? May be an off by one error
                additional_letters = letter_list[-i:]
                possible_pallindrome = list(reversed(additional_letters)) + letter_list
                if possible_pallindrome == list(reversed(possible_pallindrome)):
                    return ''.join(possible_pallindrome)
                    
        

                 

        

18700