Given an array, arr[] and a positive integer K. The task is to find the position say i of the element in arr[] such that prefix sum till i-1, i and suffix sum till i+1 are in Geometric Progression with common ratio K. Examples:Input: arr[] = { 5, 1, 4, 20, 6, 15, 9, 10 }, […]

Continue Reading#include using namespace std; int findIndex(int arr[], int N){ int maxValue = INT_MIN; for (int i = 0; i < N; i++) { maxValue = max(maxValue, arr[i]); } map St; for (int i = 1; i

Continue Readingimport java.io.*; import java.lang.*; import java.util.*; class GFG{ static int MAX = (int)(1e9); static int MinimumLength(int A[], int N, int K) { Arrays.sort(A); int suffix[] = new int[N + 1]; for(int i = N – 1; i >= 0; i–) suffix[i] = suffix[i + 1] + A[i]; int dp[][] […]

Continue Reading