Strings & Palindromes | Recursion Series

preview_player
Показать описание
In this video we explore how to reverse a string using recursion and check whether or not a string is a palindrome using the 'outside-in' method.

Source code repository:

Video slides:
Рекомендации по теме
Комментарии
Автор

@4:25, I think it should be substring = s.substring ( 1, n - 2 ); not n-1

A
Автор

Woahhhh you are back . Hey William ....huge fan of your content . Welcome back ❤

pramodhjajala
Автор

def different_chars(string1, string2):

if len(string1) != len(string2):
raise Exception("Strings must be of equal length")
chars = set() # could be returned as empty

for i in range(len(string1)):
if string1[i] != string2[i]:
chars.add(string2[i])
return chars
print(different_chars("racecar", "racecar"))
print(different_chars("hey", "bye"))

kvelez
Автор

Your video on recursion has really deepened my understanding of recursion to great detail….👍🏾👍🏾👍🏾

adehenry
Автор

def reverse_string(string):
if len(string) == 0:
return string
return reverse_string(string[1:]) + string[0]

def is_palindrome(string):
backwards = reverse_string(string)
if backwards == string:
return True
return False
print(f"Palindrome: {is_palindrome("racecar")}")

kvelez