Java

Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

Spring Logo

Spring Framework

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Hibernate Logo

Hibernate Framework

Hibernate ORM is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database.

Showing posts with label puzzles. Show all posts
Showing posts with label puzzles. Show all posts

Sunday, July 14, 2013

Write a Program to find the longest palindrome in a given String

Write a Program to find the longest palindrome in a given String

Program:
Output:
String: HYTBCABADEFGHABCDEDCBAGHTFYW12345678987654321ZWETYGDE
Longest Palindrome: 12345678987654321

Saturday, July 13, 2013

If given a 15 digit number whats the best way to find the next palindrome?

If given a 15 digit number what is the best way to find the next palindrome? for example what will be the next palindrome of: 134567329807541?

Algorithm:

Step1: Split the number into three parts, head, mid, tail

number = 134567329807541
count = no. of characters = 15
head = number.substring(0, count / 2) = number.substring(0,7) = 1345673
mid = number.substring((count / 2), (count / 2) + 1) = number.substring(7,8) = 2
tail = number.substring((count / 2) + 1) = number.substring(8) = 9807541

head   mid        tail
1345673     2                   9807541
Step2: Reverse head and compare it to tail 3765431
  • If reverse(head) <= tail ( if they are equal the initial input is a palindrome, and you want the next )
    • If mid < 9, increment mid
    • Else increment head part and set mid := 0
     
reverseHead = rev(head) = 3765431
if(reverseHead == tail) {
           if (m <= 9) {
                m++;
            } else {
                m = 0;
                h = h + 1;
            }
}

Step3: Result is head mid reverse(head). 
result = head + mid + rev(head)
           = 1345673+ 3 + reverseHead 
           = 134567333765431

Friday, September 14, 2012

Difficult Questions And Intelligent Answers for Interview

Difficult Questions and Intelligent Answers for Interview: 

1. How can you drop a raw egg onto a concrete floor without cracking it?
Ans. Concrete floors are very hard to crack! (UPSC Topper)

2. If it took eight men ten hours to build a wall, how long would it take four men to build it?
Ans. No time at all it is already built. (UPSC 23 Rank Opted for IFS)

3. If you had three apples and four oranges in one hand and four apples and three oranges in the other hand, what would you have?
Ans. Very large hands..(Good one) (UPSC 11 Rank Opted for IPS)

4. How can you lift an elephant with one hand?
Ans. It is not a problem, since you will never find! an elephant with one hand. (UPSC Rank 14 Opted for IES)

5. How can a man go eight days without sleep?
Ans. No Probs, He sleeps at night. (UPSC IAS Rank 98)

6. If you throw a red stone into the blue sea what it will become?
Ans. It will Wet or Sink as simple as that. (UPSC IAS Rank 2)

7. What looks like half apple?
Ans. The other half. (UPSC - IAS Topper)

8. What can you never eat for breakfast?
Ans. Dinner.

9. What happened when wheel was invented?
Ans. It caused a revolution.

10. Bay of Bengal is in which state?
Ans. Liquid (UPSC 33Rank)

11. How many buckets of water do Pacific Ocean contains?
Ans. It depends on the size of the bucket. (CA Institute Campus Interview Placement)

12. Interviewer said 'I shall either ask you ten easy questions or one really difficult question. Think well before you make up your mind!' The boy thought for a while and said, 'my choice is one really difficult question. ''Well, good luck to you, you have made your own choice! Now tell me this. 'What comes first, Day or Night?'
Ans. The boy was jolted into reality as his admission depends on his answer, but he thought for a while and said, 'It's the DAY sir!'
'How' the interviewer asked,
'Sorry sir, you promised me that you will not ask me a SECOND difficult question!'
He was selected for IIM!

Monday, November 21, 2011

IAS Puzzale

Only 2% students solved this in IAS exam.

5+3+2=151022
9+2+4=183652
8+6+3=482466
5+4+5=202541
then
7+2+5= ____?

Try it.

Ans: 143547

Solution:
Multiply First*Second You Will Get First two digit ans
First*Third  you will get next two digit number
First*Second value add with First*Third then subtract with Second Value finally u get last 2 digits

5*3 5*2 (5*3+5*2-3)=15 10 25-3 = 151022
9*2 9*4 9*2 +9*4 - 2= 18 36 54-2 = 183652
.................... 
7*2=14
7*5=35
14+35-2 = 49-2 = 47