Sunday, February 4, 2024

 https://meet.google.com/nwp-tgky-jsp

You are given a 0-indexed two-dimensional integer array nums.


Return the largest prime number that lies on at least one of the diagonals of nums. In case, no prime is present on any of the diagonals, return 0.


Note that:


An integer is prime if it is greater than 1 and has no positive integer divisors other than 1 and itself.

An integer val is on one of the diagonals of nums if there exists an integer i for which nums[i][i] = val or an i for which nums[i][nums.length - i - 1] = val.


In the above diagram, one diagonal is [1,5,9] and another diagonal is [3,5,7].


Example 1:


Input: nums = [[1,2,3],[5,6,7],[9,10,11]]

Output: 11

Explanation: The numbers 1, 3, 6, 9, and 11 are the only numbers present on at least one of the diagonals. Since 11 is the largest prime, we return 11.

Example 2:


Input: nums = [[1,2,3],[5,17,7],[9,11,10]]

Output: 17

Explanation: The numbers 1, 3, 9, 10, and 17 are all present on at least one of the diagonals. 17 is the largest prime, so we return 17.

-----------------------------------------------

An ugly number is a positive integer that is divisible by a, b, or c.


Given four integers n, a, b, and c, return the nth ugly number.


Example 1:


Input: n = 3, a = 2, b = 3, c = 5

Output: 4

Explanation: The ugly numbers are 2, 3, 4, 5, 6, 8, 9, 10... The 3rd is 4.

Example 2:


Input: n = 4, a = 2, b = 3, c = 4

Output: 6

Explanation: The ugly numbers are 2, 3, 4, 6, 8, 9, 10, 12... The 4th is 6.

Example 3:


Input: n = 5, a = 2, b = 11, c = 13

Output: 10

Explanation: The ugly numbers are 2, 4, 6, 8, 10, 11, 12, 13... The 5th is 10.

 -------------------------------------------------------

Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.

 


Example 1:


Input: n = 5

Output: 10

Explanation: The smallest multiple of both 5 and 2 is 10.

Example 2:


Input: n = 6

Output: 6

Explanation: The smallest multiple of both 6 and 2 is 6. Note that a number is a multiple of itself.



----------------------------------------------

Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the array by any possible subset and multiplicand.


Return True if the array is good otherwise return False.


 


Example 1:


Input: nums = [12,5,7,23]

Output: true

Explanation: Pick numbers 5 and 7.

5*3 + 7*(-2) = 1

Example 2:


Input: nums = [29,6,10]

Output: true

Explanation: Pick numbers 29, 6 and 10.

29*1 + 6*(-3) + 10*(-1) = 1

Example 3:


Input: nums = [3,6]

Output: false


----------------------------------------------

Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.


 


Example 1:


Input: num = 38

Output: 2

Explanation: The process is

38 --> 3 + 8 --> 11

11 --> 1 + 1 --> 2 

Since 2 has only one digit, return it.


----------------------------------

S
  S#  SNAME  STATUS   CITY
  ----------------------------
  S1  Smith  20       London
  S2  Jones  10       Paris
  S3  Blake  30       Paris
  S4  Clark  20       London
  S5  Adams  30       Athens

P P# PNAME COLOR WEIGHT CITY ---------------------------------- P1 Nut Red 12.0 London P2 Bolt Green 17.0 Paris P3 Screw Blue 17.0 Oslo P4 Screw Red 14.0 London P5 Cam Blue 12.0 Paris P6 Cog Red 19.0 London

SP S# P# QTY ------------ S1 P1 300 S1 P2 200 S1 P3 400 S1 P4 200 S1 P5 100 S1 P6 100 S2 P1 300 S2 P2 400 S3 P2 200 S4 P2 200 S4 P4 300 S4 P5 400
INSERT INTO S VALUES (1, 'Smith', 20, 'London');
  INSERT INTO S VALUES (2, 'Jones', 10, 'Paris');
  INSERT INTO S VALUES (3, 'Blake', 30, 'Paris');
  INSERT INTO S VALUES (4, 'Clark', 20, 'London');
  INSERT INTO S VALUES (5, 'Adams', 30, 'Athens');
  INSERT INTO P VALUES (1, 'Nut', 'Red', 12, 'London');
  INSERT INTO P VALUES (2, 'Bolt', 'Green', 17, 'Paris');
  INSERT INTO P VALUES (3, 'Screw', 'Blue', 17, 'Oslo');
  INSERT INTO P VALUES (4, 'Screw', 'Red', 14, 'London');
  INSERT INTO P VALUES (5, 'Cam', 'Blue', 12, 'Paris');
  INSERT INTO P VALUES (6, 'Cog', 'Red', 19, 'London');
  INSERT INTO SP VALUES (1, 1, 300);
  INSERT INTO SP VALUES (1, 2, 200);
  INSERT INTO SP VALUES (1, 3, 400);
  INSERT INTO SP VALUES (1, 4, 200);
  INSERT INTO SP VALUES (1, 5, 100);
  INSERT INTO SP VALUES (1, 6, 100);
  INSERT INTO SP VALUES (2, 1, 300);
  INSERT INTO SP VALUES (2, 2, 400);
  INSERT INTO SP VALUES (3, 2, 200);
  INSERT INTO SP VALUES (4, 2, 200);
  INSERT INTO SP VALUES (4, 4, 300);
  INSERT INTO SP VALUES (4, 5, 400);



No comments:

 DBMS class materials click here to join the class room  click here  https://www.youtube.com/channel/UC93Sqlk_tv9A9cFv-QjZFAQ