Kiran Vadakath
BAN USER
- 0of 0 votes
AnswersThere is a log file with writes processes details in the below mentioned format .
- Kiran Vadakath in India
---
Process_Name - RID(MB) - Time
---
It is updated every second. write bash script to report processes which is having RID greater than 30.
NB: Avoid reading the file line by line as it is very huge and updated every second| Report Duplicate | Flag | PURGE
Directi Production Engineer shell scripting - 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 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Coding - 1of 1 vote
AnswersThere are different buildings standing close to each other. These are of same width but different height.
- Kiran Vadakath in India
Suppose if rainfall happens, what will be the volume of water that get trapped on top of all these buildings together. ?
INPUT (Example)
No: of buildings : 4
heights of the buildings(in any units): 3 4 3 4| Report Duplicate | Flag | PURGE
Directi Developer Program Engineer Algorithm
Everytime we take a step, we need to ensure that we won't be resting on the 'k'th step which is broken. All other steps we can take. Please check the solution below.
int fnMaxSteps(int n,int k){
int steps = 0;
for (int i=1;i<=n;i++){
if(steps+i==k)
continue;
else
steps+=i;
}
return steps;
}
Sorting the distances in ascending can be a solution and selecting first million distances is a possible way. But the limit is quite large in this case.
- Kiran Vadakath April 27, 2015
Thank you for the answer.
'Test' you gave is working , however due to some reason there was no results after executing the given logmonitor.sh .
Below given modified version of your answer is serving the purpose
- Kiran Vadakath June 17, 2015