Jump Search Algorithm In Java

Jump search algorithm is a pretty new algorithm to search for an element in a sorted array. The idea of jump search is to skip the number of comparisons by jumping the indices by length m while performing the searching thus getting a better time complexity than linear search. For jump search m is determined…… Continue reading Jump Search Algorithm In Java

Leetcode Count Complete Tree Nodes Java Solution

Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.…… Continue reading Leetcode Count Complete Tree Nodes Java Solution

Leetcode 3 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. Example 1: Input: “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. Example 2: Input: “bbbbb” Output: 1 Explanation: The answer is “b”, with the length of 1. Example 3: Input: “pwwkew” Output: 3 Explanation: The answer is “wke”, with…… Continue reading Leetcode 3 Longest Substring Without Repeating Characters

Leetcode 2 Add Two Numbers Java Solution

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example: Input: (2 ->…… Continue reading Leetcode 2 Add Two Numbers Java Solution

Leetcode 23: Merge K Sorted Lists (Java)

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [   1->4->5,   1->3->4,   2->6 ] Output: 1->1->2->3->4->4->5->6 Solution: For this problem, the brute force solution would be passing all the lists and perform Merge Sort, but for the optimal solution we will use minHeap using…… Continue reading Leetcode 23: Merge K Sorted Lists (Java)

Arrays In Java With Example

The array is a data structure provided by Java which holds elements of the same data type with a fixed size.An array can hold elements/ values of the same data type, an example being we can create an array that can store 100 elements of type either int/String/char etc.. We can not have array hold…… Continue reading Arrays In Java With Example

Tracing With Spring Sleuth And Zipkin For Micro Services

As microservice architecture has become a standard for all the latest distributed systems, the tracing of the calls from one microservice to others has been a challenging thing for a while. To solve this Sprig Cloud introduced Spring Sleuth which borrows heavily from dapper. Spring sleuth adds traceID and spanID to the logs so it…… Continue reading Tracing With Spring Sleuth And Zipkin For Micro Services

Java ArrayList With Example

ArrayList is a resizable implementation of List interface, ArrayList can also be called as a dynamic Array. Like Array, ArrayList stores similar data type elements which can increase its size dynamically.ArrayList cannot store primitive data types like int and char, it can only store non-primitive data types like Integer, String, etc..The index of the ArrayList…… Continue reading Java ArrayList With Example

Netflix Eureka Server And Client Setup With Spring Boot

Overview We will set up a Eureka server (service registry used to register multiple services/microservices).We will set up multiple Eureka clients(REST services that register to Eureka Server).We will do client-side load balancing and service discovery through Eureka. Setting up Eureka Server The dependency required to set up a eureka server is “spring-cloud-starter-netflix-eureka-client” along with spring-boot-starter-parent.…… Continue reading Netflix Eureka Server And Client Setup With Spring Boot

Java Datatypes

What is a Datatype?A data type is an attribute of data that tells the compiler or interpreter how the programmer intends to use the data. Data types in Java programming language There are two different sets of data types in Java Primitive DatatypesNon Primitive Datatypes The below image depicts different data types in java Java…… Continue reading Java Datatypes

Published
Categorized as Java Tagged