Squares of a Sorted Array | Java Coding Interview Question and Answer | Leetcode 977 | Code Decode

preview_player
Показать описание
In this video of data structure by code decode we have picked leetcode 977
i.e. square of sorted array. This is a very simple array coding question it seems very tricky

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

please watch this video at 1.25x for better experience.

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

Example 1:
Input: nums = [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Explanation: After squaring, the array becomes [16,1,0,9,100].
After sorting, it becomes [0,1,9,16,100].

Example 2:
Input: nums = [-7,-3,2,3,11]
Output: [4,9,9,49,121]

Hibernate Interview Questions and Answers:

Spring Boot Interview Questions and Answers:

Subscriber and Follow Code Decode

#datastructure #array #codedecode
Рекомендации по теме
Комментарии
Автор

As you mentioned please create video of sorting algos it will very helpful and nice presentation 👍

pratikkurbet
Автор

Brute force approach also O(N) time complexity only right? O(N) +O(N) = O(2N) =O(N) Correct me if I am wrong

nagalakshmikesavan
Автор

what is the space complexity for this program - O(N) ?
can we optimize and make it to O(1) ?
#JustAsking

PrakashPangeni-py
Автор

sorted().toArray()

How about this solution?

rakshithagowda
Автор

A[]={-11, -12, 0, 3, 10} this logic is not working

solomonjyothsna
welcome to shbcf.ru