Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions