Applications Developer Interview Questions
- 0of 0 votes
Answersgiven a string, characters can be shuffled to make a paliandrome.
What is the minimum possible number of insertions to original string needed so that it will be a palindrome (after shuffling, if required).Input
T -> number of test cases
T number of Strings in different linesimport java.util.Arrays; import java.io.InputStreamReader; import java.io.BufferedReader; public class Xsquare{ public static void main (String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int limit = Integer.parseInt(br.readLine()); int [] alphabets = new int[26]; while(limit-- >0){ String input = br.readLine(); Arrays.fill(alphabets,0); char [] inpChar = input.toCharArray(); int sum = 0; for (int i=0;i<input.length();i++){ int pos = (int)inpChar[i] - (int)'a'; alphabets[pos]+=1; } for(int i=0;i<26;i++){ if(alphabets[i]%2==0) sum+=0; else sum+=1; } if(sum<=0) sum=0; else sum-=1; System.out.println(sum); } } }
This is the code I submitted online. But it was not accepted as solution. What is the correct approach to this question?
- Kiran Vadakath April 21, 2015 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Coding - 0of 0 votes
AnswersI have an two arrays int[] 1 = {2,5,8,9}; and int[] 2={6,3,4,7,1};
- navishsahu April 03, 2015 in India for 5
I need to merge this two array in third array int[] 3 = new int[1.Length + 2.Length]; and give the output in sorted form.
Also I need to provide and optimized code with minimal complexity...
Output: {1,2,3,4,5,6,7,8,9}
Plz Help...| Report Duplicate | Flag | PURGE
xyz Applications Developer Arrays - 0of 0 votes
AnswersMark likes to listen to music while travelling. His iPod™ contains N songs and he wants to listen to L (not necessarily different) songs during a trip. So he creates a playlist such that:
- rashmishrikant.patil February 06, 2015 in India
• Every song is played at least once.
• A song can be played again only if at least K other songs have been played
Mark wants to know how many different playlists are possible. Can you help Mark determine this number? As the number can be very large, display number modulo 1,000,000,007.
You are given N, K and L.| Report Duplicate | Flag | PURGE
Oracle Applications Developer Algorithm - 0of 0 votes
AnswersFirst they did ask to find pattern of this
'this is a test sentence' => [t, h, i, s, i, s, a, t, e, s, t, s, e, n, t, e, n, c, e] 'thiis iss a teest seentennce' => [i, s, e, e, n] 'thiiis iss aa teeest seentennnce' => [i, e, n] 'thiiiis iss a teeest seeentennncccce' => [i, c]
after i have to do body of function
- milan.medlik January 31, 2015 in United StatesgetLongestConsecutiveChar
| Report Duplicate | Flag | PURGE
Facebook Applications Developer Algorithm - 0of 0 votes
AnswersWe have a Very big which our datatypes does not provide.
- Vanquisher January 10, 2015 in India
We need to multiply such numbers, how to do?
example :
Num1 = {1,2}, Num2 = {1,0} then ans would be {1,2,0}
Num1 ={5,3,6,2,8,2,0,2,8}, num2 ={3,5,2,3,2,1,}
then ans would be the multiplication value of 5362882028 X 352321| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer Algorithm - 0of 0 votes
AnswersGood day I just got a question which is the following
- answer seeker January 07, 2015 in United States
you have an vector like this
[JFK, LXA, SNA, RKJ, LXA, SNA]
each 2 group define a route. so,
JFK -> LXA
SNA -> RKJ
LXA -> SNA
Find the path from departure to destination. note: departure and destination are not known.
The final destination should be
JFK-> LXA -> SNA -> RKJ
The function signature is something like this
vector<string> findPath(vector<string> airports)
{
}
The airports (nodes) cannot be duplicated and the path should print all the airports (nodes)| Report Duplicate | Flag | PURGE
Bloomberg LP Applications Developer Algorithm - 0of 0 votes
AnswersGood day I just got a question which is the following
- answer seeker January 07, 2015 in United States
you have an vector like this
[JFK, LXA, SNA, RKJ, LXA, SNA]
each 2 group define a route. so,
JFK -> LXA
SNA -> RKJ
LXA -> SNA
Find the path from departure to destination. note: departure and destination are not known.
The final destination should be
JFK-> LXA -> SNA -> RKJ
The function signature is something like this
vector<string> findPath(vector<string> airports)
{
}
The needed the full path from departure to destination, and you can only pass by one point only once.
Thanks!| Report Duplicate | Flag | PURGE
Bloomberg LP Applications Developer Algorithm - 0of 0 votes
AnswersGiven a binary search tree and a number n, write a program to find the greatest number in the binary search tree less than or equal to N.
- gowthamiss27 December 21, 2014 in India
Given the following tree construction, what is the output for N=44?| Report Duplicate | Flag | PURGE
abc Applications Developer Online Test - 0of 0 votes
AnswersA credit card company allows merchants to use their Point-of-sale (POS) terminal to accept payments. It wishes to charge merchants for every transaction that happens through thier POS terminal. Here are some charging rules that it has come up with:
- tarunverma December 14, 2014 in India for Java Development
Transactions are charged 2.0% of transaction amount if amount is less than 5000.00
Transactions are charged 1.5% of transaction amount if amount is between 5000.00 and 9999.99 (both inclusive)
Transactions are charged 1.0% of transaction amount if amount is equal to or above 10000.00
If merchant has already done transactions worth 50000.00 in a month, then rest of transactions of that month are charged at 0.5%
Every Month - two transactions of amount less than or equal to Rs. 5000.00 are free
Charges are rounded to nearest higher Rupee (Eg: 9.23 is rounded to 10.00)
Please develop a program to compute the charges for given inputs.
Your input will be in the following format. First Line: number of records follows, say N Next N Lines - Transaction data in the order - Transaction Date, Merchant Name, Amount
15
2014-06-25,XYZ Retail,10000.00
2014-07-01,XYZ Retail,10000.00
2014-07-01,ABC Retail,1000.00
2014-07-02,ABC Retail,3999.00
2014-07-02,ABC Retail,2000.00
2014-07-03,ABC Retail,10000.00
2014-07-15,ABC Retail,6530.00
2014-07-15,XYZ Retail,500.00
2014-07-18,ABC Retail,9750.00
2014-07-18,XYZ Retail,35000.00
2014-07-18,XYZ Retail,500.00
2014-07-18,XYZ Retail,5000.00
2014-07-18,XYZ Retail,5000.00
2014-08-02,XYZ Retail,10000.00
2014-08-02,XYZ Retail,1000.00
Transactions must be read and processed in the order given, else output will not match. Do not try to sort the transactions.
Output (Charges for each transaction on separate line)
100.00
100.00
0.00
0.00
40.00
100.00
98.00
0.00
147.00
350.00
0.00
75.00
25.00
100.00
0.00
Sample Input (Plaintext Link)
15
2014-06-25,XYZ Retail,10000.00
2014-07-01,XYZ Retail,10000.00
2014-07-01,ABC Retail,1000.00
2014-07-02,ABC Retail,3999.00
2014-07-02,ABC Retail,2000.00
2014-07-03,ABC Retail,10000.00
2014-07-15,ABC Retail,6530.00
2014-07-15,XYZ Retail,500.00
2014-07-18,ABC Retail,9750.00
2014-07-18,XYZ Retail,35000.00
2014-07-18,XYZ Retail,500.00
2014-07-18,XYZ Retail,5000.00
2014-07-18,XYZ Retail,5000.00
2014-08-02,XYZ Retail,10000.00
2014-08-02,XYZ Retail,1000.00
Sample Output (Plaintext Link)
100.00
100.00
0.00
0.00
40.00
100.00
98.00
0.00
147.00
350.00
0.00
75.00
25.00
100.00
0.00
Explanation
100.00 // Rule 3 applied
100.00 // Rule 3 applied
0.00 // Rule 5 applied (ABC Retail) for the month of July
0.00 // Rule 5 applied (ABC Retail) for the month of July
40.00 //Rule 1 & 6 applied
100.00 // Rule 3 applied
98.00 // Rule 2 & 6 applied
0.00 // Rule 5 applied (XYZ Retail) for the month of July
147.00 // Rule 2 & 6 applied
350.00 //Rule 3 applied
0.00 // Rule 5 applied (XYZ Retail) for the month of July
75.00 // Rule 2 applied
25.00 // Rule 4 applied
100.00 // Rule 3 applied
0.00 // Rule 5 applied (XYZ retail) - for the month of Augus| Report Duplicate | Flag | PURGE
Accenture Applications Developer - 0of 0 votes
Answerspublic class Base Test {
- lucky December 11, 2014 in India
protected void finalize() {
System.out.println("Destroying Base");
}
}
public class DerivedTest extends Base Test{
protected void finalize() {
System.out.println("Destroying Derived");
}
}
What is output when an instance of DerivedTest is finalized?| Report Duplicate | Flag | PURGE
Accenture Applications Developer - 1of 1 vote
AnswersYou have a class that many libraries depend on. You need to modify the class for one application. Which of the following changes require recompiling all libraries before it is safe to build the application?
- manojkumar16 December 04, 2014 in India
a. add a constructor
b. add a data member
c. change destructor into virtual
d. add an argument with default value to an existing member function| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Java - -1of 1 vote
AnswersDo thread join without join function?
- manojkumar16 December 04, 2014 in India| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Java - 0of 0 votes
AnswersGiven a BST, how would you return the kth smallest element. Cover all the corner cases with time complexity logn
- manojkumar16 December 04, 2014 in India| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Algorithm - 0of 0 votes
AnswersWrite a program that reverses alternate elements in a given linked list input: a->b->c->d, output should be b->a->d->c
- manojkumar16 December 04, 2014 in India| Report Duplicate | Flag | PURGE
Walmart Labs Applications Developer Algorithm - 0of 0 votes
AnswersYou are given the toplogical information of a terrain in the following format - There are n points ( x_i , y_i ) and for each point (x_i , y_i ) the altitude h_i is given.
- harshit.knit November 12, 2014 in United States
For any rectangle (axis parallel) defined by the x-y coordinates of
the corner points, we must answer the query about which is the highest altitude point lying within the rectangle.
Implement this using a range-query data-structure that answers such a
query in O( log^2 n) time| Report Duplicate | Flag | PURGE
Google Applications Developer Algorithm - 1of 1 vote
AnswerFind Maximum sum subarray such that no elemnt in subarray is repeated
- harshit.knit November 06, 2014 in United States
https://www.facebook.com/photo.php?fbid=10152820917104183&set=pcb.1523587287892659&type=1&theater| Report Duplicate | Flag | PURGE
Medio Systems Applications Developer Algorithm - 1of 1 vote
AnswersThe Question is to find 4 numbers between 1 and 40, so that you can get all the numbers between 1 to 40 by doing either of operation below.
- amitsahu78 October 01, 2014 in India
1) Either any of the four number itself.
2) creating an expression by combining among the four number, with either addition or subtraction.
For example suppose we have to find four numbers so that we can get numbers between 1-30.
The answer to above question is 1,3,6,20.| Report Duplicate | Flag | PURGE
Atmel Applications Developer Brain Teasers - 0of 0 votes
AnswersTo schedule a job which will run in weekdays between 3pm to 5pm , in a interval of 15min.
- sunpratikkumar2 August 18, 2014 in India
(its for oracle 10g so it doesn't support schedular
** without using repeat_interval.)| Report Duplicate | Flag | PURGE
omega Applications Developer SQL - 2of 2 votes
AnswersProblem Statement
- suresh August 02, 2014 in India
You have two strings A and B. Each one contains some letters and exactly one asterisk.
You have to replace the asterisk in each string with a letter sequence (possibly of zero length) so that the resulting two
strings are equal. This equal string is what you have to return. Attempt to return the shortest possible string.
The letter sequences may be same or different.
If it is not possible to make the given strings equal, return the string "not-possible".
Additional Constraints
- A and B will contain only uppercase letters and asterisks.
- A and B will contain one asterisk each.
Examples
0)
"SOCIA*TWIST"
"SOCIALTWI*T"
Returns: "SOCIALTWIST"
1)
"HELLO*"
"HI*"
Returns: "not-possible"
2)
"PROFESS*"
"*PROFESS"
Returns: "PROFESS"
3)
"*EXAMPLETEST"
"THIRDEXAMPLE*"
Returns: "THIRDEXAMPLETEST"
4)
"*TELL"
"*AFRIEND"
Returns: "not-possible"
5)
"*"
"B*"
Returns: "B"
6)
"*C"
"D*"
Returns: "DC"
program should be written in java| Report Duplicate | Flag | PURGE
A9 Applications Developer Algorithm - 0of 0 votes
AnswersWhat is difference between critical section and mutex.??
- Kavita July 13, 2014 in India
Can we use mutex across the process??| Report Duplicate | Flag | PURGE
Aricent Applications Developer - 0of 2 votes
Answershi guys ..hows the adobe recuitment first round will be like
- Ankit July 02, 2014 in India| Report Duplicate | Flag | PURGE
Adobe Applications Developer - 11of 11 votes
AnswersGiven an unsorted array of integers, you need to return maximum possible n such that the array consists at least n values greater than or equals to n. Array can contain duplicate values.
- abc June 20, 2014 in India
Sample input : [1, 2, 3, 4] -- output : 2
Sample input : [900, 2, 901, 3, 1000] -- output: 3| Report Duplicate | Flag | PURGE
Google Applications Developer - 1of 1 vote
AnswersTraveler wants to travel from city “A” to city “D”.
There is a path from city “A” to city “D”.
Path consists of steps, i.e. travel from city “A” to city “B”.
Path is encoded as sequence of steps.
Sequence is in incorrect order.
Your task is to restore order of steps in the path.
Input (unordered sequence):
C -> D
A -> B
B -> C
Output (Correctly ordered list which represents path):
A, B, C, D
Implement following API:
- abc June 20, 2014 in Indiaclass Step { String start; String finish; }; class Node { String value; Node next; } List<String> findPath(List<Step> steps) { }
| Report Duplicate | Flag | PURGE
Google Applications Developer Algorithm - 10of 10 votes
AnswersGiven a Binary Search tree of integers, you need to return the number of nodes having values between two given integers. You can assume that you already have some extra information at each node (number of children in left and right subtrees !!).
- abc June 19, 2014 in India| Report Duplicate | Flag | PURGE
Google Applications Developer Algorithm - 2of 2 votes
AnswersYou are given information about hotels in a country/city. X and Y coordinates of each hotel are known. You need to suggest the list of nearest hotels to a user who is querying from a particular point (X and Y coordinates of the user are given). Distance is calculated as the straight line distance between the user and the hotel coordinates.
- abc June 19, 2014 in India| Report Duplicate | Flag | PURGE
Google Applications Developer Algorithm - 0of 0 votes
Answersroot, directory, 128, admin, NONE
- vijayinani May 01, 2014 in India for Java
users, directory, 512, admin, root
santana, directory, 1024, santana, users
santana.jpg, photo, 128000, santana, santana
Project.doc, document, 256000, santana, santana
Incredibles.mpg, movie, 4123456123, santana, santana
marcus, directory, 128, marcus, users
Resume.doc, document, 256000, marcus, marcus
This contains information about files stored in a file system. Each line corresponds to one file, and the fields are separated by commas. The first field contains the filename, the second contains the file type, the third field is the size of the file in bytes, the fourth field is the username of the owner of the file, and the last field is the name of the parent directory of this file (i.e. the name of the directory in which this file is located.) Note: the special parent directory name NONE indicates that this file is the root directory of the filesystem. Also, for the purposes of this program, assume that all file/directory names are unique in the system.
write a Java program which reads data in this format from a file, parses it, and figures out the total size of storage consumed by each directory in this system. The size of storage consumed by any directory is defined as the sum of the size of this directory, sizes of all the files in this directory and the total storage sizes consumed by all the directories in this directory. Your program should write the name of each directory, and the total storage consumed by it. The output should have one directory per line, and the format should be dirname: size.
Output should be:
santana: 4123841147
marcus: 256128
root: 4124097915
users: 4124097787
Provide the best algorithm and java program.| Report Duplicate | Flag | PURGE
Wipro Technologies Applications Developer Algorithm - -6of 6 votes
Answers3, 5, 7, 9, 11, 13. Which is least like others?
- shiyin88 April 18, 2014 in United States| Report Duplicate | Flag | PURGE
Epic Systems Applications Developer - 1of 3 votes
AnswersGiven a number N, find the smallest even number E such that E > N and digits in N and E are same.
- jerinsebastian.punnamada April 08, 2014 in United States
Print NONE otherwise.
Sample:
Input
N = 34722641
Output
E = 34724126
Input
N = 8234961
Output
E = 8236194 (instead of 8236149)
Java solution| Report Duplicate | Flag | PURGE
Yahoo Applications Developer Algorithm Java - 1of 1 vote
AnswersGiven two words, determine if the first word, or any anagram of it, appears in consecutive characters of the second word. For instance, tea appears as an anagram in the last three letters of slate, but let does not appear as an anagram in actor even though all the letters of let appear in slate.
- jerinsebastian.punnamada April 08, 2014 in United States
Return the anagram of the first word that has appeared in the second word.
Sample Input 1
tea
slate
Sample Output1
ate
Sample Input 2
let
slate
Sample Output2
NONE
java solution| Report Duplicate | Flag | PURGE
Yahoo Applications Developer Algorithm Java - 1of 1 vote
AnswersGiven a string, complete the given function to recursively remove the adjacent duplicate characters and return the resultant string. If there are no characters left in the resultant string, return "-1" (without quotes).
- jerinsebastian.punnamada April 08, 2014 in United States
Sample Test Cases
Sample Input: ABCCBCBA
Output: ACBA
Explanation: (ABCCBCBA --> ABBCBA --> ACBA)
Sample Input: AA
Sample Output: -1
Java solution| Report Duplicate | Flag | PURGE
Yahoo Applications Developer Algorithm Java