Category Archives: DAILY 1 PROGRAM

BUBBLE SORT PROGRAM IN JAVA

By | June 9, 2024

BUBBLE SORT PROGRAM Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. Here is a simple implementation of Bubble Sort in Java: In this code, bubbleSort(int arr[]) is the… Read More »

FIND THE HIGHEST ALTITUDE PROGRAM IN JAVA

By | March 27, 2024

Example 1:Input: gain = [-5,1,5,0,-7] Output: 1 Explanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1. To find the highest altitude of a point during a road trip, we can iterate through the gain array and calculate the cumulative altitude at each point. Then, we track the maximum altitude reached during the trip. Here’s the Java program implementing… Read More »

Length Of the Valid Substring Program In java

By | March 24, 2024

Example: Input: word = “cbaaaabc”, forbidden = [“aaa”,”cb”] Output: 4 Certainly! Let’s break down the problem and then provide a Java solution: Problem Explanation: You are given a string word and an array of strings forbidden. You need to find the length of the longest valid substring of word, where a substring is considered valid if none of… Read More »

TRANSPOSE MATRIX PROGRAM IN JAVA

By | March 24, 2024

In the Given Array n*n Matrix, return the Transpose Matrix EX: matrix=[[1,2,3],[4,5,6],[7,8,9]]Output: [[1,4,7], [2,5,8], [3,6,9]] To transpose a matrix in Java, you can create a new matrix where the rows become columns and vice versa. Here’s a simple implementation:

ROTATE MATRIX PROGRAM IN JAVA

By | March 23, 2024

Given an image represented by an N*N . Write a method to rotate the image by 90 degrees. Let’s go through the program step by step: This approach achieves the 90-degree clockwise rotation in place, meaning it modifies the original matrix without using additional space proportional to the input matrix size. The time complexity of this approach is… Read More »