Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVASCRIPT Your task is to write a program that models growth trends based on historical financial data. Specifically, you will be given an array of

JAVASCRIPT
Your task is to write a program that models growth trends based on historical financial data. Specifically, you will be given an array of financial growth percentages (which may include negative values representing a decrease). You need to return an array of the growth trends squared, sorted in non-decreasing order, simulating a real-world business data analysis scenario.
Problem Statement:
Given an array growthPercentages representing yearly growth percentages of a company's revenue, sorted in non-decreasing order, return an array of the squared growth percentages, also sorted in non-decreasing order.
Input Format:
An array growthPercentages where each element is an integer representing the yearly growth percentage.
Output Format:
An array of integers representing the squared growth percentages, sorted in non-decreasing order.
Examples:
Example 1:
Input: growthPercentages =[-5,-2,0,3,10]
Output: [0,4,9,25,100]
Explanation: After squaring, the array becomes [25,4,0,9,100]. After sorting, it becomes [0,4,9,25,100].
Example 2:
Input: growthPercentages =[-8,-3,2,4,12]
Output: [4,9,16,64,144]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions