1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence
Given a
sentence
that consists of some words separated by a single space, and asearchWord
, check ifsearchWord
is a prefix of any word insentence
.Return the index of the word in
sentence
(1-indexed) wheresearchWord
is a prefix of this word. IfsearchWord
is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return-1
.A prefix of a string
s
is any leading contiguous substring ofs
.
3373. Maximize the Number of Target Nodes After Connecting Trees II
There exist two undirected trees with
n
andm
nodes, labeled from[0, n - 1]
and[0, m - 1]
, respectively.You are given two 2D integer arrays
edges1
andedges2
of lengthsn - 1
andm - 1
, respectively, whereedges1[i] = [ai, bi]
indicates that there is an edge between nodesai
andbi
in the first tree andedges2[i] = [ui, vi]
indicates that there is an edge between nodesui
andvi
in the second tree.Node
u
is target to nodev
if the number of edges on the path fromu
tov
is even. Note that a node is always target to itself.Return an array of
n
integersanswer
, whereanswer[i]
is the maximum possible number of nodes that are target to nodei
of the first tree if you had to connect one node from the first tree to another node in the second tree.Note that queries are independent from each other. That is, for every query you will remove the added edge before proceeding to the next query.
3372. Maximize the Number of Target Nodes After Connecting Trees I
There exist two undirected trees with
n
andm
nodes, with distinct labels in ranges[0, n - 1]
and[0, m - 1]
, respectively.You are given two 2D integer arrays
edges1
andedges2
of lengthsn - 1
andm - 1
, respectively, whereedges1[i] = [ai, bi]
indicates that there is an edge between nodesai
andbi
in the first tree andedges2[i] = [ui, vi]
indicates that there is an edge between nodesui
andvi
in the second tree. You are also given an integerk
.Node
u
is target to nodev
if the number of edges on the path fromu
tov
is less than or equal tok
. Note that a node is always target to itself.Return an array of
n
integersanswer
, whereanswer[i]
is the maximum possible number of nodes target to nodei
of the first tree if you have to connect one node from the first tree to another node in the second tree.Note that queries are independent from each other. That is, for every query you will remove the added edge before proceeding to the next query.
3371. Identify the Largest Outlier in an Array
You are given an integer array
nums
. This array containsn
elements, where exactlyn - 2
elements are special numbers. One of the remaining two elements is the sum of these special numbers, and the other is an outlier.An outlier is defined as a number that is neither one of the original special numbers nor the element representing the sum of those numbers.
Note that special numbers, the sum element, and the outlier must have distinct indices, but may share the same value.
Return the largest potential outlier in
nums
.
3370. Smallest Number With All Set Bits
You are given a positive number
n
.Return the smallest number
x
greater than or equal ton
, such that the binary representation ofx
contains only set bits.A set bit refers to a bit in the binary representation of a number that has a value of
1
.