Akamai Interview Question for Java Developers


Country: United States




Comment hidden because of low score. Click to expand.
1
of 1 vote

can you elaborate on the question .. it is little confusing

- java082864 July 11, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

My Java solution.

private boolean isEqual(String s) {
    if (s.length() < 3) {
        return false;
    }
    // create start sum and end sum value
    int start = 0;
    int end = 0;

    // sum the first three number and last three number
    for (int i = 0; i < 3; i++) {
        if (Character.isDigit(s.charAt(i))) {
            start += s.charAt(i);
        } else {
            return false; // char at i is not number
        }

        if (Character.isDigit(s.charAt(s.length() - 1 - i))) {
            end += s.charAt(s.length() - 1 - i);
        } else {
            return false; // char at s.length() - 1 - i is not number;
        }
    }

    return start == end;
}

- techinterviewquestion.com July 11, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package org.test;
{


/* write a java program to solve sum of first three numbers is equal to sum of last three numbers.
String str="123" 1+2+3 and 3+2+1
String str="678786"
String str="1b8" not equal.*/

public static void main (String[] args){
System.out.println("Program starts");
String str = "abcdfdgd";
if(str.length()<3){
System.out.println("String is not 3 length");
}
else{
char[] arr =str.toCharArray();
int firstthree=0;
int lastthree = 0;
for(int i=0;i<3;i++){
if(Character.isDigit(arr[i]))
firstthree = firstthree +Character.getNumericValue(arr[i]);
}
for (int i=arr.length; i>arr.length-3;i--){
if(Character.isDigit(arr[i-1]))
lastthree = lastthree+Character.getNumericValue(arr[i-1]);
}
if(firstthree==lastthree && firstthree!=0){
System.out.println("the first three digit and last three digit are equal");
}
else{
System.out.println("the first three digit and last three digit are not equal");
}
}
}

}

- Anonymous July 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
/* write a java program to solve sum of first three numbers is equal to sum of last three numbers.
String str="123" 1+2+3 and 3+2+1
String str="678786"
String str="1b8" not equal.*/

public static void main (String[] args){
System.out.println("Program starts");
String str = "abcdfdgd";
if(str.length()<3){
System.out.println("String is not 3 length");
}
else{
char[] arr =str.toCharArray();
int firstthree=0;
int lastthree = 0;
for(int i=0;i<3;i++){
if(Character.isDigit(arr[i]))
firstthree = firstthree +Character.getNumericValue(arr[i]);
}
for (int i=arr.length; i>arr.length-3;i--){
if(Character.isDigit(arr[i-1]))
lastthree = lastthree+Character.getNumericValue(arr[i-1]);
}
if(firstthree==lastthree && firstthree!=0){
System.out.println("the first three digit and last three digit are equal");
}
else{
System.out.println("the first three digit and last three digit are not equal");
}
}
}

}

- Thushar July 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Scanner;
public class CompareThreeDigitsAddition {

//Limitations 1. String length >=3
// 2. Only digits accepted


static final int len = 3;

public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner scn = new Scanner(System.in);

System.out.print("Enter string:");
String str = scn.next();

int firstSum=0, lastSum=0;
boolean exception = false;
if(str.length() < CompareThreeDigitsAddition.len)
System.out.println("Length should be greater than "+CompareThreeDigitsAddition.len);
else {

//simple approach by iterating only once
for(int i=0;i<3;i++){

if(Character.isDigit(str.charAt(i))){
firstSum += Character.getNumericValue(str.charAt(i));

}else{ exception = true;}

if(Character.isDigit(str.charAt(str.length()-1-i))){
lastSum += Character.getNumericValue(str.charAt(str.length()-1-i));
}else{ exception = true;}
}
if( !exception && firstSum==lastSum)
System.out.println("Both are equal "+firstSum);
else{
System.out.println("Exception occured or Both are not equal. firstSum:"+firstSum+" lastSum:"+lastSum);
}


}

}

}

- Anonymous August 17, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

private static boolean checkIfFirstThreeNumbersAreEqualToSumOfLastThreeNumbers(String param){
boolean flag = false;
if (param.length() < 3)
flag = false;

else {
int fisrtThreeSum = 0;
int lastThreeSum = 0;
int startIndex = 0;
int lastIndex = param.length()-1;
flag = true;
while (startIndex < 3) {
if(Character.isAlphabetic(param.charAt(startIndex)) || Character.isAlphabetic(param.charAt(lastIndex))) {
flag = false;
break;
}
fisrtThreeSum = fisrtThreeSum+Character.getNumericValue(param.charAt(startIndex));
lastThreeSum = lastThreeSum+Character.getNumericValue(param.charAt(lastIndex));
startIndex++; lastIndex--;
}

System.out.println("FirstThreeSum = "+fisrtThreeSum);
System.out.println("LastThreeSum = "+lastThreeSum);

}
System.out.println("Flag is "+flag);
return flag;
}

- Kapil Naidu February 13, 2019 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More