Coding Questions – Easy, Medium, Hard
Easy Level Question
Given an array of integers, write a program to calculate the sum of all even numbers present
in the array.
Input: An array of integers
Output: An integer representing the sum of even numbers
Example:
Input: [1, 2, 3, 4, 5]
Output: 6
Medium Level Question
Given an array of integers and a target value, write a program to find the indices of two
numbers in the array such that their sum is equal to the target value. Assume that exactly
one solution exists.
Input: An array of integers and a target integer
Output: Indices of the two numbers
Example:
Input: nums = [3, 5, 2, 7], target = 9
Output: [1, 2]
Hard Level Question
Given a string, write a program to find the length of the longest substring without repeating
characters.
Input: A string
Output: An integer representing the length of the longest substring
Example:
Input: "abcabcbb"
Output: 3