JP Morgan Interview Question for Associates


Country: United States




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

No. input string could be empty or have multiple missing letters too.

- lord.claxton March 08, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

have a string alpabet lookup... remove chars from it if its presnt inthe input string...
print remaining letters from the alphabet lookup string

public static void main(String[] args)
{
    Scanner in = new Scanner(System.in);

    System.out.println("Enter the string : ");
    String input = in.nextLine();

    String out = checkPangram(input);

    if (out.length() == 0)
        System.out.println("Pangram");
    else
        System.out.println("The letters missing : " + out);
}

private static String checkPangram(String input)
{
    input = input.toLowerCase();
    String alph = "abcdefghijklmnopqrstuvwxyz";
    int max = 26;

    for (int i = 0; i < max; i++)
    {
        int index = input.indexOf(alph.charAt(i));
        if (index != -1)
        {
            alph = alph.substring(0, i) + alph.substring(i + 1);
            i--;
            max--;
        }
    }

    return alph;
}

- PeyarTheriyaa March 08, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

from string import ascii_lowercase, punctuation
from collections import defaultdict

def isPanagram(sentence):
  sentence = sentence.lower()
  letterCount = defaultdict(int)
  for letter in ascii_lowercase:
    letterCount[letter] = 0
  for letter in sentence:
    if letter in punctuation:
      continue # Skip special characters / punctuation marks
    letterCount[letter] += 1

  missingLetters = [letter for letter, count in letterCount.items() if count == 0]
  if len(missingLetters) == 0:
    print('The sentence is a panagram!')
  else:
    print('The sentence is not a panagram and is missing the letters: ', missingLetters)


isPanagram('Fox nymphs grab quick-jived waltz.')
isPanagram('The quick fox.')
isPanagram('The five boxing wizards jump quickly.')
isPanagram('The five boxing wizards jump.')

- prudent_programmer March 08, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void findMissingLetters(String input){
		boolean[] present = new boolean[26];
		input = input.toLowerCase();
		for(int i=0;i<input.length();i++){
			char c = input.charAt(i);
			if(c>='a' && c<='z'){
				present[c-'a'] = true;
			}
		}
		for(int i=0;i<26;i++){
			if(!present[i]){
				System.out.print((char)(i+'a') +  "   ");
			}
		}
	}

- dadakhalandhar March 09, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public boolean checkPangram(String word){
boolean flag=false;
word=word.toLowerCase();
for(char ch = 'a' ; ch <= 'z' ; ch++){
flag=false;
for(int i=0;i<word.length();i++ ){
if(word.charAt(i)==ch){
flag=true;
break;
}
}
if(false==flag){
System.out.println("missing charature is :" +ch);
break;
}
}
return flag;
}

- shubham dwivedi March 16, 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