Surekhag28
BAN USER
Questions (5)
Comments (2)
Followers (1)
Reputation 150
- 2of 2 votes
AnswersWrite a code to test whether string s2 is obtained by rotating the string s1 by 2 places.
- Surekhag28 in India for Kindle
e.g S1="amazon" S2="azonam" return true
S1="quality" S2="lityqua" return false| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 0of 0 votes
AnswersWrite the test data for the function which takes input value as floating number and precision. It returns the output by rounding the value nearest to precision value.
- Surekhag28 in India for Kindle
e.g roundOff(3.4567,2) output will be 3.55| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Yes u are right thats a small mistake from my side.....it should round off to 3.46....(i.e to the 2nd decimal place)
- Surekhag28 July 26, 2014Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
With hashmap code will be
- Surekhag28 July 26, 2014import java.util.*;
public class arrayDuplicate
{
public static void main(String args[])
{
int arr[]={5,3,4,6,7,3,5,1,5,5,2,3,2,3};
int duparr[];
int i,j,count;
HashMap hm=new HashMap();
for(i=0;i<arr.length;i++)
{
count=1;
for(j=i+1;j<arr.length;j++)
{
if(arr[i]!=arr[j])
continue;
else
{
count=count+1;
hm.put(arr[i],count);
}
}
}
Set set=hm.entrySet();
Iterator it=set.iterator();
while(it.hasNext())
{
Map.Entry me=(Map.Entry)it.next();
System.out.println("Element:- "+me.getKey()+" Count:- "+me.getValue());
}
System.out.println("Total duplicate elements:- "+hm.size());
}
}