🌐
HackerRank
hackerrank.com › contests › world-codesprint-13 › challenges › group-formation
Group Formation | World CodeSprint 13 Question | Contests
Find the largest group after possibly granting some requests. Solving code challenges on HackerRank is one of the best ways to prepare for programming interviews.
🌐
GitHub
github.com › srgnk › HackerRank
GitHub - srgnk/HackerRank: Solutions to HackerRank problems · GitHub
Solutions to HackerRank problems. Contribute to srgnk/HackerRank development by creating an account on GitHub.
Starred by 457 users
Forked by 223 users
Languages   Python 85.2% | C 7.8% | C++ 5.4% | Shell 1.6%
🌐
GitHub
github.com › cstrouse › hackerrank › blob › master › division.py
hackerrank/division.py at master · cstrouse/hackerrank
from __future__ import division · · # https://www.hackerrank.com/challenges/python-division · · a = int(raw_input()) b = int(raw_input()) · print a // b ·
Author   cstrouse
🌐
GeeksforGeeks
geeksforgeeks.org › dsa › count-the-number-of-ways-to-divide-n-in-k-groups-incrementally
Count the number of ways to divide N in k groups incrementally - GeeksforGeeks
July 12, 2025 - Initialize a 2-D array dp[][] of size n+1, k+1 where dp[i][j] will store the optimal solution to divide n into k groups.
🌐
HackerRank
hackerrank.com › challenges › python-division › forum
Python: Division Discussions | Python | HackerRank
Please Login in order to post a comment · if name == 'main': a = int(input()) b = int(input()) print((a//b)) print((a/b))
🌐
HackerRank
hackerrank.com › challenges › kingdom-division › forum
Kingdom Division Discussions | Algorithms | HackerRank
Recursive solution doesn't work on Python because of the maximum recursion limit (e.g. Test 11 has a tree with 72000 depth). sys.setrecursionlimit(100000) doesn't work because Python still crashes at ~2670 level of recursion. What works: using Kahn's algorithm to iteratively go from the leaves to the root.
🌐
LeetCode
leetcode.com › discuss › interview-question › 533794 › create-k-group-using-n-members
Create k group using n members - Discuss - LeetCode
March 9, 2020 - You need to create k group using n members. The number of members in ith group should be more than or equal to the members in (i-1)th group. For example 8 members and 4 groups.
🌐
GitHub
github.com › cassiopagnoncelli › hacker-rank-solutions › blob › master › python-division.py
hacker-rank-solutions/python-division.py at master · cassiopagnoncelli/hacker-rank-solutions
May 26, 2024 - Solutions to hackerrank.com programming challenges. - hacker-rank-solutions/python-division.py at master · cassiopagnoncelli/hacker-rank-solutions
Author   cassiopagnoncelli
Find elsewhere
🌐
Seuhkaa
app.seuhkaa.org › 9oatf › 1rh7u.php
Group division hackerrank solution github
We can group submissions with full score by hacker_id and name, and select hackers whose total number of challenges with full score is larger than 1. First, the spaces are removed from the text. groups() A gro The first line should contain integer division, // . You are viewing a single comment's ...
🌐
Blogger
allhackerranksolutions.blogspot.com › 2016 › 07 › python-division-hacker-rank-solution.html
Python: Division - Hacker Rank Solution - Hacker Rank Solutions
July 21, 2016 - Task Read two integers and print two lines. The first line should contain integer division, // .
🌐
HackerRank
hackerrank.com › challenges › team-formation › problem
Team Formation | HackerRank
For the first case, Roy can form two teams: one with contestants with skill levels {-4,-3,-5} and the other one with {4,5,2,3}. The first group containing 3 members is the smallest.
🌐
Martin Kysel
martinkysel.com › hackerrank-solutions
HackerRank Solutions - Martin Kysel
February 24, 2015 - Over the course of the next few (actually many) days, I will be posting the solutions to previous Hacker Rank challenges. The page is a good start for people to solve these problems as the time constraints are rather forgiving. The majority of the solutions are in Python 2. Some are in C++, Rust and GoLang. My public HackerRank profile here.
Top answer
1 of 1
3

First of all, big O notation gives us an idea about the relation between two functions t(n)/i(n) when n -> infinity. To be more specific, it's an upper bound for such relation, which means it's f(n) >= t(n)/i(n). t(n) stands for the speed of growth of time spent on execution, i(n) describes the speed of growth of input. In function space (we work with functions there rather than with numbers and treat functions almost like numbers: we can divide or compare them, for example) the relation between two elements is also a function. Hence, t(n)/i(n) is a function.

Secondly, there are two methods of determining bounds for that relation.

The scientific observational approach implies the next steps. Let's see how much time it takes to execute an algorithm with 10 pieces of input. Then let's increase the input up to 100 pieces, and then up to 1000 and so on. The speed of growth of input i(n) is exponential (10^1, 10^2, 10^3, ...). Suppose, we get the exponential speed of growth of time as well (10^1 sec, 10^2 sec, 10^3 sec, ... respectively).

That means t(n)/i(n) = exp(n)/exp(n) = 1, n -> infinity (for the scientific purity sake, we can divide and compare functions only when n -> infinity, it doesn't mean anything for the practicality of the method though). We can say at least (remember it's an upper bound) the execution time of our algorithm doesn't grow faster than its input does. We might have got, say, the quadratic exponential speed of growth of time. In that case t(n)/i(n) = exp^2(n)/exp(n) = a^2n/a^n = exp(n), a > 1, n -> infinity, which means our time complexity is O(exp(n)), big O notation only reminds us that it's not a tight bound. Also, it's worth pointing out that it doesn't matter which speed of growth of input we choose. We might have wanted to increase our input linearly. Then t(n)/i(n) = exp(n)*n/n = exp(n) would express the same as t(n)/i(n) = exp^2(n)/exp(n) = a^2n/a^n = exp(n), a > 1. What matters here is the quotient.

The second approach is theoretical and mostly used in the analysis of relatively obvious cases. Say, we have a piece of code from the example:

// DP Table 
static int [][][]dp = new int[500][500][500]; 
   
// Function to count the number 
// of ways to divide the number N 
// in groups such that each group 
// has K number of elements 
static int calculate(int pos, int prev,  
                 int left, int k) 
{ 
    // Base Case 
    if (pos == k)  
    { 
        if (left == 0) 
            return 1; 
        else
            return 0; 
    } 
    
    // if N is divides completely  
    // into less than k groups 
    if (left == 0) 
        return 0; 
   
    // If the subproblem has been 
    // solved, use the value 
    if (dp[pos][prev][left] != -1) 
        return dp[pos][prev][left]; 
   
    int answer = 0; 
    
    // put all possible values  
    // greater equal to prev 
    for (int i = prev; i <= left; i++)  
    { 
        answer += calculate(pos + 1, i,  
                           left - i, k); 
    } 
   
    return dp[pos][prev][left] = answer; 
} 

// Function to count the number of  
// ways to divide the number N in groups 
static int countWaystoDivide(int n, int k) 
{ 
    // Intialize DP Table as -1 
        for (int i = 0; i < 500; i++)  
        { 
            for (int j = 0; j < 500; j++) 
            { 
                for (int l = 0; l < 500; l++) 
                    dp[i][j][l] = -1; 
            } 
        } 
   
    return calculate(0, 1, n, k); 
} 

The first thing to notice here is a 3-d array dp. It gives us a hint of the time complexity of a DP algorithm because usually, we traverse it once. Then we are concerned about the size of the array. It's initialized with the size 500*500*500 which doesn't give us a lot because 500 is a number, not a function, and it doesn't depend on the input variables, strictly speaking. It's done for the sake of simplicity though. Effectively, the dp has size of k*n*n with assumption that k <= 500 and n <= 500.

Let's prove it. Method static int calculate(int pos, int prev, int left, int k) has three actual variables pos, prev and left when k remains constant. The range of pos is 0 to k because it starts from 0 here return calculate(0, 1, n, k); and the base case is if (pos == k), the range of prev is 1 to left because it starts from 1 and iterates through up to left here for (int i = prev; i <= left; i++) and finally the range of left is n to 0 because it starts from n here return calculate(0, 1, n, k); and iterates through down to 0 here for (int i = prev; i <= left; i++). To recap, the number of possible combinations of pos, prev and left is simply their product k*n*n.

The second thing is to prove that each range of pos, prev and left is traversed only once. From the code, it can be determined by analysing this block:

for (int i = prev; i <= left; i++)  
{ 
    answer += calculate(pos + 1, i,  
                       left - i, k); 
}

All the 3 variables get changed only here. pos grows from 0 by adding 1 on each step. On each particular value of pos, prev gets changed by adding 1 from prev up to left, on each particular combination of values of pos and prev, left gets changed by subtracting i, which has the range prev to left, from left.

The idea behind this approach is once we iterate over an input variable by some rule, we get corresponding time complexity. We could iterate over a variable stepping on elements by decreasing the range by twice on each step, for example. In that case, we would get logarithmical complexity. Or we could step on every element of the input, then we would get linear complexity.

In other words, we without any doubts assume the minimum time complexity t(n)/i(n) = 1 for every algorithm from common sense. Meaning that t(n) and i(n) grow equally fast. That also means we do nothing with the input. Once we do something with the input, t(n) becomes f(n) times bigger than i(n). By the logic shown in the previous lines, we need to estimate f(n).

🌐
Blogger
codeworld19.blogspot.com › home › hackerrank › hackerrank python
Python: Division - Hacker Rank Solution - CodeWorld19
April 9, 2021 - The first line should contain integer division, a//b . The second line should contain float division, a/b. You don't need to perform any rounding or formatting operations. The first line contains the first integer, a. The second line contains the second integer, b. Print the two lines as described above. ... the above hole problem statement is given by hackerrank.com but the solution is generated by the codeworld19 authority if any of the query regarding this post or website fill the following contact form thank you.
🌐
Stupidtechy
stupidtechy.me › threads › group-division-java-hackerrank-solution.200
Loading...
November 19, 2021 - We cannot provide a description for this page right now
🌐
Blogger
codeworld19.blogspot.com › home › hackerrank › hackerrank python
Group() Groups() Groupdict() in Python - HackerRank Solution - CodeWorld19
April 9, 2021 - Re.start() & Re.end() in Python - HackerRank Solution · Re.findall() & Re.finditer() in Python - HackerRan... Group() Groups() Groupdict() in Python - HackerRan...
🌐
GitHub
gist.github.com › meet100ni › 5dd3525792b66e91ea9c1f43c79f68e4
Python: Division HackerRank Solution · GitHub
Python: Division HackerRank Solution . GitHub Gist: instantly share code, notes, and snippets.
🌐
HackerEarth
hackerearth.com › problem › algorithm › hp-and-counting-number-of-ways-1-2808c854
Two Groups | Practice Problems
Prepare for your technical interviews by solving questions that are asked in interviews of various companies. HackerEarth is a global hub of 5M+ developers. We help companies accurately assess, interview, and hire top developers for a myriad of roles.