• 15 October

    Count 1’s in sorted Binary Array

    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 count number of 1’s in sorted binary array. Problem Print number of 1’s in a given sorted Binary Array. For eg:- int[] arr = {0,0,0,1,1,1,1}; output : 4 int[] arr […]

  • 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, […]

  • 17 February

    Check if Array Elements are Consecutive

    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 check if array elements are consecutive. Problem Given an array, we need to check if array contains consecutive elements. For example: Input: array[] = {5, 3, 4, […]

  • 30 September

    Longest common substring

    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 longest common substring in java. Program Given two String, find longest common substring. For example: String 1: Java2blog String 2: CoreJavaTutorial Longest common subString is: […]

  • 27 September

    Print maximum occurring character in a String

    In this post, we will see how to print the maximum occurring character in a String. Problem Print maximum occurring character in a String For example: String 1: java2blog tutorial Character: a has occurred maximum times in String: 3 ———————- String 2: This is test message Character: s has occurred maximum times in String: 5 […]

  • 26 September

    Print all subarrays of a given 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 print 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}, […]

  • 18 August

    Print all paths from top left to bottom right of MxN matrix

    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 print all paths from top left to bottom right of MxN matrix. Problem We need to print all paths from top left to bottom right of MxN matrix. You can either […]

  • 18 August

    Print Numbers from 1 to N without using loop

    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 print numbers from 1 to N without using loop. Problem Print number from 1 to N without using any loop. N=10 Output: 1 2 3 4 5 6 7 8 […]

  • 16 August

    Find all subsets of set (power set) 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 subsets of set or power set in java. Problem Given a set of distinct integers, arr, return all possible subsets (the power set). For example: Input: nums = [1,2,3] Output: […]