• Find peak element in the array
    14 October

    Find peak element in the array

    If you want to practice data structure and algorithm programs, you can go through 100+ data structure and algorithm programs. In this post, we will see how to find peak element in the array. Problem Given an array of integers. find the peak element in the array. Peak Element is the element of the array […]

  • 09 October

    Find first repeating element in an array of integers

    If you want to practice data structure and algorithm programs, you can go through 100+ data structure and algorithm programs. In this post, we will see how to find the first repeating element in array of integers. Problem Find the first repeating element in array of integers. For example: Input: array[] = {10, 7, 8, […]

  • 26 September

    Generate all subarrays of an array

    If you want to practice data structure and algorithm programs, you can go through 100+ data structure and algorithm programs. In this post, we will see how to generate all subarrays of given array. Problem Print all print all subarrays of given array. For example: If array is {1,2,3} then you need to print {1}, […]

  • 13 August

    Permutations of array in java

    If you want to practice data structure and algorithm programs, you can go through Java coding interview questions. In this post, we will see how to find all permutations of the array in java. Problem 1 Given array of distinct integers, print all permutations of the array. For example: array : [10, 20, 30] Permuations are : […]

  • 20 January

    Java program to find largest number in array

    In this tutorial, Java program to find the largest number in array. Here is simple algorithm to find larget element in the array. Initialize lrg with arr[0] i.e. first element in the array. If current element is greater than lrg, then set lrg to current element. [crayon-6767d4f5f2745306252971/] Output: Enter Array Size : 5 Enter Array […]

  • 20 January

    Java program to find minimum value in array

    In this tutorial, Java program to find minimum value in an array. Here is simple algorithm to find minimum value in the array. Initialize sml with arr[0] i.e. first element in the array. If current element is less than sml, then set sml to current element. [crayon-6767d4f5f27cd847836687/] Output: Enter array Size : 3 Enter array […]

  • 24 December

    Linear Search in Java

    If you want to practice data structure and algorithm programs, you can go through Java coding interview questions. In this post, we will see about linear search in java. Linear search is simple sequential search in which target element is searched one by one in the array. If element is found in the array then index […]

  • 23 August

    Sort array in java

    In this post, we will see how to sort an array in java. There are various ways to sort array in java. You can implement different sorting algorithms to sort an array. You can use Arrays.sort method to sort array in java. There are various overloaded versions of Arrays.sort method. You can go through it […]

  • 02 February

    Rotate an array by K positions

    In this tutorial, we will see how to rotate an array be K positions. Problem: N=6 and k=2 If Arr[] = {1, 2, 3, 4, 5, 6} and k=2 then [rotated array](https://java2blog.com/search-element-in-sorted-and-rotated-array-java/ “rotated array”) will be  {5, 6, 1, 2,  3,  4} Solution: There are multiple ways to solve this problem. Approach 1: Move each […]