How to solve following problem using segment trees?

See the following link for better understanding of problem. In brief suppose i have given an array of size n corresponding to permutation of $ [1,2,3 …… n]$ , whose $ ith$ element (say $ s_i$ ) is sum of all $ p_j$ such that $ j<i$ and $ p_j < p_i$ .

How to solve this problem using segment trees in O($ nlogn$ ) (We can solve this in O(n$ ^2$ ) by brute force).

I tried to understand the solution but i failed .Thus asking for help (I tried for 1 whole day)

Solve SUBSET SUM for Reciprocals of Primes

Let $ p_1, …, p_n$ distinct prime numbers with $ P = \prod_{i=1}^{n}{p_i}$ and $ A=(a_1, …, a_n)$ with $ a_i = P/p_i$ .

Problem

Show the SUBSET SUM problem $ (A, \alpha)$ can be solved in polynomial (not pseudo-polynomial) time for every $ \alpha \in \mathbb{N}$ and $ P, p_1, … , p_n$ unknown.

First attempts

$ P$ and $ p_1, … p_n$ can be calculated with $ P = \sqrt[n-1]{\prod_{i=1}^{n}{a_i}}$ and $ p_i = P / a_i$ .

Now we can write the problem as $ \alpha/P = 1/p_{i_1} + … + 1/p_{i_n}$

How to solve Application is not registered in our store. error while using GRAPH API for making a call?

I am trying to make a call in one of the channels in MS Teams via Postman.

I followed all the steps mentioned in the below article. I have also given all the required permission.

Create Call to Teams using GRAPH API – BETA

I am able to successfully retrieve other beta APIs but with /beta/app/calls I am getting the Application is not registered in our store error.

Initially, I got Unsupported AAD Identity error but, that I solved as per the steps mentioned in the below reference.

Solve Unsupported AAD Identity Error

Note: I tried to make the call from SPFx web part but over there also I am getting the same error.

My main goal is to make a call to channel of the team and all the members should get the notification for the same. (Same as meet now button’s functionality in teams app)

Any help will be appreciated. Thanks in advance.

Tell Me any website related problem and i’ll try to solve that for free

Hello Members, I'm here to help you. If you have any problem, questions and errors related to your website then feel free to write here and i'll try to solve your issue without taking any penny but before we go ahead you need to trust on me.

Little About me: I'm a programmer who likes to make new apps, Software and websites. I have knowledge of PHP, MySQL, HTML5, CSS3, Bootstrap, JavaScript, jQuery.

How do I solve these questions regarding homomorphism?

enter image description here Questions:

  1. Give an example of a homomorphism, using the same alphabet, Σ, for both languages A and B.
  2. Now, give a second example of a homomorphism but this time using two different alphabets, Σ and Γ, for languages A and B, respectively.

Questions to stack overflow:

  • How do I give the examples above? Do I make the state diagrams? Do I show it through the tuple-definition?
  • What are some examples of the questions above?

Idea behind using binary search to solve rolling ball?

What is the idea behind using binary search to solve this problem:

There is a segment of length meters, and there are $ L$ positions on it, numbered $ 1,2,…L$ , equally spaced by 1 meter apart each, in the given order. There are $ n$ balls on it, at positions $ s1, s2,…s_n$ . Each ball is either rolling to the left of to the right at the speed of 1 meter/second. Whenever two balls hit each other, both of them change direction instantly but keep the same speed. A ball also changes direction when it reaches one of the ends of the segment (position $ 1$ or $ L$ ). You are given $ q$ queries, each one gives you two numbers $ t_i$ and $ p_i$ , and you should output the position of the $ p_i$ -th ball after $ t_i$ second.

https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/rolling-balls-b8923a50/

My solution moves the ball after every second and does not use binary search:

for query in range(q):   for ti, pi in array_ti_pi:      ti = ti % (2 * L - 1)      for i in range(n):         if dir[i] == 0:             balls_pos[i] = balls_pos[i] - ti         else:             balls_pos[i] = balls_pos[i] + ti      for i in range(n):         if balls_pos[i] < 1:             balls_pos[i] = 2 - balls_pos[i]         elif balls[i] > L:             balls_pos[i] = 2 * L - balls_pos[i] 

How to solve following tree problem with number assigned to each node?

I have a tree whose nodes have numbers assigned to them initially. A series of $ Q$ queries are asked from $ n=0$ to $ n=Q-1$ seconds. During end of each second numbers on a node (which are not leaf) are removed and gets transferred to each direct child node. Numbers on leaf node remain as it is and number coming from parent gets added to them. At each query it is possible that new number is added to a node. How to solve this efficiently?

Example: Suppose I have a tree 1—–2——3——-4 (1 is parent). Suppose at beginning numbers on nodes are 1, 2, 3, 4 respectively. Then at…

At zero second end 5 is added to node zero. At end of 0 seconds numbers on node are 5, 1, 2, 7. (Note 1 is not added to 5 because it is removed).

At one second end, 1 is added to node 4, then numbers are 0, 5, 1, 10. Fourth node has number 10 since it received 2 from parent node and 1 is added and 7 was present on it.

Now suppose at two second end, I am asked to tell number on 2nd node?Answer is 0.

I mean that in each query either a number can be added on a node or a question can be asked like – what is number on $ ith$ node?
How to solve this in less than $ O(nQ)$ . Where $ n$ is number of nodes and $ Q$ is number of queries?