Developer Program Engineer Interview Questions
0of 0 votescode for MS Paint program. N*N pixels area. given pixel and color, change color in pixel to desired color and if adjacent pixels are of same color change them too. efficient algorithm with place and time complexity
0of 0 voteswrite a program to print the given string as alphabets in order next integres with sum next special characters
example: CAE2W3@D# as input and output should be
ACDEW5@#
0of 0 voteswrite a program to print checksum for given number
by taking last digit sapeate and if sum of squares of remaining numbers are equal to previous last number then print valid checksum else invalid
example: 321543 take 3 saperately and
let sum of squares be 3^2+2^2+1^2+5^2+4^2 == 3(last digit) then print valid checksum otherwise invalid
0of 0 votesThe root node in the tree is equal to sum of its all descendants and the leafs are assigned value 0, so if your tree is something like 10
20 30
40 50
output will be
140
0 90
0 0
0of 0 votesIn the page 90 of Gayle's cracking the coding interview book, there was a method defined which is used to get the bit at particular position. Method goes like this...
boolean getBit(int num, int i) {
return ((num&(1<<i))!=0);
}
Will this works..? if my number is 8 and I want to get the 3rd position, this return a wrong result
2of 2 votesone unsorted array is given.Find out the index i and j ,j> i for which a[j] - a[i] is maximum.perform in linear time complexity
0of 0 voteswrite algo for longest palindrome?
0of 0 votesA number is given asked to find the all combination with permutation from the digit which makes the sum equal to given number for example for number 4
1 1 1 1
1 1 2
1 2 1
2 1 1
2 2
1 3
3 1
if number is 5
then output should be
1 1 1 1 1
2 1 1 1
1 2 1 1
1 1 2 1
1 1 1 2
3 1 1
1 3 1
1 1 3
2 3
3 2
1 4
4 1
1 2 2
2 1 2
2 2 1
0of 0 votesSwap 2 variables without using a temporary variable
0of 0 votesThe columns that I get in a table after a clustering process is not specific but varies from 150 to 210. I need to get the column name that has the max value for each row and add that column name to a target column..
Schema looks like this
cluster_name ---> varchar(20)
col1 ----> decimal
col2 ----> decimal
...
coln ----> decimal
The result of the query should look like this
cluster_name -----> varchar(20)
col_name(that had the max value for that row)------> varchar(20)
col_max(max value across all columns for that row)-------->decimal
should use only mysql query..
0of 0 votesyou are given with N points on a graph and a point A and range R suggest an algo for finding the points that lies within distance R from A
0of 0 votesI want to design log in service for banking site.
Design consideration :
1. If User try 5 times wrong password than he should block for 1hr
2. User can try log in from different browser too
3. User can log in again with correct password after 1 hr if he lock on last attempt.
Solution consideration :
1. How to design the data structure for maintaining the user sign in
2. How to design thread or any service which can remove the user from data structure after 1 hr
0of 0 votesWhy linux is more stable than windows ?
0of 0 voteswhat are the stuffs a compiler provide to a class ?
0of 0 votesWrite a code snippet print a count no of characters in a number (string can't be used) ?
int count(int num)
{
//code should return no of digits
}
0of 0 votesWhat is the disadvantage of normalization ?
Why can't we follow normalization always ?
0of 0 votesWhat is critical section ?
0of 0 votesWrite an algorithm to avoid and detect deadlock in C++ ?
What is Banker's algorithm ?
0of 0 votesThere is a pool of memory with a specific address. How to make sure the object is always created in that part of memory ?
0of 0 votesHow to forbid the creation of object in
1>Stack
2>Heap
?
0of 0 votesHow to restrict a function so that in can't throw any kind of exception ?
How to restrict a function so that it can throw the exception of a particular type ?
0of 0 votesTest cases for chat application (lyk MSN ,YAHOO CHAT,GTALK etc).
0of 0 votesQuestion 3)
Given an crypted array obtain the original text . Should be implemented without extra space .
Eg: Crypt array : a3b4c3
decrypt array : aaabbbbccc
Imagine the array contains sufficient memory to hold the decrypt ?
0of 0 votesQuestion 2)
Given a binary tree which contains values at each node , find whether the path exist from root to the "LEAF NODE" such that sum of the values of d path nodes is equal to the GIVEN SUM. if so return true or else return false
0of 0 votesQuestion 1)
Eg:
Input linked list:
1->2->3->4->a->b->c->d->5->6->e->f
Output should be in below format :
1->a->2->b->3->c->4->d->5->e->6->f
0of 0 votesIn a university, students can enroll in different courses. A student may enroll for more than one course. Both students and courses can be identified by IDs given to them. Design a data structure to store students, courses, and the student-course relationships. You can use arrays, lists, stacks, trees, graphs, etc. or come up with your own data structures. Give the running times, in Big O notation, for the following operations for your data structure and justify the answers: a) Return all students in a list. b) Return all courses in a list. c) Return all courses in a list for a given student. d) Return all students in a list for a given course.
0of 0 votes]A shop sells an item in packets of 6, 9, and 17. A customer can buy any number of packets, but a packet cannot be broken up. Provide an efficient algorithm to solve the question "Can I buy N items?". For example, is it possible to buy 29 items? What about 19? Your algorithm simply needs to return true or false.
0of 0 votesWrite a function which traverse the whole tree and return the linked list of nodes.Your code should also be generic enough to work on any tree exp Binary tree, General tree etc.
0of 0 votesSuppose we have an array like
1,2,3,4,5,a,b,c,d,e where we have always even number of elements.First half of the elements
are integers and second half are alphabets we have to change it to like
1,a,2,b,3,c,4,d,5,e in place i.e no use of any extra space, variables are allowed ..
0of 0 votesIf have allocated an array of integers using new operator. How can the memory be freed using free(not delete) ?
If have allocated an array of integers using malloc(not new). How can the memory be freed using delete(not free) ?
