Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Kendrick Ledet
    New update dropping next week ;)
    Fully integrated Github user accounts, implementation commenting, maintainer pages and general bug fixes/improvements
    Jon-Pierre Sanchez
    Hey guys can someone help me out ? For the below algorithm can you tell me why the Big O runtime is O(n2n^2) ? I'm think that the last block where there is three nested for loops would make it O(n3n^3)
    n = 1000
    for c from 1 to n
       for d from 1 to n
         result c^3 + d^3
         append (c, d) to list at value map[result]
    for each result, list in map
       for each pair1 in list
         for each pair2 in list
           print pair1, pair2
    @jsanchez034: the map you populate in the first two nested loops is essentially a dictionary (i.e., a hash of key / value pairs) where the keys are c^3 + d^3 (with an integer co-domain) and the values are list of (c, d) tuples. Because those keys are just integers, it's safe to assume that the map can compute a hash code for those keys in constant time, O(1) (hence, why the "result, key" lookup performed by that outermost "for each result, list in ..." loop preserves the overall O(n^2) complexity of that "for each pair1 ... for each pair2 ... etc"
    Saurabh Vyas
    guys I am really stuck on matrix chain multiplication recursive implementation using c++ my code works for only some i's and j's and not all of them
    using namespace std;
    #include <iostream>
    #include <stdio.h>
    #include <algorithm>
    // this is the most basic recursive version implementation
    int minimum =999999999 ;
    int param1 ;
    int param2 ;
    int param3;
    int matrix_chain(int p[] , int i , int j) {
    // minimum =p[0]*p[1];
     if (i == j) {
            cout << "m[" << i << "," << j << "] = " << 0 << "\n";
        return 0;
              for (int k=i; k<j; k++)  {
    param1= matrix_chain(p,i,k);
    param2= matrix_chain(p,k+1,j);
     param3 = p[i-1] * p[k]  * p[j];
      cout << (param1+param2+param3) << "\n";
    //cout << "param3 : " << p[i-1] * p[j-1] << "\n";
    //cout << "p[k] : "  << p[k] << "\n";
        if ((param1+param2+param3) < minimum) {
            minimum = (param1+param2+param3);
            cout << "minimum : "  << minimum;
    cout << "m[" << i << "," << j << "] = " << minimum << "\n";
     return minimum;
    int main() {
    int p[]={30,35,15,5,10,20,25};
    cout << "answer : " << matrix_chain(p,1,4);
    // cout << cut_rod(arr,18) ;
     // cout << memoized_cut_rod(arr,10);
    // cout << bottom_cut_rod(arr,9);
    // print_cut_rod_solution(arr,7);
    return 0;
    Praveendra Singh

    seems like Kennyledet is not active and most of the PRs are still on hold.
    I'm maintaining the fork at Please do send the PRs to this fork.

    lets continue with the mission Kennyledet started with.

    Pankaja Gamage
    hi i was wondering what would be the best algorithm to use for path finding in a squre grid
    in terms of the the cost for the algorithm to run and implementation
    @PankajaGamage_twitter if your square grid is small, then recursive implementation with dp would be a good choice or else some more advancement would be needed
    Hi! So I'm gonna implement simplex algorithm I take from here for my open source project (MIT licensed). I was wondering if it's okay to take the code from this repo? Can't see any license here so I figured I should ask. Someone is ought to know hopefully.
    Oh I see @pravsingh 's repo is MIT licensed. I should just take it from there if it's okay for you Praveendra. I'll make the open source as well once it's finished hopefullyl.
    Ullas T V
    can anyone help me to implement HashMap function in java ?
    Jay Ma
    ['as', '10h', '9d', 'qc', '3h'] here is an array for cards, and how to use shortest code to detect if it is straight in php? anyone can help plz?
    How to Change the Algorithm of the Ethereum ? Any tutorials and Guide to be use. hard fork has a different algorithm from ethereum (I want the miners to use our software not other, you can send me a list of algorithms and your opinion that would be the best)
    Oleksii Trekhleb
    Hello Everyone,
    I've recently launched JavaScript Algorithms and Data Structures repository on GitHub - . This repository contains examples, explanations and links for further readings about some classic algorithms and data structures. I hope it might be interesting and useful for someone in this chat.
    Mohamed Akidh
    Hey guys anybody have idea on this....?? 3.1 Design suitable algorithms for vehicle tariff calculation for rents and hires
    Nick Anthony
    Hey there :D I have a little question. I have this algorithm in c++ And I have an Input file and an output file. I can process all testcaeses from 0 - 97, but get stuck at 98 and 99. Can you help me optimize the code ? xD I think the problem is in the for loops, but don't know how to solve it. Thanks in advance.
    hi, I am practising algorithm of Mars Rover that is confined to a plane and it can move only forward, rotate clockwise and rotate anticlockwise. Rover movements is to be saved in a output text file. I am implementing this in a functional programming language. Can you throw some light on how to implement rotate by some degrees(Say 45 or 90 degrees) pls?

    A String is called a palindrome if it can be read the same way in either direction For example, "malayalam" is a palindrome, but "tamil" is not

    There are S students in a class. Some of them are fiends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B and B is a direct friend of C, then A is an indirect friend of C.

    A "social circle" is a group of students who are direct or indirect friends.

    You are given a S*S matrix M (S is the number of students) representing the friend relationship between students in the class. if M[i][j] = 1, then the ith and jth students are direct friend with eachother, otherwise not.

    Your task is to return the string, representing all the social circles separated by pipe(i) among all the students. Individual members within circle should be seprated by a comma(,)

    Write a function

    function solution(s);
    that given a zero-indexed double-dimensional array A of dimensions S*S (in string format to be converted to a 2-dimensional array), returns a string representing pipe-separated (|) social circles of comma-separated friends.

    The function should return "0,1|2" (qutoes for representation purpose only)

    The 0th and 1st students are direct friends (M[0][1]) = 1 and subsequently M[1][0] = 1), so they are in a social circle.

    The 2nd student is in her/his own social circle. So return 2.

    For another example, given:

    M = "[
    the function should return "0,1,2"

    The 0th and 1st students are direct friends, the 1st and 2nd students are direct friends. Thus, the 0th and 2nd are indirect friends. All of them are ub tge sine sociak curckes si retyrb 1.

    You can assume that:

    for every i within the range [0.. N - 1] M[i][i] = 1
    In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment
    js solution quickly