2709. Greatest Common Divisor Traversal
You are given a 0-indexed integer array
nums, and you are allowed to traverse between its indices. You can traverse between indexiand indexj,i != j, if and only ifgcd(nums[i], nums[j]) > 1, wheregcdis the greatest common divisor.Your task is to determine if for every pair of indices
iandjin nums, wherei < j, there exists a sequence of traversals that can take us fromitoj.Return
trueif it is possible to traverse between all such pairs of indices, orfalseotherwise.
2708. Maximum Strength of a Group
You are given a 0-indexed integer array
numsrepresenting the score of students in an exam. The teacher would like to form one non-empty group of students with maximal strength, where the strength of a group of students of indicesi0,i1,i2, … ,ikis defined asnums[i0] * nums[i1] * nums[i2] * ... * nums[ik].Return the maximum strength of a group the teacher can create.
2707. Extra Characters in a String
You are given a 0-indexed string
sand a dictionary of wordsdictionary. You have to breaksinto one or more non-overlapping substrings such that each substring is present indictionary. There may be some extra characters inswhich are not present in any of the substrings.Return the minimum number of extra characters left over if you break up
soptimally.
You are given an integer array
pricesrepresenting the prices of various chocolates in a store. You are also given a single integermoney, which represents your initial amount of money.You must buy exactly two chocolates in such a way that you still have some non-negative leftover money. You would like to minimize the sum of the prices of the two chocolates you buy.
Return the amount of money you will have leftover after buying the two chocolates. If there is no way for you to buy two chocolates without ending up in debt, return
money. Note that the leftover must be non-negative.