classSolution{publicbooleancontainsDuplicate(int[] nums){HashMap<Integer,Integer> map =newHashMap<>();for(int i =0;i<nums.length;i++){if(map.containsKey(nums[i])==false){
map.put(nums[i],1);}else{returntrue;}}returnfalse;}}
classSolution:defcontainsDuplicate(self, nums: List[int])->bool:dict={}for i in nums:if i notindict:dict[i]=1else:returnTruereturnFalse
classSolution:deffindTheDifference(self, s:str, t:str)->str:dict={}for i in t:if i indict:dict[i]+=1else:dict[i]=1#print(dict)for i in s:if i indict:dict[i]-=1#print(dict)for i indict:ifdict.get(i)==1:return i
classSolution{publiccharfindTheDifference(String s,String t){int res =0;for(char c:s.toCharArray()){
res^=c;}for(char c:t.toCharArray()){
res^=c;}return(char)res;}}
classSolution{publicint[]nextGreaterElement(int[] nums1,int[] nums2){int[] res =newint[nums1.length];Stack<Integer> stack =newStack<>();for(int i =0;i<nums2.length;i++){
stack.push(i);}for(int i =0;i<nums1.length;i++){boolean isFound =false;int max =-1;int count =0;Stack<Integer> temp =newStack<>();while(stack.size()!=0&& isFound ==false){int top = stack.pop();if(top > nums1[i]){
max = top;}elseif(top == nums1[i]){
isFound =true;}
temp.push(top);}
res[count]= max;
count++;while(temp.size()!=0){
stack.push(temp.pop());}}return res;}}
classSolution:defnextGreaterElement(self, nums1: List[int], nums2: List[int])-> List[int]:
res =[]
stack =[]for i in nums2:
stack.append(i)for num in nums1:
temp =[]
isFound =Falsemax=-1while(len(stack)!=0and isFound ==False):
top = stack.pop()if top > num:max= top
elif top == num:
isFound =True
temp.append(top)
res.append(max)while(len(temp)!=0):
stack.append(temp.pop())return res