๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.61K photos
3 videos
95 files
10.6K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
โœ…โœ… Break the Palindrome

class Solution {
public String breakPalindrome(String palindrome) {
// If empty or of length 1 => return empty
if (palindrome.length() <= 1) {
return "";
}
char[] chars = palindrome.toCharArray();
for (int i = 0; i < chars.length; i++) {
if (chars[i] != 'a') {
// Skip if the string is of odd length and it is the middle index
if (palindrome.length() % 2 != 0 && i == palindrome.length() / 2) {
continue;
}
chars[i] = 'a';
break;
}
// If all chars all 'a' update last char to 'b'
if (i == chars.length - 1) {
chars[i] = 'b';
}
}
return String.valueOf(chars);
}
}
๐Ÿ‘1
โœ…โœ…โœ… Mettl - Large Small Difference - Tech Mahindra Exam
def LargeSmallDifference(data):
l = data[0]
s = data[0]
for num in data:
if num> l:
l = num
elif num< s:
s = num
return l, s

print(LargeSmallDifference([0, 10, 15, 40, -5, 42, 17, 28, 75]))