Question: JAVA Please Answer all the questions otherwise don't answer... thank you Homework 6: HashMap & HashSet Question 1: Two sum Given an array of integers

JAVA

Please Answer all the questions otherwise don't answer... thank you

Homework 6: HashMap & HashSet

Question 1: Two sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up

to target.

You may assume that each input would have exactly one solution, and you may not use the same element

twice.

Question 2: Happy number

Write an algorithm to determine if a number n is happy.

A happy number is a number defined by the following process:

Starting with any positive integer, replace the number by the sum of the squares of its digits.

Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not

include 1.

Those numbers for which this process ends in 1 are happy.

Return true if n is a happy number, and false if not.

Question 3: Contains nearby duplicate

Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that

nums[i] == nums[j] and abs(i - j) <= k.

Question 4: Majority Element

Given an array nums of size n, return the majority element.

The majority element is the element that appears more than n / 2 times. You may assume that the majority

element always exists in the array.Homework 5: Recursion

Question 5: Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.

Two strings s and t are isomorphic if the characters in s can be replaced to get t.

All occurrences of a character must be replaced with another character while preserving the order of

characters. No two characters may map to the same character, but a character may map to itself

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!