• 06 October

    Convert decimal to binary in java

    In this post, we will see how to convert decimal to binary in java. There are lot of ways to convert decimal to binary in java.Let’s explore them one by one. Using Integer.toBinaryString() method You can simply use inbuilt Integer.toBinaryString() method to convert a decimal [crayon-6103d1964b97d243919553/] Output: Binary representation of 12 : 1100 Binary representation […]

  • 18 April

    Minimum Number of Jumps to reach last Index

    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 Minimum Number of Jumps to reach last Index. Problem Given an array A of positive integers possibly zeroes, every index indicating the maximum length of a jump that can […]

  • FizzBuzz Java
    31 March

    FizzBuzz program in java

    In this post, we will see how to program FizzBuzz in java. Fizzbuzz is a fun game played generally by school children. It is simple game in which when your turn comes, you need to say the next number. So here are rules of the game: If number is divisible by 3, then you need […]

  • 10 March

    Print pyramid pattern: 1 3*2 4*5*6 pattern in java

    In this post, we will see how to print the following pyramid pattern. Problem Input : n = 4 Output : 1 3*2 4*5*6 10*9*8*7Input : n = 5 Output : 1 3*2 4*5*6 10*9*8*7 11*12*13*14*15 Solution If you notice the pattern we need to print odd rows in increasing order and even rows in […]

  • 20 February

    Inorder Successor in a Binary Search Tree

    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 Inorder Successor in a Binary Search Tree. Problem Given a Binary Search Tree and a target node value. Find the Inorder successor of the given node value in the […]

  • 04 February

    LCA of a K-ary Tree in O(Sqrt(height))

    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 how to find Lowest Common Ancestor of a K-ary Tree in O(Sqrt(height)).We have already seen how to find LCA of n-ary tree in O(n) complexity. Problem Given a K-ary tree and […]

  • 03 February

    Largest Rectangular Area in a Histogram

    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 how to find largest rectangular area in a Histogram. Problem Given an Integer representing number of bars in a Histogram and an array of integers representing the height of the bars […]

  • 20 November

    Serialize and Deserialize n-ary tree

    If you want to practice data structure and algorithm programs, you can go through Java coding interview questions. Problem Given a Generic Tree, Serialize and Deserialize it. Serialization is a basically a representation of a tree in a String format which takes much lesser space than storing the tree itself. Deserialization is constructing the actual tree […]

  • 12 November

    Segment Tree 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 Segment Tree in java. Problem Consider an Array of Integers, int[] arr = {a1, a2, a3, a4, a5,….., an}; Given two types of queries, (i) In the first type of query, […]