Professional Documents
Culture Documents
AP-1.4_21BCS4422_Manohar Chaudhary_ FL-603
AP-1.4_21BCS4422_Manohar Chaudhary_ FL-603
AP-1.4_21BCS4422_Manohar Chaudhary_ FL-603
Experiment 1.4
Student Name: Manohar Chaudhary UID: 21 BCS4422
Branch: BE-CSE Section/Group: FL-603-B
Semester: 6th Date of Performance: 30-01-2024
Subject Name: Advance Programming-2 Subject Code: 21CSP-251
I. Problem statement – Given a string s, find the length of the longest Substring without
repeating characters. Input: s = "abcabcbb"
II. Problem statement – You are given a string s. You can convert s to a Palindrome by
adding characters in front of it. Return the shortest palindrome you can find by
performing this transformation. Input: s = "aacecaaa"
2. Objective:
• Finding the length of the longest substring without repeating characters.
• Constructing the shortest palindrome from a given string by adding characters to its
beginning.
2nd:
class Solution:
def shortestPalindrome(self, s: str) -> str:
i=0
n = len(s)
for j in range(n):
if s[i] == s[n-j-1]:
i += 1
if i==n:
return s
p = s[i:n][::-1]
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Learning Outcomes: