Write a program to move all negative elements to end in an int array ? || Java problem solving
Vložit
- čas přidán 11. 09. 2024
- #kkjavatutorials
About this Video:
Hello Friends,
In this video we will write a java program for below problem statement:
Write a program to move all negative elements to end in an int array ?
Source Code LINK:
bit.ly/2ZUxDZg
Follow me on Social network:
Facebook : / kkjavatutorials
Twitter : / kkjavatutorials
instagram : / kkjavatutorials
Google Plus:plus.google.co...
KK JavaTutorials WebSite:
kkjavatutorial...
Subscribe KK JavaTutorails CZcams Channel:
/ kkjavatutorials
Subscribe My Hindi Channel(KK HindiGyan):
bit.ly/2AL1ub6
Some Important Playlist link on KK JavaTutorials:
Spring Framework Tutorial:
bit.ly/2F0Fltx
Eclipse shortcuts :
bit.ly/2QiL27j
Java 8 Features Tutorial(All In One):
bit.ly/2OnKmf5
JDBC Tutorial in depth[Must Watch]
bit.ly/2Ou5sso
Java 8 Stream APIs:
bit.ly/2RwPBek
WebLogic Server Tutorials:
bit.ly/2SIuV4x
Spring Boot Tutorial(All In One):
bit.ly/2P8PJ7f
Hibernate Tutorials:
bit.ly/2QiZI6r
Java 5 new features Tutorials
bit.ly/2SKCV59
Java 7 Features tutorials:
bit.ly/2ALPoP4
Java multithreading for beginners:
bit.ly/2PGIpyW
Java Collections framework Tutorials:
bit.ly/2zqeEs5
OOPs concepts in java Tutorials:
bit.ly/2QgUdF9
Kk please start Java9 and above series. I learnt a lot from ur java8 series. Thanks a lot 😊👍.
IntStream positives = Arrays.stream(arr).filter(n -> n >= 0);
IntStream negatives = Arrays.stream(arr).filter(n -> n < 0);
return IntStream.concat(positives, negatives).toArray();
Thanks a lot 🙏❤️
what is the time and space complexity in 2nd solution?
Arrays.stream(arr). boxed ().sorted(Comparator.comparingInt(Integer::intValue). reversed ()).toArray(Integer[]::new);
One line code using java8
First you should explain the approch before jumping into code