Java Program to left rotate the Array

The following Java program rotates the array to d rotational integer. A left rotation operation on an array shifts each of the array’s elements  unit to the left. For example, if left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2]. The Code makes use of swapping using temp variable for circular […]

Advertisements

Finding Kth Maximum Number from an Array in Java

The following program is used to find the Kth Maximum number from a given unsorted array. The approach on which this code is written uses sorting and then gives out the Kth  maximum number. This can be done without sorting too. At the end of the code, you will get a […]

Advertisements

Swapping every two bits in byte Java Solution

In the Swapping of two bits in byte in java, the output should look like something below: Swap all the pair of bits in a byte. Before swapping: 11-10-11-01 After swapping: 11-01-11-10 The code is written and tested in Netbeans. Code: import java.util.Arrays; import java.util.Scanner; public class bitbyte { public […]

Advertisements

Converting Decimal to Binary in Java

The below code will convert decimal number in binary format [bits] in java. I have taken a byte as an array, i.e. 8. You can take more depending on your needs. The input for the current program is a with the value 48. You can take the input through scanner […]

Advertisements

GeeksforGeeks Sudo Placement: Validate an IP Address in Java

The code is written in java. The output that is generated is correct, I have corrected the code on their page which is already written, It was generating error on submit,so I thought to publish the code here. The code ask to validate an IP address, that the given ip […]

Advertisements