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

//remove space in the word
str = str.Replace(" ", "");
Console.WriteLine("After remove the space in the sentence " + str);
//----------*******************-----------------

//Find the largest word in a sentence
string BigWord = string.Empty;
int maxcount = 0;
foreach (string word in str.Split(' '))
{
if (word.Length > maxcount)
{
BigWord = word;
maxcount = word.Length;
}
}
Console.WriteLine("Longest word in the sentence is : " + BigWord + "and the length of the word is : " + maxcount);
//----------*******************-----------------


//Find the count of E
int numberofE = str.ToCharArray().Count(c => c == 'e');

//Extract Number from string - Option1
string intextract =string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (char.IsDigit(str[i]))
{
intextract += str[i];
}
}
//----------*******************-----------------

//Extract Number from string - Option2
string intextract1 = Regex.Match(intextract, @"\d+").Value;
int a = int.Parse(intextract);
int b = int.Parse(intextract1);
Console.WriteLine("The Extracted numbers are : " + a);
Console.WriteLine("The Extracted numbers are : " + b);
//----------*******************-----------------

int numberofWord = str.ToCharArray().Count(c => c == ' ');

int numberofSentence= str.ToCharArray().Count(c => c == '.');

- Anonymous March 07, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Collections;
using System.Text.RegularExpressions;

namespace Anagram
{
class Program
{

/* program to test above function */
public static void Main()
{
//Convert Character into string
char[] ch1 = new char[5] { 'H', 'e', 'l', 'l', 'o' };
string ss = new string(ch1);
Console.WriteLine(ss);
//----------*******************-----------------


string str = "my brother is taller than me@1233334. I always a short man,but smaller than him.";
//Count a particular character in a string
int numberofE = str.ToCharArray().Count(c => c == 'e');
int numberofWord = str.ToCharArray().Count(c => c == ' ');
int numberofSentence= str.ToCharArray().Count(c => c == '.');
Console.WriteLine("Number of E in the given sentence is : " + numberofE);
Console.WriteLine("Number of word in the given sentence is : " + numberofWord);
Console.WriteLine("Number of sentence in the given string is : " + numberofSentence);


//Number of occurece of each character in a given string
int numberofoccur = 0;
Dictionary<char, int> dc = new Dictionary<char, int>();
char[] newarr = str.ToCharArray();
foreach (char ch in newarr)
{
numberofoccur = str.ToCharArray().Count(c => c == ch);
if (numberofoccur > 1)
{
if (!dc.ContainsKey(ch))
{
dc.Add(ch, numberofoccur);
Console.WriteLine("The character " + ch + " Repeated upto " + numberofoccur + " times");
}
}
}
//----------*******************-----------------

//Extract Number from string - Option1
string intextract =string.Empty;
for (int i = 0; i < str.Length; i++)
{
if (char.IsDigit(str[i]))
{
intextract += str[i];
}
}
//----------*******************-----------------

//Extract Number from string - Option2
string intextract1 = Regex.Match(intextract, @"\d+").Value;
int a = int.Parse(intextract);
int b = int.Parse(intextract1);
Console.WriteLine("The Extracted numbers are : " + a);
Console.WriteLine("The Extracted numbers are : " + b);
//----------*******************-----------------

//Find the largest word in a sentence
string BigWord = string.Empty;
int maxcount = 0;
foreach (string word in str.Split(' '))
{
if (word.Length > maxcount)
{
BigWord = word;
maxcount = word.Length;
}
}
Console.WriteLine("Longest word in the sentence is : " + BigWord + "and the length of the word is : " + maxcount);
//----------*******************-----------------

//remove space in the word
str = str.Replace(" ", "");
Console.WriteLine("After remove the space in the sentence " + str);
//----------*******************-----------------
Console.ReadLine();
}
}
}

- PAPPU March 07, 2020 | 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