1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence
Given a
sentencethat consists of some words separated by a single space, and asearchWord, check ifsearchWordis a prefix of any word insentence.Return the index of the word in
sentence(1-indexed) wheresearchWordis a prefix of this word. IfsearchWordis 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
sis any leading contiguous substring ofs.
3373. Maximize the Number of Target Nodes After Connecting Trees II
There exist two undirected trees with
nandmnodes, labeled from[0, n - 1]and[0, m - 1], respectively.You are given two 2D integer arrays
edges1andedges2of lengthsn - 1andm - 1, respectively, whereedges1[i] = [ai, bi]indicates that there is an edge between nodesaiandbiin the first tree andedges2[i] = [ui, vi]indicates that there is an edge between nodesuiandviin the second tree.Node
uis target to nodevif the number of edges on the path fromutovis even. Note that a node is always target to itself.Return an array of
nintegersanswer, whereanswer[i]is the maximum possible number of nodes that are target to nodeiof 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
nandmnodes, with distinct labels in ranges[0, n - 1]and[0, m - 1], respectively.You are given two 2D integer arrays
edges1andedges2of lengthsn - 1andm - 1, respectively, whereedges1[i] = [ai, bi]indicates that there is an edge between nodesaiandbiin the first tree andedges2[i] = [ui, vi]indicates that there is an edge between nodesuiandviin the second tree. You are also given an integerk.Node
uis target to nodevif the number of edges on the path fromutovis less than or equal tok. Note that a node is always target to itself.Return an array of
nintegersanswer, whereanswer[i]is the maximum possible number of nodes target to nodeiof 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 containsnelements, where exactlyn - 2elements 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
xgreater than or equal ton, such that the binary representation ofxcontains only set bits.A set bit refers to a bit in the binary representation of a number that has a value of
1.