Skip to content
This repository was archived by the owner on Jun 26, 2022. It is now read-only.

Commit b65bb5d

Browse files
Merge branch 'master' into master
2 parents 14c9b72 + 6809107 commit b65bb5d

11 files changed

+460
-22
lines changed

CONTRIBUTORS.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
If you have contributed to this repository, kindly add your username here
44

5-
65
- [SanjayDevtech](https://github.com/SanjayDevTech)
76
- [hritikkhurana10sm](https://github.com/hritikkhurana10sm)
87
- [finalight](https://github.com/finalight)
@@ -14,11 +13,13 @@ If you have contributed to this repository, kindly add your username here
1413
- [afaditya](https://github.com/afaditya)
1514
- [aaishikasb](https://github.com/aaishikasb)
1615
- [sam0hack](https://github.com/sam0hack)
16+
- [shivajipotnuru](https://github.com/shivajipotnuru)
1717
- [albysabu9](https://github.com/albysabu9)
1818
- [Jayant-saksham](https://github.com/Jayant-saksham)
1919
- [Harshit564](https://github.com/Harshit564)
2020
- [sahil9001](https://github.com/sahil9001)
2121
- [southpole01](https://github.com/southpole01)
2222
- [HarshitGupta150](https://github.com/HarshitGupta150)
2323
- [qwertymaden](https://github.com/qwertymaden)
24-
- [mjnorton](https://github.com/mjnorton)
24+
- [mjnorton](https://github.com/mjnorton)
25+
- [gauravkhatri2698](https://github.com/gauravkhatri2698)

README.md

+24-20
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66

77
## Instructions:
88

9-
*Make sure you have a GitHub account. In case you don't have one, you can create your account by visiting https://github.com/ and clicking on ``Sign up`` option at the top right corner.*
10-
9+
_Make sure you have a GitHub account. In case you don't have one, you can create your account by visiting https://github.com/ and clicking on `Sign up` option at the top right corner._
1110

1211
### 1. Star and Fork this Repository
12+
1313
###### You can star and fork this repository on GitHub by navigating at the top of this repository.
1414

1515
GitHub repository URLs will reference both the username associated with the owner of the repository, as well as the repository name. For example, acmbvp is the owner of the Hacktoberfest repository, so the GitHub URL for this project is:
1616

1717
https://github.com/SanjayDevTech/Code-with-love
1818

19-
2019
When you’re on the main page of a repository, you’ll see a button to "Star" and “Fork” the repository on the upper right-hand side of the page, underneath your user icon.
2120

2221
### 2. Clone the Repository
2322

2423
To make your own local copy of the repository you would like to contribute to, let’s first open up a terminal window.
2524

26-
We’ll use the `git clone` command along with the URL that points to your fork of the repository.
25+
We’ll use the `git clone` command along with the URL that points to your fork of the repository.
2726

2827
This URL will be similar to the URL above, except now it will end with `.git.` The URL will look like this:
2928
https://github.com/your-username/Code-with-love.git
@@ -34,60 +33,65 @@ Once we have the URL, we’re ready to clone the repository. To do this, we’ll
3433

3534
`git clone https://github.com/your-username/Code-with-love.git`
3635

37-
3836
### 3. Create a New Branch
3937

4038
To create your branch, from your terminal window, change your directory so that you are working in the directory of the repository. Be sure to use the actual name of the repository (i.e. Code-with-love) to switch into that directory.
4139

42-
##### `cd Code-with-love`
40+
##### `cd Code-with-love`
4341

4442
Now, we’ll create our new branch with the git branch command. Make sure you name it descriptively so that others working on the project understand what you are working on.
4543

4644
##### `git branch new-branch`
4745

4846
Now that our new branch is created, we can switch to make sure that we are working on that branch by using the git checkout command:
4947

50-
##### ` git checkout new-branch `
48+
##### `git checkout new-branch`
5149

5250
Once you enter the git `checkout` command, you will receive the following output:
5351

54-
###### `Output:`
55-
##### `Switched to branch 'new-branch' `
52+
###### `Output:`
53+
54+
##### `Switched to branch 'new-branch' `
5655

56+
##### `code .`
57+
58+
Once you enter this command, the whole code will automatically open in your code editor
5759

5860
At this point, you can now modify existing files or add new files to the project on your own branch.
5961

6062
#### Make Changes Locally
6163

6264
Once you have modified existing files or added new files to the project, you can add them to your local repository, which you can do with the git add command. Let’s add the -A flag to add all changes that we have made:
6365

64-
##### ` git add -A ` or ` git add . `
66+
##### `git add -A` or `git add .`
6567

6668
Next, we’ll want to record the changes that we made to the repository with the git commit command.
6769

68-
*The commit message is an important aspect of your code contribution; it helps the other contributors fully understand the change you have made, why you made it, and how significant it is. Additionally, commit messages provide a historical record of the changes for the project at large, helping future contributors along the way.*
69-
70+
_The commit message is an important aspect of your code contribution; it helps the other contributors fully understand the change you have made, why you made it, and how significant it is. Additionally, commit messages provide a historical record of the changes for the project at large, helping future contributors along the way._
7071

7172
If you have a very short message, you can record that with the -m flag and the message in quotes:
7273

73-
###### ` Example: `
74-
##### ` git commit -m "Updated Readme.md" `
74+
###### `Example:`
75+
76+
##### `git commit -m "Updated Readme.md"`
7577

7678
###### At this point you can use the git push command to push the changes to the current branch of your forked repository:
79+
7780
###### ` Example:`
78-
##### ` git push --set-upstream origin new-branch `
81+
82+
##### `git push --set-upstream origin new-branch`
7983

8084
### 4. Update Local Repository
8185

82-
*While working on a project alongside other contributors, it is important for you to keep your local repository up-to-date with the project as you don’t want to make a pull request for code that will cause conflicts. To keep your local copy of the code base updated, you’ll need to sync changes.*
86+
_While working on a project alongside other contributors, it is important for you to keep your local repository up-to-date with the project as you don’t want to make a pull request for code that will cause conflicts. To keep your local copy of the code base updated, you’ll need to sync changes._
8387

8488
We’ll first go over configuring a remote for the fork, then syncing the fork.
8589

8690
### 5. Configure a Remote for the Fork
8791

8892
Next up, you’ll have to specify a new remote upstream repository for us to sync with the fork. This will be the original repository that you forked from. you’ll have to do this with the git remote add command.
8993

90-
##### ` git remote add upstream https://github.com/your-username/Code-with-love.git `
94+
##### `git remote add upstream https://github.com/your-username/Code-with-love.git`
9195

9296
In this example, // upstream // is the shortname we have supplied for the remote repository since in terms of Git, “upstream” refers to the repository that you cloned from. If you want to add a remote pointer to the repository of a collaborator, you may want to provide that collaborator’s username or a shortened nickname for the shortname.
9397

@@ -96,15 +100,15 @@ In this example, // upstream // is the shortname we have supplied for the remote
96100
Once you have configured a remote that references the upstream and original repository on GitHub, you are ready to sync your fork of the repository to keep it up-to-date.
97101
To sync your fork, from the directory of your local repository in a terminal window, you’ll have to use the // git fetch // command to fetch the branches along with their respective commits from the upstream repository. Since you used the shortname “upstream” to refer to the upstream repository, you’ll have to pass that to the command:
98102

99-
##### ` git fetch upstream `
103+
##### `git fetch upstream`
100104

101105
Switch to the local master branch of our repository:
102106

103-
##### ` git checkout master `
107+
##### `git checkout master`
104108

105109
Now merge any changes that were made in the original repository’s master branch, that you will access through your local upstream/master branch, with your local master branch:
106110

107-
##### ` git merge upstream/master `
111+
##### `git merge upstream/master`
108112

109113
### 7. Create Pull Request
110114

cpp/Unique_Number_III.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*Unique_Number_III
2+
Given an array that contains all elements occurring 3 times, but one occurs only once. Find that unique element.*/
3+
#include <iostream>
4+
using namespace std;
5+
int main()
6+
{
7+
int cnt[64] = {0};
8+
int n, no;
9+
cin >> n;
10+
for (int i = 0; i < n; i++)
11+
{
12+
cin >> no;
13+
14+
int j = 0;
15+
while (no > 0)
16+
{
17+
int last_bit = (no & 1);
18+
cnt[j] += last_bit;
19+
j++;
20+
no = no >> 1;
21+
}
22+
}
23+
int p = 1;
24+
int ans = 0;
25+
for (int i = 0; i < 64; i++)
26+
{
27+
cnt[i] %= 3;
28+
ans += (cnt[i] * p);
29+
p = p << 1;
30+
}
31+
cout << ans << endl;
32+
return 0;
33+
}
34+
/*
35+
Input : arr[] = {6, 2, 5, 2, 2, 6, 6}
36+
Output : 5
37+
Time Complexity:O(n)
38+
*/

cpp/russian_peasant.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*Russian Reasant Algorithm
2+
In this algorithm, two numbers are multiplied without using multiplication operator.
3+
We double the first number and halve the second number repeatedly till the second number doesn’t become 1.
4+
In the process, whenever the second number becomes odd, we add the first number to result.
5+
In the 1800s, Peasants in a remote area of Russia were discovered multiplying numbers using this remarkably unusual process.
6+
*/
7+
8+
#include <iostream>
9+
using namespace std;
10+
int main()
11+
{
12+
int a, b, result = 0;
13+
14+
cout << "Enter two numbers to multiply: \n";
15+
cin >> a >> b;
16+
while (b > 0)
17+
{
18+
if (b % 2 != 0)
19+
{
20+
result += a;
21+
}
22+
a = a << 1;
23+
b = b >> 1;
24+
}
25+
cout << "Product: " << result;
26+
return 0;
27+
}
28+
29+
/*Input:
30+
Enter two numbers to multiply:
31+
4 20
32+
Output:
33+
Product: 80
34+
Time complexity: O(1)
35+
*/

cpp/siddhantmittal02_MergeSort.cpp

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//ALGO FOR MERGE SORT
2+
/*
3+
Declare an array Arr of length N
4+
If N=1, Arr is already sorted
5+
If N>1,
6+
Left = 0, right = N-1
7+
Find middle = (left + right)/2
8+
Call merge_sort(Arr,left,middle) =>sort first half recursively
9+
Call merge_sort(Arr,middle+1,right) => sort second half recursively
10+
Call merge(Arr, left, middle, right) to merge sorted arrays in above steps.
11+
Exit
12+
*/
13+
14+
//CODE
15+
#include <iostream>
16+
using namespace std;
17+
void merge(int *, int, int, int);
18+
void merge_sort(int *arr, int low, int high)
19+
{
20+
int mid;
21+
if (low < high)
22+
{
23+
//divide the array at mid and sort independently using merge sort
24+
mid = (low + high) / 2;
25+
merge_sort(arr, low, mid);
26+
merge_sort(arr, mid + 1, high);
27+
//merge or conquer sorted arrays
28+
merge(arr, low, high, mid);
29+
}
30+
}
31+
// Merge sort
32+
void merge(int *arr, int low, int high, int mid)
33+
{
34+
int i, j, k, c[50];
35+
i = low;
36+
k = low;
37+
j = mid + 1;
38+
while (i <= mid && j <= high)
39+
{
40+
if (arr[i] < arr[j])
41+
{
42+
c[k] = arr[i];
43+
k++;
44+
i++;
45+
}
46+
else
47+
{
48+
c[k] = arr[j];
49+
k++;
50+
j++;
51+
}
52+
}
53+
while (i <= mid)
54+
{
55+
c[k] = arr[i];
56+
k++;
57+
i++;
58+
}
59+
while (j <= high)
60+
{
61+
c[k] = arr[j];
62+
k++;
63+
j++;
64+
}
65+
for (i = low; i < k; i++)
66+
{
67+
arr[i] = c[i];
68+
}
69+
}
70+
// read input array and call mergesort
71+
int main()
72+
{
73+
int myarray[30], num;
74+
cout << "Enter number of elements to be sorted:";
75+
cin >> num;
76+
cout << "Enter " << num << " elements to be sorted:";
77+
for (int i = 0; i < num; i++)
78+
{
79+
cin >> myarray[i];
80+
}
81+
merge_sort(myarray, 0, num - 1);
82+
cout << "Sorted array\n";
83+
for (int i = 0; i < num; i++)
84+
{
85+
cout << myarray[i] << "\t";
86+
}
87+
}

html/Kshitij9896_HelloWorld.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Hello World</title>
5+
</head>
6+
<body>
7+
<h1>Simple HTML Program</h1>
8+
<h1>Hello World</h1>
9+
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)