Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/randhir200/masai-numbers-game

You are given an array A of N integers. Now, two functions F(X) and G(X) are defined: F(X) : This is the smallest number Z such that X < Z <= N and A[X] < A[Z] G(X) : This is the smallest number Z such that X < Z <= N and A[X] > A[Z] Now, you need to find for each index i of this array G(F(i)) , where 1 <= i <= N. If such a number does not exist, for a particular index i, output -1 as its answer. If such a number does exist, output A[G(F[i])]
https://github.com/randhir200/masai-numbers-game

Last synced: 2 days ago
JSON representation

You are given an array A of N integers. Now, two functions F(X) and G(X) are defined: F(X) : This is the smallest number Z such that X < Z <= N and A[X] < A[Z] G(X) : This is the smallest number Z such that X < Z <= N and A[X] > A[Z] Now, you need to find for each index i of this array G(F(i)) , where 1 <= i <= N. If such a number does not exist, for a particular index i, output -1 as its answer. If such a number does exist, output A[G(F[i])]

Awesome Lists containing this project