LateRunner
BAN USER- 0of 0 votes
AnswersThere is a Deployment Window of fixed time T. There are multiple patches (independent of each other),
- LateRunner in India
that are to be deployed in the fixed time T. Find solution to deploy patches such that maximum time is
utilized in the window.
Test Case 1:
Input:
Window Size 4, List of Patches: [1,1,1,2,3]
Output:
[3,1] or [1,1,2]
Test Case 2:
Input:
Window Size 5, List of Patches: [1,2,3,6]
Output:
[2, 3]| Report Duplicate | Flag | PURGE
Computer Associates Principal Software Engineer Algorithm - 0of 0 votes
AnswersMultiThreading: How to process trades paralelly, and if there are any trades that are modified need to process then in a sequential way.
- LateRunner in United States
For E.g. if there are 10 trades, of which some trades are like created and then immediately modified before being processed, then need to process the trades parallelly, and for those trades that are created and modifed, need to process them sequentially.| Report Duplicate | Flag | PURGE
Applications Developer
Tried following with above algo. working fine for me.. :)
public class ArraySortPerformance {
//Array Length not specified in problem. Lets say n=50
private final static int ARRAY_LENGTH = 50;
public static void main(String[] args) {
//Prepare Input Data
int[] inputArray = new int[ARRAY_LENGTH];
Random random = new Random();
for(int i=0;i<50;i++){
inputArray[i] = random.nextInt(100);
}
//Create Temporary array
int[] tempArray = new int[101];
for(int i: inputArray){
tempArray[i]++;
}
//Sort Result based on temp
int[] resultArray = new int[ARRAY_LENGTH];
for(int i=1, j=0; i<=100;i++){
if(tempArray[i] == 0)
continue;
else{
for(int k=0; k<tempArray[i];k++){
resultArray[j] = i;
j++;
}
}
}
//Print input and output for verification
System.out.println("Input::");
for(int j: inputArray){
System.out.print(j+" ");
}
System.out.println("");
System.out.println("Result::");
for(int j: resultArray){
System.out.print(j+" ");
}
}
}
- LateRunner February 02, 2014