NetApp Interview Question for Software Engineer / Developers






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

Map<String, List<String>> anagrammsMap = ....

public void addAnagramm(String str){
char[] strArr = str.toCharArray();
Arrays.sort( strArr );
String key = new String( strArr );
List<String> anagramms = anagrammsMap.get( key );
if( anagramms == null ){
anagrammsMap.put(key, anagramms);
}
anagramms.add( str );
}

- Maxim Stepanenko March 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

best solution

- Murat Karakus October 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

ohh!!!!
sorry i did the palindrome..
thanks
:)

- aditya.bokaro October 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static int IsAnagrams(string str1, string str2)
{
str1 = str1.ToLower();
str2 = str2.ToLower();

if (str1.Length != str2.Length)
{
Console.WriteLine("Strings are not anagrams of each other the lengths are not equal");
return 0;
}

Hashtable ht1 = new Hashtable();
for (int i = 0; i < str1.Length; i++)
{
ht1.Add(i,str1[i]);
}

Hashtable ht2 = new Hashtable();
for (int i = 0; i < str2.Length; i++)
{
ht2.Add(i, str2[i]);
}
int countsareequal = 0;
foreach (char c in str1)
{
if (ht1[c] == ht2[c])
{
countsareequal += 1;
}
}

if (countsareequal == str1.Length)
{
Console.WriteLine("two strings are anagrams");
return 1;
}
else
{
Console.WriteLine("two strings are anagrams");
return 0;
}

}

- vani October 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Space: O(1)
Time: O(n)

#include <stdio.h>
int main(int argc, char *argv[])
{
        char map[255] = { 0 }, *answ = "YES";
        int i,len1 = strlen(argv[1]), len2 = strlen(argv[2]);
        if(len1 == len2) {
                for(i = 0; i < len1;i++)
                        map[argv[1][i]]++;
                for(i=0;i < len2;i++)
                        map[argv[2][i]]--;
                for(i = 0; i < sizeof(map)/sizeof(map[0]); i++)
                        if(map[i] != 0) {
                                answ = "NO";
                                break;
                        }
        }
        else
                answ = "NO";
        printf("%s\n",answ);
        return (0);
}

- Anonymous November 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

void anagram(char *d, char *c, int length)
{
int i=0;
while(length--)
{d[i]=c[length];
i++;}
d[i]='\0';
}

- aditya.bokaro August 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@aditya.bokaro
dude u r wrong ...u r just reversing the string ..
Anagram is rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; e.g., orchestra = carthorse

- aditya rajhAns October 06, 2011 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

XOR All the characters of "Str1" and "Str2" , If result is zero then it is an anagram.

- Anonymous November 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

how about "abb" "acc"?

- Buptrain May 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

how about "abb" "acc"?

- Buptrain May 08, 2012 | Flag


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