What is Hashing? Hashing is a mechanism to convert one value to another. The process which performs this transformation is called the ‘Hash Function’. The input to the hash function is normally called as the ‘Key’ and this could be any value which can be converted to a String. The output or the hashed value […]

# Category: Java interview questions

## Introduction to Design Patterns

What are Design Patterns? What is a Pattern? Patterns exist everywhere in the world. In culinary, art, medicine, law, mathematics, music, dancing and the list goes on. Genrally, a pattern is identified as a recurring arrangement created to solve some generalized problem. It is simply a solution outline. That solution outline can be used over and over […]

## Strategy Design Pattern

Do you Know The Strategy Design Pattern? What is Strategy Design Pattern? Do you use Strategies? We all have dealt with strategies in certain moments of our life. In more technical words strategy is a set of planned actions designed to achieve a specific goal. Simply, you try out many strategies when a final exam […]

## Java Regular Expression Interview Questions

In this article, we would be going through the mostly asked Java Regular expression interview questions and answers. Even if you are not a great fan of interview questions, this post may offer you some interesting excercises on Regular Expressions. Java Regular Expression Interview Questions and Answers What are the classes in Java that helps to […]

## Java Collection Interview Questions and Answer

Here is a list of Java Collections interview Questions. These are some of the famous questions asked in interviews. Java Collections Interview Questions What is rehashing? When is it done? In the case of a HashMap, there are two important member fields which determine when exactly the resizing of the map needs to be done. […]

## Why is String immutable in java?

This question has been asked in a number of interviews in the past and is still being asked. If you search google for this question you will find people trying to answer this question. But no one has been able to answer it properly and no one except the Java designers can really answer. We […]

## Predict the Winner -Leetcode

Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available for the next player. This continues until all […]

## Leetcode – Zuma Game

Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls in your hand. Each time, you may choose a ball in your hand, and insert it into the row (including the leftmost place and rightmost place). Then, if there is […]

## Number Complement – Leetcode

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation. Example 1:

1 2 3 |
Input: 5 Output: 2 Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2. |

Example 2:

1 2 3 |
Input: 1 Output: 0 Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0. |

[…]

## Max Consecutive Ones – Leetcode

Given a binary array, find the maximum number of consecutive 1s in this array. Example 1:

1 2 3 4 |
Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3. |

Note: The input array will only contain 0 and 1. The length of input array is a positive integer and will not exceed 10,000 Solution This is an easy to solve problem. We keep on counting the ones till a […]