Skip to content

Latest commit

 

History

History
100 lines (74 loc) · 3.42 KB

Contributing.md

File metadata and controls

100 lines (74 loc) · 3.42 KB

Contribution Guidelines

Table of Contents

Adding your solution to the repository by creating A Pull Request

If you want to add something awesome to contribute to the repository, this is how you do it.

You'll need a GitHub account!

  1. Go to given file where you could see the problem.
  2. See the constraints, input and output formats of the problem and write your function accordingly. (Would help you to write a clean code.)
  3. Run your solution on local machines and check for some test cases.
  4. Click on create new file in that folder only.
  5. Copy your code there and with SolutionByA.cpp [ A would be Your Name - Like SolutionByShoaib.cpp ]
  6. After copying, click on propose new file.[ At the Bottom]
  7. Then You'd be redirected to new page, where you need to click on create pull request.
  8. Add your comments or anything you want to tell abour you solution.
  9. Then Click on create pull request and write one line description in box above the button.
  10. Your solution is pushed in the repository.
  11. If you want to add a new problem, then add a readMe.md together to explain the problem and choose appropriate sections such as Dynamaic Programming, Greedy Algorithms, Data Structure, etc to push your readMe and solution file. For example - If you are adding Tim Sort solution, go to Array or Vector folder inside Data Structure Section and then create a folder Tim Sort and then add both of your files there.

Updating your Pull Request

Sometimes, Your pull request needs some modifications before merging it to the repository. This is normally due to wrong file extension or because your PR fails.

Sample Code

  1. A working and neat Program should be pushed.
  2. The variable names and function names should be related to its purpose.
  3. Write your programs in the form of function(s)
  4. The program should be indented.
  5. You should push the solution to the mentioned file. Here's a code you need to see before writing your code.

How to write a Function in Cpp

    /*
        Example to write code on the given file.
        LCS of Two String
    */
    
int Calculate_LCS_Length_Using_DP( string firstString, string secondString )  { 

   long sizeOfFirstString = firstString.length();
   long sizeOfSecondString = secondString.length();
   
   int Table[sizeOfFirstString + 1 ][sizeOfSecondString + 1 ]; 
   
   for (int i = 0; i <= sizeOfFirstString; i++ ) { 
   
     for (int j = 0; j <= sizeOfSecondString; j++ ) { 
     
       if (i == 0 || j == 0) {
         Table[i][j] = 0; 
       }
       
       else if ( firstString[i-1] == secondString[j-1] ) {
         Table[i][j] = Table[i-1][j-1] + 1;
       }
   
       else {
         Table[i][j] = max( Table[i-1][j] , Table[i][j-1] ); 
       }
       
     } 
     
   } 
   
   return Table[sizeOfFirstString][sizeOfSecondString]; 
}
    /*
        to check any constraints or to decide anything : Always use bool
    */
bool check() {
    if (condions satisfies) {
        return true;
    }
    else {
        return false;
    }
}