Skip to main content

Featured

Adobe Experience Manager - Create an OSGI Configuration

 In this article, let's create an OSGi configuration, configure it and use it in AEM code. So now let's get started with the creation of an OSGi configuration. Technical details and Assumptions: All the following details are tested in AEM version 6.5.8, Java version 11.0.2 Creation of OSGi configuration: To create an OSGi configuration we need to create an ObjectClassDefinition. I have included a sample OCD configuration, which can be used as a reference to create one. The next step would be to create an interface and an implementation that can help fetch the OSGi configurations.  Interface: Implementation: Let's try to use the OSGi configuration created so far in Models/Servlets. For demonstration purposes, I used AEM Models here, but the same can be implemented in Servlets too. Now that we have created the OSGi configuration. Once building the code, we should be able to see the OSGi configuration in the web console (http://localhost:4502/system/console/configMgr) Configur

Equal Chocolates

Christy is interning at HackerRank. One day she has to distribute some chocolates to her colleagues. She is biased towards her friends and plans to give them more than the others. One of the program managers hears of this and tells her to make sure everyone gets the same number.
To make things difficult, she must equalize the number of chocolates in a series of operations. For each operation, she can give  chocolates to all but one colleague. Everyone who gets chocolate in a round receives the same number of pieces.
For example, assume the starting distribution is . She can give  bars to the first two and the distribution will be . On the next round, she gives the same two  bar each, and everyone has the same number:.
Given a starting distribution, calculate the minimum number of operations needed so that every colleague has the same number of chocolates. 
Input Format
The first line contains an integer , the number of testcases.
Each testcase has  lines. 
- The first line contains an integer , the number of colleagues. 
- The second line contains n space-separated integers denoting the number of chocolates each colleague has.
Constraints
 
 
Number of initial chocolates each colleague has < 
Output Format
Print the minimum number of operations needed for each test case, one to a line.
Sample Input
1
4
2 2 3 7
Sample Output
2
Explanation
Start with  
Add  to all but the 3rd element  
Add  to all but the 4th element 
Two operations were required.
Sample Input 1
1
3
10 7 12
Sample Output 1
2
Explanation 1
Start with  
Add  to the first two elements  
Add  to the last two elements 
Two operations were required.

Comments

Popular Posts