Tape Equilibrium

Problem A non-empty array A consisting of N integers is given. Array A represents numbers on a tape. Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: The difference between the two parts is the value of: In other words, it is the absolute difference between the sum of…

Read More

Perm Missing Elem

Problem An array A consisting of N different integers is given. The array contains integers in the range 1..(N + 1), which means that exactly one element is missing. Your goal is to find that missing element. Write a function: that, given an array A, returns the value of the missing element. For…

Read More

Perm Check

Problem A non-empty array A consisting of N integers is given. A permutation is a sequence containing each element from 1 to N once, and only once. For example, array A such that: is a permutation, but array A such that: is not a permutation, because value 2 is missing. The goal is to check whether…

Read More

Cyclic Rotation

Problem An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = 3, 8, 9, 7, 6 is 6, 3, 8, 9, 7 (elements are shifted right by one…

Read More

Missing Integer

Problem This is a demo task. Write a function: that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = 1, 3, 6, 4, 1, 2, the function should return 5. Given A = 1, 2, 3, the function should return 4. Given A = −…

Read More
Page 21 Of 26