Skiing on Mountains Matrix : “John Snow” likes Skiing on Mountains a lot.That’s not very surprising, since skiing is really great. The problem with skiing is one have to slide downwards to gain speed. Also when reached the bottom most point one has to wait for ski-lift to get to higher altitude.

“John Snow” seeks your help to know the longest run possible with the given peaks, As (“John Snow knows nothing” ), That altitude of different peaks is given by a grid of numbers. Look at this example Skiing on Mountains Matrix Path: [Read more…]

## The greedy coins game Dynamic Programming

The greedy coins game Dynamic Programming Solution :

Question statement There is a row of 2n coins on the table; each coin can have any positive integer value. Two players alternate turns.

On a player’s turn he/she must take one of the two coins on either END of the row of remaining coins, so with each turn the row gets shorter by one.

After all the coins have been taken, the player with the higher total value is the winner.

Decide Strategy and Determine the maximum possible amount of money we can definitely win if we move first. [Read more…]

## Handle duplicates in Binary Search Tree

In a Binary Search Tree (BST), all keys in left subtree of a key must be smaller and all keys in right subtree must be greater. So a Binary Search Tree by definition has distinct keys and duplicates in binary search tree are not allowed.

How to allow duplicates where every insertion inserts one more key with a value and every deletion deletes one occurrence?

A **Simple Solution** is to allow same keys with count. For example consider insertion of keys 3, 6, 7, 8, 8, 8, 10, 12, 12 in an empty Binary Search Tree [Read more…]

## Minimum insertions to form a palindrome

Given a string, find the minimum number of characters to be inserted to form Palindrome string out of given string

Before we go further, let us understand with few examples:

ab: Number of insertions required is 1. **b**ab

aa: Number of insertions required is 0. aa

[Read more…]

## Binary Tree Isomorphic to each other

Find weather two given trees are isomorphic to each other or not.

Lets understand What is isomorphic strings

AAB and XXY are IsoMorphic to each other, consider A replaces/morphs as X and B as Y, then both strings are isomorphic.

ABC and XXY are not IsoMorphic.

[Read more…]

## Naurki.com Security Breach

## Naukri.com Security Bug found

Hi Folks, Today I am going to show and explain Security bug of Naukri.com from Mails, Being a Backend Coder and with knowledge of SQL injection and security breach issues, I came to know about Bug in Naukri.com’s security that without login,you can access your or your Friend’s profile, if he has sent you Mail of Naukri.com’s Job Opening Mail.

This issue I found out because, I have forwarded mail to few of my colleague as I was not looking out for job change.

One of my colleague got the job opening mail which I have forwarded to him, to update his profile he has clicked on “Update now”, And profile which was opened was mine, without seeing that, he has updated his CV into my Profile.

And due to that I have started getting Calls of HRs that weather I am looking for job change or not. When I refused to some HRs, One of HR said that why I have updated profile, if I am not looking out and even some HRs claimed that CV in my naukri profile is of some other person from my company.

So I understood that there should be fussy about the mails which I am forwarding to my friends/colleagues to help them getting job. After investigation of mail template of Naukri.com and “Update Now” Button’s url I came to know that this security glitch or security breach is present.

You help a colleague/friend and if your colleague/friend can access your profile, along with email/phone he can see your Salary information which is highly confidential.

Stay Safe.

*PS : I have showed this step and performed this steps for spreading awareness and not to malign Naukri.com, I highly respect Sanjeev Bikhchandani (CEO of Naukri) I sincerely request Naukri.com to act upon their security breach. And If they find this search useful, they can reward me ;)

## Maximum occurred Smallest integer in n ranges

### Maximum occurred integer in n ranges

Given n ranges in the form of Start Number and End Number in Two Array L and R such that

L[i]-R[i] is one range given. Our task is to find the maximum occurred smallest (first) integer in all the ranges. Means If more than one integer occurs max times, print the smallest one.

In other you can find similar code in

**Time Complexity**: O(n + MAX) and **Space Complexity : **O(Max)

We have tried to reduce complexity to O(n+m), space complexity : O(m) where m is largest integer in L or R

means m is largest range number.

## Best Java Book | Top Java Programming Book for Beginners

Being certified Java programmer SE 7, Enterprise Edition ( EE ) Application, etc. from Oracle & ex-Developer at Oracle, I can refer some of the * best java books* for learning.

Why Java? Java is most used language across many Multi National Companies like Amazon, Walmart, Goldman Sachs, Google, etc. for their coding because of its many features. Java is best for great architecture as it is easy to scale, multi-threading support, secure, robust and most important:** Java is easy to learn. **

It also provides the foundation for many languages and platforms such as Android, Groovy. So It becomes the most important language to learn.

Without wasting much of your time, let’s go through some of the *best programming books for Java* and grab the one which suits you.

Publisher | Title of Java Book | Pages in the book | Year | Price Range |
---|---|---|---|---|

O'Reilly Media | Head First Java, 2nd Edition | 688 | 2005 | Check Price |

Amazon Digital Services | JAVA: A Beginner to Expert Guide to Learning the Basics of Java Programming | 162 | 2016 | Check Price |

McGraw-Hill Education | Java: The Complete Reference, Ninth Edition | 1312 | 2014 | Check Price |

Prentice Hall | Thinking in Java (4th Edition) | 1150 | 2006 | Check Price |

Pearson | Java: An Introduction to Problem Solving and Programming (7th Edition) | 1024 | 2014 | Check Price |

CreateSpace Independent Publishing Platform | Data Structures and Algorithms Made Easy in Java: Data Structure and Algorithmic Puzzles, Second Edition | 450 | 2011 | Check Price |

Pearson | Building Java Programs: A Back to Basics Approach (4th Edition) | 1224 | 2016 | Check Price |

Addison-Wesley | Effective Java (2nd Edition) | 346 | 2008 | Check Price |

Pearson | Starting Out with Java: From Control Structures through Objects (6th Edition) | 1224 | 2015 | Check Price |

Pearson | Java How To Program (Early Objects) (10th Edition) | 1248 | 2014 | Check Price |

Prentice Hall | Core Java Volume I--Fundamentals (9th Edition) (Core Series) | 1008 | 2012 | Check Price |

Addison-Wesley Professional | Java Concurrency in Practice | 384 | 2006 | Check Price |

Some Other Recommendation for You

Here is the list of best Java Books which explains all stages of Java learning with their pros and cons.

[Read more…]

## Right view of Binary tree

We are given a Binary Tree, Print the Right view of Binary tree,

Right view of binary tree is : List of all nodes which are visible If you look at Binary tree from right side.

For example,

Right view of following tree is a, c, g, h a / \ b c / \ / \ d e f g \ h

Hint for logic : [Read more…]

## Find Nearest Minimum number in left side in O(n)

Given an array of integers, find the nearest smaller number for every element such that the smaller element is on left side.

Examples:

Input: arr[] = {1, 6, 4, 10, 2, 5} Output: {-1, 1, 1, 4, 1, 2} First element ('1') has no element on left side. For 6, there is only one smaller element on left side '1'. For 10, there are three smaller elements on left side (1, 6 and 4), nearest among the three elements is 4. Input: arr[] = {1, 3, 0, 2, 5} Output: {-1,1,-1, 0, 2}

- 1
- 2
- 3
- …
- 12
- Next Page »