You are given a tree (connected, undirected, acyclic graph) consisting of NN nodes. Based on this tree, you have to answer QQ queries.
Each query is of the form:
- K D V1 V2 ⋯ VKK D V1 V2 ⋯ VK — output the number of pairs (i,j)(i,j), 1≤i
Given an array A1,A2…ANA1,A2…AN, find the minimum number of operations (possibly zero) required to convert all integers in AA to 00.
In one operation, you
- choose a non-negative integer pp (p≥0p≥0),
- select at most KK indices in the array AA, and
- for each selected index…
You are the owner of a big company. You are so rich, that the government has allowed you to print as many notes as you want of any single value that you like. …
Chef and his friend Bharat have decided to play the game “The Chefora Spell”.
In the game, a positive integer NN (in decimal system) is considered a “Chefora” if the number of digits dd is odd and it satisfies the equationN=∑i=0d−1Ni⋅10i,N=∑i=0d−1Ni⋅10i,
where NiNi is the ii-th…
You’re given a tree with NN vertices numbered from 11 to NN. Your goal is to handle QQ queries. For each query you are given KK nodes v1,v2,…,vKv1,v2,…,vK. Find if there exists a simple path in the tree covering all the given vertices.
- The first…
AmazeWiT platform is India’s first single-point platform for all women in tech initiatives. With an endeavor to bridge the women in tech gender diversity gap in the workforce, AmazeWiT brings the champions of the industry together to shape the tech community. …
IBM and its collaborators know what tech and professional skills are critical for the future and have packaged that knowledge specifically for you through Open P-TECH!
IBM Free Courses
- Artificial Intelligence
- Data Science
- Professional Skills
- Design Thinking
There are NN cities in Chefland numbered from 11 to NN and every city has a railway station. Some cities have a train and each city has at most one train originating from it. The trains are represented by an array AA, where Ai=0Ai=0 means the…
Given a tree with NN nodes, answer QQ queries of the following type:
- a,ba,b (where a≠ba≠b) which asks you to calculate ∑Ni=1min(dist(i,a),dist(i,b))∑i=1Nmin(dist(i,a),dist(i,b)) where dist(x,y)dist(x,y) is the number of edges on the shortest path between the nodes xx and yy in the tree.
Note: The input…
There is an inter-city math competition among kk various prestigious top schools in the city. Some subset of schools will be selected to compete, where the ii-th school is selected with probability pi(mod998 244 353)pi(mod998 244 353). The schools are all selected independently from each other…