Algorithms

Maximum sum subarray of length k in array of n integers
AskAI

Find the contiguous subarray of length k with the maximum sum in an array of n integers.

longest consecutive sequence
AskAI

This problem asks you to find the length of the longest consecutive sequence in an array of integers. Your algorithm should run in O(n) time and use only constant space.

Squares of an Array
AskAI

This technical problem deals with taking an array of integers and returning an array of the squares of those integers. So, for example, if the input array is [-1, 2, 3, 4, 5], the output array would be [1, 4, 9, 16, 25].

Find the maximum average value in a contiguous subarray of length k.
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.

Two Sum
AskAI

The problem is to find the indices of two numbers in an array that sum up to a given target. There is always a solution, and you cannot use the same element twice.

Product of All Array Elements Except the One at Index i
AskAI

Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.

Sum of Positive Integers in Array
AskAI

The function should take in an array of positive integers and return the sum of all the integers in the array.

Longest consecutive element sequence
AskAI

Given an unsorted array of integers, this algorithm will find the length of the longest consecutive element sequence. For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. The algorithm will return the length of this sequence, which is 4. The algorithm runs in O(n) complexity.