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

Programming Exercises

Write a function to find the longest substring without repeating characters.

Medium

Problem Statement

Write a function to find the longest substring without repeating characters.

Sample Input

A string: "abcabcbb"

Sample Output

Longest substring: "abc"

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun maxDifference(arr: Array<Int>): Int { // Add your code here to find the maximum difference } fun main() { val array = arrayOf(2, 3, 10, 6, 4, 8, 1) println("The maximum difference is: ${maxDifference(array)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
A string: "abcabcbb"
Expected Output
Longest substring: "abc"