Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to find the longest palindromic substring in a given string.

Medium

Problem Statement

Write a function to find the longest palindromic substring in a given string.

Sample Input

A string: "babad"

Sample Output

Longest palindromic substring: "bab"

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun isSymmetric(matrix: Array<Array<Int>>): Boolean { // Add your code here to check if the matrix is symmetric } fun main() { val matrix = arrayOf( arrayOf(1, 2, 3), arrayOf(2, 4, 5), arrayOf(3, 5, 6) ) if (isSymmetric(matrix)) { println("The matrix is symmetric") } else { println("The matrix is not symmetric") } }
Log in or sign up to run or submit your code.Log inSign up
Input
A string: "babad"
Expected Output
Longest palindromic substring: "bab"