McAfee 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
AnswersList of all the test cases for the following program
- helphand2015 January 22, 2015 in India
read p
read q
if p+q >100
pring large
end if
if p>50
print "p is larger"
end if| Report Duplicate | Flag | PURGE
McAfee SDET Testing - 0of 0 votes
AnswersOSI layers
- helphand2015 January 22, 2015 in India| Report Duplicate | Flag | PURGE
McAfee SDET Network - 0of 0 votes
AnswerDiff between tcp and udp
- helphand2015 January 22, 2015 in India| Report Duplicate | Flag | PURGE
McAfee SDET Network - 0of 0 votes
AnswersLife cycle of bug, test severity and priority
- helphand2015 January 22, 2015 in India| Report Duplicate | Flag | PURGE
McAfee SDET Testing - 0of 0 votes
Answersshell script to rename all files in directory
- helphand2015 January 22, 2015 in India| Report Duplicate | Flag | PURGE
McAfee SDET Unix - 0of 0 votes
Answersfind if linked list is palindrome
- helphand2015 January 22, 2015 in India
a -> b-> Null| Report Duplicate | Flag | PURGE
McAfee SDET Stacks - 0of 0 votes
AnswersImplement 2 stacks in a single array
- helphand2015 January 22, 2015 in India| Report Duplicate | Flag | PURGE
McAfee SDET Arrays - 0of 0 votes
AnswersProgram to get current %CPU and %MEM
- helphand2015 January 22, 2015 in India| Report Duplicate | Flag | PURGE
McAfee SDET Algorithm - 1of 1 vote
AnswersInput will be a matrix consiting of only 1's n 0's.
- im.akki90 April 21, 2014 in India
The 1's represent the lines and 0's its absence.
For eg a matrix 6X7 is shown
0 0 0 1 1 1 1
0 1 1 1 0 1 1
0 1 0 1 0 1 1
0 1 0 1 0 1 1
0 1 1 1 0 1 1
0 0 0 1 1 1 1
In the above matrix, the sequence of 1’s represents the lines. These eight lines constitute three
rectangles.
Conditons :
1. The rectangles will always enclose some 0’s. e.g. last two vertical lines does not constitute a
rectangle.
2. A rectangle can contain multiple rectangles
Output : should be no. of rectangles formed in the matrix(intersecting rectangles are also counted).| Report Duplicate | Flag | PURGE
McAfee Senior Software Development Engineer Java - 1of 1 vote
AnswersReverse String Ex: "Hello World" into "World Hello"
- priti2.jain August 16, 2013 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Algorithm - 1of 3 votes
AnswersWrite a function to find 5th element from a singly linked List from the end(not from the head) in one pass.
- priti2.jain August 16, 2013 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Linked Lists - 0of 0 votes
AnswersWrite a function to find an first non-duplicate Character from the given String. For example : String "efficiency" has 'n' first non-duplicate character.
- priti2.jain August 16, 2013 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Algorithm - 0of 0 votes
Answersnegate each bit of 32 bit integer. I answered with XOR with FFFF but interviewer asked will ~(number) work? I answered as no.
- gaurav.2897 July 30, 2013 in India
I executed this piece of code
int x=8;
int k=~(x);
printf(%d",k)
output: 9
x=1000
~(x) =9 how?| Report Duplicate | Flag | PURGE
McAfee SDE1 C - -2of 2 votes
AnswersIn a game, you bet using the following strategy. Whenever you lose a bet, you double the value of the bet for the next round. Whenever you win, the bet for the next round will be one dollar. You start the round by betting one dollar.
- Shock March 17, 2013 in India for Sustainability Engineering
For example, if you start with 20 dollars, and you win the bet in the first round, lose the bet in the next two rounds and then win the bet in the fourth round, you will end up with 20+1-1-2+4 = 22 dollars.
You are expected to complete the function, getFinalAmount, which takes two arguments. The first argument is an integer initialAmount which is the initial money we amount we have when we start the betting. The second argument is a string betResultsThe ith character of outcome will be either 'W' (win) or 'L' (lose), denoting the result of the ith round.
Your function should return the amount of money you will have after all the rounds are played. If at some point you don't have enough money in your account to cover the value of the bet, you must stop and return the sum you have at that point.
Sample Test Cases:
Input #00:
12
WWWWWWWW
Output #00:
20
Explanation:
The initial amount is 12, for every win, you gain 1 dollar.
There are totally 8 consecutive wins and no losses, hence total money gained = 12 + 8 = 20
Input #01:
15
LLLWLLLL
Output #01:
1
Explanation:
The initial amount is 15. As stated in the problem, the amount of bet doubles for every loss.
1st round - Loss: 15-1 = 14
2nd round - Loss: 14-2 = 12 (Bet doubles)
3rd round - Loss: 12-4 = 8
4th round - Win: 8 + 8 = 16
5th round - Loss:16-1 = 15 (Since the previous bet was a win, this bet has a value of 1 dollar)
6th round - Loss: 15-2 = 13
7th round - Loss: 13-4 = 9
8th round - Loss: 9-8 = 1| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Algorithm - 0of 0 votes
AnswersComplete the function getEqualSumSubstring, which takes a single argument. The single argument is a string s, which contains only non-zero digits.
- Shock March 17, 2013 in India for Sustainability Engineering
This function should print the length of longest contiguous substring of s, such that the length of the substring is 2*N digits (maximum length of the string is 49) and the sum of the leftmost N digits is equal to the sum of the rightmost N digits.If there is no such string, your function should print 0.
Sample Test Cases:
Input #00:
123231
Output #00:
6
Explanation:
1 + 2 + 3 = 2 + 3 + 1.
The length of the longest substring = 6 where the sum of 1st half = 2nd half
Input #01:
986561517416921217551395112859219257312
Output #01:
36| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Algorithm - 0of 0 votes
Answersnormal bubble sort require 100sec to sort 10000 entries.what will be the input size if it will solve in 50sec.
- Amresh September 02, 2012 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer C - 0of 0 votes
AnswersYou are blindfolded and 20 coins are placed on the table in front of you. Out of them 10 coins have heads facing up and other tails. You are allowed to flip and move the coins. You should divide those coins into two sets such that one set contains 10 heads and other tails. You are allowed to only move or flip the coins
- irraju July 31, 2012 in India| Report Duplicate | Flag | PURGE
McAfee Developer Program Engineer - 0of 0 votes
AnswersWhat are upper half and bottom half in device drivers.Why are they used?
- McAfee July 11, 2011| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Linux Kernel - 0of 0 votes
AnswerWhat is the mechanism for open(),read(),write() system calls how does the kernel implements them and what happens when a user space program uses
- McAfee July 11, 2011
open(file,r) like this with arguments,how does kernel implement it.| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Operating System - 0of 0 votes
AnswersWhat is the difference between spin lock, mutex,semaphore.I was clear on this answer but then he asked for a real example of mutex.
- McAfee July 11, 2011
I answered for busy waiting condition in spin lock,mutex there is no context switch.Then he said about pthread_mutex() call defined for using a mutex.Another program in which you do a fork and have a child process where are you going to use pthread_mutex in parent or in child.What is the difference between parent and child process?| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Operating System - 0of 0 votes
AnswersDifferenced between fork(),pthread() system calls.What is vfork().What is a file system how does kernel stores the data structure with respect to file system,he hinted to super blocks I was not much aware of super blocks etc in a file system,then I attempted for VFS kind of thing.
- McAfee July 11, 2011| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Linux Kernel - 0of 0 votes
AnswersOn some architecture stack grows upwards and on some architecture stack grows downwards.How will you find out whether the stack is growing upwards or downwards?
- McAfee July 11, 2011| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Computer Architecture & Low Level - 0of 0 votes
AnswersGiven two linked lists, which are intersecting some where the shape can be L,Y or I, how will you find the intersection point?What will be time complexity.Assuming worst case how will you reduce the complexity.After having attempted this how will you convert above structure into X?
- McAfee July 11, 2011| Report Duplicate | Flag | PURGE
McAfee Software Engineer / Developer Algorithm