Core Java Programming Challenges #29 | Coding Challenges | Naresh IT

preview_player
Показать описание
Core Java Programming Challenges #29 | Coding Challenges | Naresh IT

💡 Also Watch

Java Programming Tutorials by Mr.Hari krishna:
Advanced Java Programming Tutorials by Mr.Nataraj:

Subscribe to our channel and hit the bell 🔔🔔🔔 icon to get video updates.

💡 Visit Our Websites
#CoreJava_Programing #Challenges #CoreJava #Quiz
--------------------------

💡 About NareshIT:

"Naresh IT is having 14+ years of experience in software training industry and the best Software Training Institute for online training, classroom training, weekend training, corporate training of Hadoop, Salesforce, AWS, DevOps, Spark, Data Science, Python, Tableau, RPA , Java, C#.NET, ASP.NET, Oracle, Testing Tools, Silver light, Linq, SQL Server, Selenium, Android, iPhone, C Language, C++, PHP and Digital Marketing in USA, Hyderabad, Chennai and Vijayawada, Bangalore India which provides online training across all the locations

--------------------------

💡 Our Online Training Features:
🎈 Training with Real-Time Experts
🎈 Industry Specific Scenario’s
🎈 Flexible Timings
🎈 Soft Copy of Material
🎈 Share Videos of each and every session.

--------------------------

💡 Please write back to us at

--------------------------

💡 Check The Below Links

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

class PushZero
{
// Function which pushes all zeros to end of an array.
static void pushZerosToEnd(int arr[], int n)
{
int count = 0; // Count of non-zero elements

// Traverse the array. If element encountered is
// non-zero, then replace the element at index 'count'
// with this element
for (int i = 0; i < n; i++)
if (arr[i] != 0)
arr[count++] = arr[i]; // here count is
// incremented

// Now all non-zero elements have been shifted to
// front and 'count' is set as index of first 0.
// Make all elements 0 from count to end.
while (count < n)
arr[count++] = 0;
}

/*Driver function to check for above functions*/
public static void main (String[] args)
{
int arr[] = {3, 0, 5, 6, 0, 0, 7, 0, 0, 2, 7, 5};
int n = arr.length;
pushZerosToEnd(arr, n);
System.out.println("Array after pushing zeros to the back: ");
for (int i=0; i<n; i++)
System.out.print(arr[i]+" ");
}
}

gsrcreations
Автор

public class Test {

public static void main(String[] args) {
int[] arr = {0, 0, 5, 6, 0, 0, 7, 0, 0, 2, 7, 5};
int i = 0;
int j = arr.length-1;

while(i <= j){
while(arr[i] != 0){
i++;
}
while(arr[j] == 0){
j--;
}
swap(arr, i, j);
if(i < j){
i++;
j--;
}
}

}

private static void swap(int[] arr, int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}

MaulikSakhida
Автор

I like your c videos sir please use board sir that way understand easily

nadhikutty
Автор

public class Challenge27 {

public static void main(String[] args) {

int arr[] = {3, 0, 5, 6, 0, 0, 7, 0, 0, 2, 7, 5};
int count = 0;
for(int i = 0;i<arr.length;i++)
{
if(arr[i]!=0)
{
arr[count]=arr[i];
count++;
}
}
for(int i=count+1;i<arr.length;i++)
{
arr[i]=0;
}

for(int i = 0;i<arr.length;i++)
{
System.out.print(arr[i]+", ");
}
}

}

Output
3, 5, 6, 7, 2, 7, 5, 0, 0, 0, 0, 0,

SunilKumarSunil
Автор

sir I have one doubt what is difference between java and core java

nadhikutty
Автор

import java.util.Arrays;

public class Challenge29 {
public static void main(String[] args) {
int a[] = {3, 2, 0, 1, 2, 3, 0, 9, 6, 0, 5, 7};
int temp;
for(int i = 0;i<a.length; i++){
if(a[i] == 0){
for(int j=i+1;j<a.length;j++){
if(a[j]!=0){
temp = a[i];
a[i] = a[j];
a[j] = temp;
break;
}
}
}
}
}
}

samahmahdi
welcome to shbcf.ru