Vaibhavs
BAN USER
- 1of 1 vote
AnswersSliding window problem where window size is 3 and we need to find the minimum from the window.
- Vaibhavs in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm
I need the first unique element
my solution is :
1. Insert the elements of the list into hashmap as Key and a count as value.
2. Before insert check the key into hashmap
if the key is present make the value as negative
else insert into the hashmap and increase the count value
3. After iterating the whole list,search for the key whose value is least +ve value
and that is the answer.
public static boolean isAnagram(String word, String anagram) {
if(word.length() != anagram.length())
return false;
char[] chars = word.toCharArray();
for(char c : chars)
{
int index = anagram.indexOf(c);
if(index != -1){
anagram = anagram.substring(0,index) +
anagram.substring(index +1, anagram.length());
}
else {
return false;
}
}
return anagram.isEmpty();
}
Time Complexity: O(n)
- Vaibhavs February 16, 2014public void setNext(ListNode node) {
this.node = node;
}
public void getNext() {
return this.next;
}
ListNode ReverseList(ListNode head) {
ListNode temp = null,nextNode = null;
while(head != null) {
nextNode = head.getNext();
head.setNext(temp);
temp = head;
head = nextNode;
}
return temp;
}
Time complexity:O(n) Space Complexity:O(1)
- Vaibhavs February 16, 2014
RepJeanSwest, Data Engineer at Achieve Internet
I am a nuclear power reactor operator who is responsible for the flow of energy at a power plant. I ...
RepBarbaraLocke, Android test engineer at ABC TECH SUPPORT
Hey, I'm a BarbaraLocke. And I love my work. Apart from this, I am doing some new experiments in ...
RepRaimeCarrillo, Area Sales Manager at 247quickbookshelp
Hi, I am Raime from Tampa USA . I work as an Local account executive employee. I work in many fields ...
RepHenryBrown, Associate at A9
I am an experienced budget analyst skilled at researching and consolidating financial and budget information. I am taught record keeping ...
RepAaghnyaBrown, Accountant at 247quickbookshelp
Professional agile project manager with over 2 years of experience in various facets of project management. Implement agile management ideals ...
RepZoyaCox, abc at A9
I am skilled in partnering with authorities and managers to identify items of concern and find innovative solutions to such ...
RepNevaLucas, Analyst at Apache Design
I was the Training manager in Checker Auto Parts Center. My current research projects are about astrology, vashikaran health outcomes ...
@Madhur do u think set can have duplicate into it?
- Vaibhavs April 19, 2014Given a list with duplicate values find the first unique elements in it.
and From Ex : BH BH F AL HJ AL HJ PK
according to ur logic the O/P should be F PK
how u will decide which one is First Unique element?