Algorithms

Sum of Array Elements
AskAI

This problem asks for the sum of all elements in an array. An example input is given as [1, 2, 3, 4, 5], and the expected output is 15.

First Non-Repeating Character in a String
AskAI

Given a string, this problem seeks to find the index of the first non-repeating character within it. If no such character exists, the function returns -1. Examples are provided to demonstrate how the function works.

Largest Sum of Contiguous Subarray
AskAI

Given an array of integers, the largest sum of any contiguous subarray can be found by iterating through the array and keeping track of the current sum. If the current sum is greater than the largest sum found so far, it becomes the new largest sum. The largest sum is then returned.

Longest Substring Without Repeating Characters
AskAI

Given a string, the longest substring without repeating characters is found by iterating through the string and keeping track of the longest substring found so far.

"Find the First Missing Positive Integer"
AskAI

Given an array of integers, this algorithm will find the first missing positive integer. It runs in linear time and constant space.

Sum of Odd Numbers in Array
AskAI

This problem asks the programmer to return the sum of the odd numbers in an array. An example input would be [1, 2, 3, 4, 5] and the corresponding output would be 9.

Find the Maximum Average Value in an Array
AskAI

Given an array of n integers, find the contiguous subarray of given length k that has the maximum average value. Output the maximum average value.

Find the First Missing Positive Integer in an Array
AskAI

Given an array of integers, this problem asks you to find the first missing positive integer. You should do this in linear time and constant space. Note that the array may contain duplicates and negative numbers.