Problem 59741. Pivot index
Let L be a vector of numbers. We are searching for the index n of the pivot element defined as follows: the dot product of the elements in the sub-vector to the left by their distance to the pivot element is equal to the dot product of the elements in the sub-vector to the right by their distance to the pivot element.
Example 1:
If L = [6,1,10,5,4], then n = 3 since :
- Left sub-vector: L(1:n-1) = [6,1] and distances = [2,1] so dot product =
- Right sub-vector: L(n+1:end) = [5,4] and distances = [1,2] so dot product =
Example 2:
If L = [10,3,3,2,1], then n = 2 since :
- Left sub-vector: L(1:n-1) = [10] and distances = [1] so dot product =
- Right sub-vector: L(n+1:end) = [3,2,1] and distances = [1,2,3] so dot product =
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers11
Suggested Problems
-
314 Solvers
-
Project Euler: Problem 9, Pythagorean numbers
1407 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1219 Solvers
-
ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
584 Solvers
-
Find Rows with Specift Properities
287 Solvers
More from this Author53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!