Arrays Series #7- Alternate positive and negative numbers- Solution Explained in Java

Given an unsorted array Arr of N positive and negative numbers. Your task is to create an array of alternate positive and negative numbers without changing the relative order of positive and negative numbers.
Note: Array should start with positive number.
Example 1:
Input:
N = 9
Arr[] = {9, 4, -2, -1, 5, 0, -5, -3, 2}
Output:
9 -2 4 -1 5 -5 0 -3 2
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
➡️ Practice here - practice.geeksforgeeks.org/pr...
---------------------------------------------------------
Please click the LIKE button so that this kind of content can be seen by as many as possible aspiring engineers and professionals. Doing so gives me even more motivation to post such content in the future.
Please comment below and let me know if you have any questions or concerns.
Additionally, don't forget to click the bell symbol to receive notifications and subscribe to the channel.
Follow us on:
➡️Twitter - / codeease
----------------------------------------------------------
Created and Instructed by:
Varsha Das
Mid-senior Software Engineer, Content Curator of ‪@codewithease-byvarsha‬
➡️ LinkedIn - / varsha-das-se
➡️ Quora - www.quora.com/profile/Varsha-...
➡️ Hashnode - varsha-das.hashnode.dev/
Code With Ease is meant to make problem-solving in programming easier. For DSA preparation, we post topic-specific videos pertaining to Coding Interview topics so that everyone may approach such questions with a clear thought process and achieve the best outcomes. In addition, we make an effort to include different "Primer Series" that teach particular concepts or algorithms. We want to be the one-stop solution for everything pertaining to DSA preparation and programming foundations in general, saving candidates from having to visit many sources in order to receive structured content.
Additionally, we believe that learning to code entails much more than only "cracking the coding interview." The long-term goal of this channel is to create more proficient problem-solvers in this field so that, in the end, we can create fantastic products and be able to resolve challenging issues in our environment to improve the quality of life for everyone.
#codinginterviewquestions #dsa #codewithease #datastructureandalgorithm #programming #javaprogramming #arraysinjava

Пікірлер: 2

  • @aishwaryadeshmukh9531
    @aishwaryadeshmukh95316 ай бұрын

    thankyou....nicely explained

  • @codewithease-byvarsha

    @codewithease-byvarsha

    4 ай бұрын

    Glad you like them! If you could spare 3 mins to help this channel grow further, kindly nominate me here for National Creator Awards. For more details : tinyurl.com/bdhuj237

Келесі