PuzzlersWorld.com

  • Hacker Puzzle
  • Interview Puzzles
  • Number Puzzles
  • Maths Puzzles
All Puzzles Solved Unsolved

Card Game solution: Facebook hacker cup 2013 Round1

February 4, 2013 by puzzler 1 Comment

From 2011 facebook is organizing a Facebook hacker cup every year around feb, visit Facebook hacker cup homepage for more details

This question is the first question(Carried 20 marks out of 100) for the Round 1 of 2013 hacker cup. only top 500 contestants will be moved to Round 2.

Problem Statement

John is playing a game with his friends. The game’s rules are as follows: There is deck of N cards from which each person is dealt a hand of K cards. Each card has an integer value representing its strength. A hand’s strength is determined by the value of the highest card in the hand. The person with the strongest hand wins the round. Bets are placed before each player reveals the strength of their hand.

John needs your help to decide when to bet. He decides he wants to bet when the strength of his hand is higher than the average hand strength. Hence John wants to calculate the average strength of ALL possible sets of hands. John is very good at division, but he needs your help in calculating the sum of the strengths of all possible hands.

Problem

You are given an array a with N ≤ 10 000 different integer numbers and a number, K, where 1 ≤ K ≤ N. For all possible subsets of a of size K find the sum of their maximal elements modulo 1 000 000 007.

Input

[Read more…]

Checkout more Interview Questions Tags: Facebook Hacker Cup, Interview, Java, Solved Puzzles

Find the Min solution: Facebook hacker Cup 2013 Qual Round

January 29, 2013 by puzzler 4 Comments

From 2011 facebook is organizing a Facebook hacker cup every year around feb, visit Facebook hacker cup homepage for more details

This question is the third question(Carried 45 marks out of 100) for the qualification round 2013 hacker cup.

Problem Statement

After sending smileys, John decided to play with arrays. Did you know that hackers enjoy playing with arrays? John has a zero-based index array, m, which contains n non-negative integers. However, only the first k values of the array are known to him, and he wants to figure out the rest.

John knows the following: for each index i, where k <= i < n, m[i] is the minimum non-negative integer which is *not* contained in the previous *k* values of m.
[Read more…]

Checkout more Interview Questions Tags: Facebook Hacker Cup, Interview, Java, Solved Puzzles, Very Difficult

Balanced Smileys solution: Facebook hacker Cup 2013 Qual Round

January 29, 2013 by puzzler 4 Comments

From 2011 facebook is organizing a Facebook hacker cup every year around feb, visit Facebook hacker cup homepage for more details

This question is the second question((Carried 35 marks out of 100) for the qualification round 2013 hacker cup.

Problem Statement

Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go 🙁

Sometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.

A message has balanced parentheses if it consists of one of the following:
[Read more…]

Checkout more Interview Questions Tags: Difficult, Interview, Java, Solved Puzzles

Beautiful Strings solution: Facebook hacker Cup 2013 Qual Round

January 29, 2013 by puzzler Leave a Comment

From 2011 facebook is organizing a Facebook hacker cup every year around feb, visit Facebook hacker cup homepage for more details

This question is the first question in the qualification round of 2013 hacker cup.

When John was a little kid he didn’t have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could… he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.

Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.

The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn’t care about whether letters are uppercase or lowercase, so that doesn’t affect the beauty of a letter. (Uppercase ‘F’ is exactly as beautiful as lowercase ‘f’, for example.)

You’re a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?

[Read more…]

Checkout more Interview Questions Tags: Easy, Interview, Java, Solved Puzzles

Find all non duplicate pairs that sum to S

January 25, 2013 by puzzler Leave a Comment

Find all non duplicate pairs that sum to S.

try to do it in O(nlogn).

Solution 1:
[Read more…]

Checkout more Interview Questions Tags: Algorithm, Difficult, Interview, Solved Puzzles

Subjective Question set C/C++ – Part 1

January 3, 2013 by puzzler Leave a Comment

Q1) int a[10[15];
char b[10[15];
What will be the location of a[3][4], if base location a[0][0] is ox1000?
What will be the location b[3][4], if base location b[0][0] is ox2000?

See AnswerHide Answer
(a) ox10C4 (b) ox2031
Let me know if you need the solution in detail.
Q2) How can the unary operator ++ be overloaded in C++ for postfix operation ?
[Read more…]

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Basic Concepts C/C++

December 24, 2012 by puzzler Leave a Comment

These are the few pointer i made while i myself was preparing for C/C++ interviews. You might want to get these facts right into your mind as well, beware you might be asked some question based on these facts in the interview.

Please do comment what you feel about these? Do you agree with these?
If you have some more pointers to share with puzzlersworld.com user’s, please don’t hesitate.

Some Facts on C/C++

  1. Functions defined in a class are by default inline.
  2. Memory space for the members of a class is allocated when an object of that class is created, not before that(at declaration of the class).
  3. Compiler provides a zero argument constructor only when there is no other constructor defined in the class.
  4. Realloc can be used to reallocate the memory allocated using new operator.
  5. Size of the pointer does not depend on where it is pointing to, it is always the same.
  6. Copy constructor and assignment operators are provided by default by the compiler.
  7. When an object is passed or returned to/from a function by value the copy constructor gets called automatically.
  8. For a template function to work it is mandatory that its definition should always be present in the same file from where it is called.
  9. All static data members are initialized to zero.
  10. For every static data member of a class it should also be defined outside the class to allocate the storage location.

Checkout more Interview Questions Tags: C/C++, Solved Puzzles

Objective Questions set C/C++ – Part 6

December 23, 2012 by puzzler Leave a Comment

11 Objective type interview questions on C/C++ with answers – Part 6

Before you start:-

  1. You can check your answer by filling a,b,c,d or e in the text box.
  2. You can get the answer by clicking Give Up Button.

Give your best shot before giving up 🙂

Q1) Max value of SIGNED int?
a. 2^31
b. 2^31 -1
c. 2^32
d. 2^32 -1

Tried enough already?

Q2) What does extern means in a function declaration?
[Read more…]

Checkout more Interview Questions Tags: C/C++, Interview, Solved Puzzles

Rotate an array by k elements

November 18, 2012 by puzzler Leave a Comment

Given an array of n elements, write an algorithm to rotate it right by k element without using any other array. In other words rotate an array in place.
you can have temp variable to swap two elements.
Ex:-
Initial Array: A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Rotating array A right by 3 elements should result in
A = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7}
Hint: There is a trick, think before doing much of the programming 🙂
See Solution: Rotate an array by k elementsHide Solution

So the trick is to reverse the whole array first then reverse the array from 0 to k-1 and k to n-1.
For example
Array A after reversing whole array: {10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
Array A after reversing 0 to 2 elements: {8, 9, 10, 7, 6, 5, 4, 3, 2, 1}
Array A after reversing 3 to 9 elements: {8, 9, 10, 1, 2, 3, 4, 5, 6, 7}
Code:

void rotateRight(int[] a, int k){
	int length = a.length();//in C/C++ it will be given as input
	reverse(a, 0, length -1);//reverse whole array
	reverse(a, 0, k-1);//assuming 0 < k < length
	reverse(1, k, n-1);
}
void reverse(int[] a, int start, int end){
	while(start < end){
		swap(a, start, end);
		start++;
		end--;
	}
}
void swap(int[] a, int pos1, int pos2){
	int temp = a[pos1];
	a[pos1]= a[pos2];
	a[pos2] = temp;
}
//Note: in interviews you might be asked to handle negative scenarios
// like array out of bound etc.

Checkout more Interview Questions Tags: Array, Difficult, Interview, Solved Puzzles

Reverse a link list without using another

November 12, 2012 by asinghal 2 Comments

How to reverse a link list without using another link list?

Note: Linked list is singly linked list (there is only next pointer no previous pointer).
See Solution: Reverse a link list without using another linked listHide Solution

Take two pointers previous and current, increment both pointers by one till current reaches at the end of the list.

Reverse a Linked List

Reverse a Linked List

Node* reverse(Node* node)
{
	if(node == null)
		return null;
	Node * prev = node;
	Node* curr = node->next;
	
	while(curr != null){
		Node* tmp = curr->next;
		curr->next = prev;
		prev = curr;
		curr = temp;
	}
	return prev;
}

Checkout more Interview Questions Tags: Interview, Linked List, medium, Solved Puzzles

  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • 5
  • Next Page »
Submit your Puzzle

You may also like

  • Objective Questions set C/C++ – Part 6
  • Find a pythagorean triplet from an array
  • Objective Questions set C/C++ – Part 2
  • Rotate an array by k elements
  • Minesweeper Master Solution – Google Code jam 2014
  • implement isPalindrome(int n)
  • Find all non duplicate pairs that sum to S
  • DS with insert, delete and getRandomElement in O(1)
  • Deceitful War Solution – Google Code Jam 2014
  • Full Binary Tree Solution – Google Code Jam

Categories

  • Aive hi Puzzles
  • Akbar and Birbal
  • Alphabetical Puzzles
  • Bollywood Puzzles
  • Google Code jam
  • Hindi Riddles
  • Interview Puzzles
  • Interview Questions
  • Logical Puzzles
  • Malayalam Puzzles
  • Maths Puzzles
  • Miscellaneous
  • Number Puzzles
  • Picture Puzzles
  • Riddles
  • Tamil Puzzles
  • Technical

Social

  • View puzzlersworld’s profile on Twitter
privacy policy

Copyright © 2025 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in

  • Hacker Puzzle
  • Logo Puzzles
  • Optical Illusions
  • WhatsApp Puzzles
  • Picture Puzzles
  • Riddles
    ▼
    • Hindi Riddles
  • Bollywood Puzzles
  • Alphabetical Puzzles
  • Aive hi Puzzles
  • Interview Puzzles
  • Logical Puzzles
  • Interview Questions
    ▼
    • Data Structures
    • Binary Tree
    • Algorithms
    • Recursion Questions
    • Amazon Interview Questions
    • Snapdeal Interview Questions
    • Google Code jam
  • Technical
  • Akbar and Birbal
  • Number Puzzles
  • Maths Puzzles
  • Miscellaneous