java082864
BAN USERpublic List<Integer> findTriplet(int[] tempChar){
List<Integer> tempList = new ArrayList<>();
for(int i=0;i<tempChar.length-2;i++){
for(int j=1;j<tempChar.length-1;j++){
for(int k=2;k<tempChar.length;k++){
if(tempChar[i]+tempChar[j]+tempChar[k] == 0 || tempChar.length ==0){
tempList.add(tempChar[i]);
tempList.add(tempChar[j]);
tempList.add(tempChar[k]);
}
}
}
}
System.out.println("" +tempList);
return tempList;
}
public List<Integer> findTriplet(int[] tempChar){
List<Integer> tempList = new ArrayList<>();
for(int i=0;i<tempChar.length-2;i++){
for(int j=1;j<tempChar.length-1;j++){
for(int k=2;k<tempChar.length;k++){
if(tempChar[i]+tempChar[j]+tempChar[k] == 0 || tempChar.length ==0){
tempList.add(tempChar[i]);
tempList.add(tempChar[j]);
tempList.add(tempChar[k]);
}
}
}
}
System.out.println("" +tempList);
return tempList;
}
public List<String> startStop(){
Map<String,List<Integer>> employee = new HashMap<>();
employee.put("A", Arrays.asList(1,4));
employee.put("B", Arrays.asList(3,5));
employee.put("C", Arrays.asList(2,7));
employee.put("D", Arrays.asList(5,10));
int startIndex = 0;
int stopIndex = 1;
int currentTime =24;
int maxCount=0;
List<String> meetingRoom = new ArrayList<>();
for(int i=0; i<currentTime; i++){
for(Map.Entry<String, List<Integer>> emp : employee.entrySet()){
if(emp.getValue().get(startIndex)==i){
meetingRoom.add(emp.getKey());
} if(emp.getValue().get(stopIndex)==i){
meetingRoom.remove(emp.getKey());
}
}
if(maxCount < meetingRoom.size()){
maxCount = meetingRoom.size();
}
System.out.println("At time " + i + " employees " +meetingRoom.toString()+ " are present. Max members " +maxCount);
}
return meetingRoom;
}
public boolean checkdup (String charInput){
char[] tempChar = charInput.toCharArray();
for(int i=0;i<tempChar.length -1;i++){
for(int j=i+1;j<tempChar.length;j++){
if(tempChar[i] == tempChar[j]){
return true;
}
}
}
return false;
}
can you elaborate on the question .. it is little confusing
- java082864 July 11, 2017public String myString(char [] charInput){
StringBuilder sb = new StringBuilder();
sb.setLength(charInput.length +1);
sb.insert(0, charInput.length); //first element of the string is the length of the array.
int j=1;
for (int i=0; i<charInput.length; i++){
sb.insert(j, charInput[i]); //add all elements of array to string after length
j++;
}
System.out.println("final string -" +sb);
return sb.toString();
}
Were they looking for a front end design ?
- java082864 July 07, 2017public boolean triplet(int[] numbers, int X){
for(int i=0;i<numbers.length;i++){
for(int j = i+1; j<numbers.length;j++){
for(int k = j+1; k<numbers.length;k++){
if(numbers[i]+numbers[j]+numbers[k] == X){
return true;
}
}
}
}
return false;
}
- java082864 July 18, 2017