## Longest positive subarray

Array A[] contains only ‘1’ and ‘-1’

Construct array B, where B[i] is the length of the longest continuous subsequence starting at j and ending at i, where j < i and A[j] + .. + A[i] > 0

## Double array initialization in Java

I was reading a book on Java and came across an example in which an array of type double was initialized in a way that I haven’t seen before. What type of initialization is it and where else can it be …

## How to change the position of an array element?

I have a question on how I can change the index of a array element, so that it doesn’t come at the 7. position but at position 2 instead…

Is there a function to handle this?

## How to create ArrayList (ArrayList) from array (int[]) in Java

I have seen the question: Create ArrayList from array

However when I try that solution with following code, it doesn’t quite work in all the cases:

import java.util.ArrayList;
import java.util….

## How to find duplicate elements’ index in C++?

Is there any STL function in C++ that allows me to find all indices of duplicates in an array?

For eg:

int array[] = {1,1,2,3,4};
Should return 0,1

## Numpy: For every element in one array, find the index in another array

I have two 1D arrays, x & y, one smaller than the other. I’m trying to find the index of every element of y in x.

I’ve found two naive ways to do this, the first is slow, and the second memory-…

## Getting a collection of index values using a LINQ query

Is there a better way to do this?

string[] s = {“zero”, “one”, “two”, “three”, “four”, “five”};

var x =
s
.Select((a,i) => new {Value = a, Index = i})
.Where(b => b.Value.StartsWith(“t”))
….

## Why [1:2] != Array[1:2]

I am learning Julia following the Wikibook, but I don’t understand why the following two commands give different results:

julia> [1:2]
1-element Array{UnitRange{Int64},1}:
1:2

julia> Array[1:…

## Swift: Get all subviews of a specific type and add to an array

I have a custom class of buttons in a UIView that I’d like to add to an array so that they’re easily accessible is there a way to. Get all subviews of with a specific class and add it to an array in …