INFO5100 Assignment 1 Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

Question 1:

You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.

Return the sum of all the unique elements of nums. Example 1:

Input: nums = [1,2,3,2]
Output: 4
Explanation: The unique elements are [1,3], and the sum is 4.

Example 2:

Input: nums = [1,1,1,1,1]
Output: 0
Explanation: There are no unique elements, and the sum is 0.

Example 3:

Input: nums = [1,2,3,4,5]
Output: 15
Explanation: The unique elements are [1,2,3,4,5], and the sum is 15.

Question 2:

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

Example 1:

Input: nums = [-4,-1,0,3,10] Output: [0,1,9,16,100]

Explanation: After squaring, the array becomes [16,1,0,9,100]. After sorting, it becomes [0,1,9,16,100].

Example 2:

Input: nums = [-7,-3,2,3,11] Output: [4,9,9,49,121]

Question 3:

Find first non repeated integer in an array.

Example: int[] arr = {2,3,4,2,2,3,5,7} Output : 4

Question 4:

Given two stings and , return true if can be constructed from magazine and false otherwise.

Each letter in magazine can only be used once in ransomNote. Example 1:

ransomNote

magazine

Input: ransomNote = “a”, magazine = “b” Output: false

Example 2:

ransomNote

Input: ransomNote = “aa”, magazine = “ab” Output: false

Example 3:

Input: ransomNote = “aa”, magazine = “aab” Output: true

Question 5:

Letter followed by Digit: Given a string str write a function which will check if the string no letter followed by another letter, and no digit followed by another digit.

For example: 1A3d4s5t Result : True

Input: A2bb2d4 Result : False

  • Assignment1-78ec7n.zip