Athena Health Interview Question for Applications Developers


Country: India
Interview Type: In-Person




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

Static problem (the way you posed it).

So, PRINT(" < pre process the answers and put them here> ");

?

- S O U N D W A V E October 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

#include <iostream>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	char str[90] =
			"my brother is taller than me@1233334. I always a short man,but smart than him";
	char find = 'e';
	int findCount = 0, sentenceCount = 0, doubleCount = 0, wordCount = 0,
			intCount = 0, wordLength = 0, maxLength = 0;
	char lastChar = '\0';
	char* iterator = str;
	bool sentenceEnd = true, wordEnd = true;
	char word[20];
	string maxWord = "";
	vector<char> noSpaceString ;

	memset(word,'\0',20);
	for (int i = 0; *iterator != '\0'; ++i, ++iterator) {
		if (*iterator == find) {
			++findCount;
		}

		if (sentenceEnd == true) {
			++sentenceCount;
			sentenceEnd = false;
		}

		if (wordEnd == true && isalpha((int) *iterator)) {
			++wordCount;
			wordEnd = false;
		}

		if (*iterator == ' ' || *iterator == ',' || *iterator == '.') {
			wordEnd = true;
		}

		if (*iterator == '.') {
			sentenceEnd = true;
		}

		if (isdigit((int(*iterator)))) {
			++intCount;
		}

		if (*iterator == lastChar) {
			++doubleCount;
			lastChar = '\0';
		} else
			lastChar = *iterator;

		if (isalpha((int) *iterator)) {
			++wordLength;
			word[wordLength-1] = *iterator;
		} else {
			maxLength = maxLength > wordLength ? maxLength : wordLength;
			maxWord = maxLength == wordLength ? word : maxWord;
			wordLength = 0;
			memset(word,'\0',20);
		}

		if (*iterator != ' ')
			noSpaceString.push_back(*iterator);

	}

	cout << "Number of integers: " << intCount << endl;
	cout << "Number of doubles: " << doubleCount << endl;
	cout << "Number of words: " << wordCount << endl;
	cout << "Number of sentences: " << sentenceCount << endl;
	cout << "Number of " << find << "(s): " << findCount << endl;
	cout << "Biggest word: " << maxWord << endl;
	cout << "Space-less String: ";
	for (vector<char>::iterator it = noSpaceString.begin(); it!= noSpaceString.end(); ++it)
		cout << *it;

	cout << endl << "Actual String: " << str << endl;
	return 0;
}

- Vishwanath S July 31, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
package coding;

//import java.util.Scanner;

public class DealingWithString {
public static void main(String args[]){
String text= "my brother is taller than me @1233334 . I always a short man , but smatter than him .";
String word[]=text.split(" ");
int max=0,count=0;
String maxStr="";

//Removing whitespaces
System.out.println("Text without space is ");
for(int i=0;i<word.length;i++)
{System.out.print(word[i]);
}
System.out.print("\n");

//Largest string
for(int i=0;i<word.length;i++)
{
if(max < word[i].length())
{
max=word[i].length();
maxStr=word[i];
}
}
System.out.println("The largest word is "+maxStr);



//Finding numbers of e letters in the given text
for(int i=0;i<text.length();i++){
if(text.charAt(i)=='e'){
count++;
}
}
System.out.println("Numbers of e in the text are: "+count);


//Finding number of double
int doubleCount=0;
for(int i=0;i<text.length()-1;i++){
char c=text.charAt(i+1);
if(text.charAt(i)==c){
doubleCount++;
}
}
System.out.println("Numbers of doubles in the text are: "+doubleCount);


//Finding number of integers
int intCount=0;
for(int j=0;j<text.length();j++){
if((text.charAt(j)>='0' && text.charAt(j)<='9')){
intCount++;
}
}
System.out.println("Numbers of integers in the text are: "+intCount);




//Finding number of words
System.out.println("Number of words in the string are :" +(word.length-3));

//Finding number of sentence
int sencount=0;
for(int i=0;i<text.length();i++){
if(text.charAt(i)=='.'){
sencount++;
}
}
System.out.println("Number of sentence is"+(sencount));
}

}
}

- Anonymous January 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use replace the space with no space and print the string

- Anonymous February 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

in this program no spaces were removed between words

- muthusankar October 25, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

package com.lmali;

public class QuestionPaper {

	public static void main(String args[]){
		
		
		String s="my brother is taller than me @1233334 . I always a short man , but smatter than him .";
		String s1=s.replaceAll(" ", "");
		System.out.println("String without space: "+s1);
		
		String[] stk=s.split(" ");
		
		int len=0;
		int index=0;
		for(int i=0;i<stk.length;i++){
			int stlen=stk[i].length();
			if(stlen>len){
				len=stlen;
				index=i;
			}
		}
		System.out.println("Longest String is :"+stk[index]);
		
		int count=0;
		for(int i=0;i<s.length();i++){
			if('e'==s.charAt(i)){
				count++;
			}
		}
		System.out.println("Number of e cahracter is:"+count);
		int cntDigit=0;
		for(int i=0;i<s.length();i++){
			if(((int)s.charAt(i)>=48 && (int)s.charAt(i)<=57)){
				cntDigit++;
			}
		}
		System.out.println("Number of Integer in string:"+cntDigit);
		
		int wordcnt=0;
		for(int i=0;i<stk.length;i++){
			if(stk[i].length()==1 && ((int)stk[i].charAt(0)>=32&&(int)stk[i].charAt(0)<=47)){	
			}
			else{
				wordcnt++;
			}
		}
		
		System.out.println("Number of Word in String is"+wordcnt);
		
		
		String[] st=s.split("\\.");
		System.out.println("Number of Sentence :"+st.length);
		
		int doublecnt=0;
		 for(int i=0;i<s.length()-1;i++){
			 if(s.charAt(i+1)==s.charAt(i)){
				 doublecnt++; 
			 }
		 }
		 System.out.println("Doubles count:"+doublecnt);		
	}	
}

- Anonymous May 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package com.lmali;

public class QuestionPaper {

	public static void main(String args[]){
		
		
		String s="my brother is taller than me @1233334 . I always a short man , but smatter than him .";
		String s1=s.replaceAll(" ", "");
		System.out.println("String without space: "+s1);
		
		String[] stk=s.split(" ");
		
		int len=0;
		int index=0;
		for(int i=0;i<stk.length;i++){
			int stlen=stk[i].length();
			if(stlen>len){
				len=stlen;
				index=i;
			}
		}
		System.out.println("Longest String is :"+stk[index]);
		
		int count=0;
		for(int i=0;i<s.length();i++){
			if('e'==s.charAt(i)){
				count++;
			}
		}
		System.out.println("Number of e cahracter is:"+count);
		int cntDigit=0;
		for(int i=0;i<s.length();i++){
			if(((int)s.charAt(i)>=48 && (int)s.charAt(i)<=57)){
				cntDigit++;
			}
		}
		System.out.println("Number of Integer in string:"+cntDigit);
		
		int wordcnt=0;
		for(int i=0;i<stk.length;i++){
			if(stk[i].length()==1 && ((int)stk[i].charAt(0)>=32&&(int)stk[i].charAt(0)<=47)){	
			}
			else{
				wordcnt++;
			}
		}
		
		System.out.println("Number of Word in String is"+wordcnt);
		
		
		String[] st=s.split("\\.");
		System.out.println("Number of Sentence :"+st.length);
		
		int doublecnt=0;
		 for(int i=0;i<s.length()-1;i++){
			 if(s.charAt(i+1)==s.charAt(i)){
				 doublecnt++; 
			 }
		 }
		 System.out.println("Doubles count:"+doublecnt);
		
		
	}
	
	
}

- Anonymous May 01, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.StringTokenizer;


public class Solution {

public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
String str = "All the best friends. You could do it by yourself!!!";
StringTokenizer arr = new StringTokenizer(str," ");
StringTokenizer sentence = new StringTokenizer(str,".");
StringBuffer str1 = new StringBuffer();
String longestStr = "";
long ecount = str.toLowerCase().chars().filter(num -> num == 'e').count();
long ncount = str.toLowerCase().chars().filter(num -> Character.isDigit(num)).count();
int wcount = arr.countTokens();
int scount = sentence.countTokens();
while (arr.hasMoreElements()) {
String currStr = arr.nextToken();
str1.append(currStr);
if(currStr.length()>longestStr.length()){
longestStr = currStr;
}
}

System.out.println(str1);
System.out.println(longestStr);
System.out.println(ecount);
System.out.println(ncount);
System.out.println(wcount);
System.out.println(scount);

}
}

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

import java.util.StringTokenizer;


public class Solution {

public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
String str = "All the best friends. You could do it by yourself!!!";
StringTokenizer arr = new StringTokenizer(str," ");
StringTokenizer sentence = new StringTokenizer(str,".");
StringBuffer str1 = new StringBuffer();
String longestStr = "";
long ecount = str.toLowerCase().chars().filter(num -> num == 'e').count();
long ncount = str.toLowerCase().chars().filter(num -> Character.isDigit(num)).count();
int wcount = arr.countTokens();
int scount = sentence.countTokens();
while (arr.hasMoreElements()) {
String currStr = arr.nextToken();
str1.append(currStr);
if(currStr.length()>longestStr.length()){
longestStr = currStr;
}
}

System.out.println(str1);
System.out.println(longestStr);
System.out.println(ecount);
System.out.println(ncount);
System.out.println(wcount);
System.out.println(scount);

}
}

- Shiv Dayal Kushwaha July 20, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.StringTokenizer;


public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        String str = "All the best friends. You could do it by yourself!!!";
        StringTokenizer arr = new StringTokenizer(str," ");
        StringTokenizer sentence = new StringTokenizer(str,".");
        StringBuffer str1 = new StringBuffer();
        String longestStr = "";
        long ecount =  str.toLowerCase().chars().filter(num -> num == 'e').count();
        long ncount =  str.toLowerCase().chars().filter(num -> Character.isDigit(num)).count();
        int wcount =  arr.countTokens();
        int scount =  sentence.countTokens();
        while (arr.hasMoreElements()) {
            String currStr = arr.nextToken();
            str1.append(currStr);
            if(currStr.length()>longestStr.length()){
                longestStr = currStr;
            }
        }
            
        System.out.println(str1);
        System.out.println(longestStr);
        System.out.println(ecount);
        System.out.println(ncount);
        System.out.println(wcount);
        System.out.println(scount);
        
    }
}

- Shiv Dayal July 20, 2018 | 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