Java Left Rotate Array K Times
Problem: Given array of size ‘n’ and left rotate k times Input : [1,2,3,4,5,6,7], K=3 Left Rotate 1: 2,3,4,5,6,7,1 Left Rotate 2: 3,4,5,6,7,1,2 Left Rotate 3: 4,5,6,7,1,2,3 Solution: Reverse the…
Problem: Given array of size ‘n’ and left rotate k times Input : [1,2,3,4,5,6,7], K=3 Left Rotate 1: 2,3,4,5,6,7,1 Left Rotate 2: 3,4,5,6,7,1,2 Left Rotate 3: 4,5,6,7,1,2,3 Solution: Reverse the…
In this post, we will see the java is pure functional programming language or not. Java is not a purely functional programming language support functional programming concepts with help of…
Comparable and Comparator are two Java interfaces that allow objects to be compared and sorted. Comparable Comparable is a functional interface that is implemented by a class to define its…
In this tutorial, we will learn about using comparators with Lamda. Comparators are extensively used in collections to sort objects link users, employees, orders etc. In Java 8, comparators can…
In this post, we will learn on java8 method referenced exampls: Method references in Java 8 are compact, easy-to-read lambda expressions which will refer to an existing method. They can…
In this post, we will see questions asked on String during java interview 1. Explain String pool in java? String Pool is java string literals pool that JVM maintains a…
In this post, we will learn various ways of converting input stream to String In this example, we will see that InputStream will be converted to String using java8 streams…
We can convert Java String to Input with below approaches: Example1: String str = "Hello World!"; InputStream inputStream = new ByteArrayInputStream(str.getBytes()); Example 2 with UTF8: javaCopy codeString str = "Hello…
In this tutorial, we will see concerting String[] to InputStream in the following ways:
In this, we will see java code to remove duplicates from linked list Java Code: class LinkedList { static class Node { int data; Node next; Node(int d) { data…