-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3409 from fineanmol/master
Tic Tac Toe in HTML CSS and JAVASCRIPT
- Loading branch information
Showing
177 changed files
with
7,513 additions
and
2,317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Auto-Merge PRs | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
auto_merge: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check PR status | ||
run: | | ||
PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH") | ||
PR_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" | ||
PR_STATE=$(curl -s -H "Authorization: token ${{ secrets.AUTOMERGE_TOKEN }}" $PR_URL | jq -r .state) | ||
if [ "$PR_STATE" = "open" ]; then | ||
echo "PR is still open. Merging..." | ||
curl -s -X PUT -H "Authorization: token ${{ secrets.AUTOMERGE_TOKEN }}" $PR_URL/merge | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: Auto Comment | ||
on: [issues, pull_request] | ||
on: [issues] | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
.git/objects/ | ||
.DS_Store | ||
*.idea* | ||
.github | ||
*.github/ | ||
/.vs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Program's_Contributed_By_Contributors/C++ Programs/2pointer/3sum.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
vector<int> vals={2,6,3,11,7,4,9,7,10,6}; | ||
int target = 20; | ||
|
||
sort(vals.begin(),vals.end()); | ||
for(int i=0;i<vals.size();i++) | ||
{ | ||
int x = vals[i]; | ||
int l = i+1; | ||
int r = vals.size()-1; | ||
while(l<r) | ||
{ | ||
if(x+vals[l]+vals[r]==target) | ||
{ | ||
cout<<"Triplet Found: "<<x<<" "<<vals[l]<<" "<<vals[r]<<endl; | ||
return 0; | ||
} | ||
if(x+vals[l]+vals[r]>target) | ||
{ | ||
r--; | ||
} | ||
else | ||
{ | ||
l++; | ||
} | ||
} | ||
} | ||
|
||
cout<<"No triplet"<<endl; | ||
return 0; | ||
} |
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
Program's_Contributed_By_Contributors/C++ Programs/2pointer/removeduplicate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
vector<int> nums = {1,1,1,2,3,4,4,4,4,5}; | ||
int i = 0, j = 1; | ||
while(j<nums.size()) | ||
{ | ||
if(nums[i]==nums[j]) | ||
j++; | ||
else | ||
{ | ||
i++; | ||
nums[i] = nums[j]; | ||
} | ||
} | ||
for(int k = 0;k<=i;k++) | ||
cout<<nums[k]<<" "; | ||
cout<<endl; | ||
return 0; | ||
} |
41 changes: 41 additions & 0 deletions
41
Program's_Contributed_By_Contributors/C++ Programs/2pointer/traprainwater.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
vector<int> rain = {0,1,0,2,1,0,1,3,2,1,2,1}; | ||
int l = 0; | ||
int r = rain.size() -1; | ||
int leftmax = 0; | ||
int rightmax = 0; | ||
int res = 0; | ||
while(l<=r) | ||
{ | ||
if(rain[l]<=rain[r]) | ||
{ | ||
if(rain[l]>=leftmax) | ||
{ | ||
leftmax = rain[l]; | ||
} | ||
else | ||
{ | ||
res+= leftmax - rain[l]; | ||
} | ||
l++; | ||
} | ||
else | ||
{ | ||
if(rain[r]>=rightmax) | ||
{ | ||
rightmax = rain[r]; | ||
} | ||
else | ||
{ | ||
res+=rightmax - rain[r]; | ||
} | ||
r--; | ||
} | ||
} | ||
cout<<res<<endl; | ||
return 0; | ||
} |
25 changes: 25 additions & 0 deletions
25
Program's_Contributed_By_Contributors/C++ Programs/Array/TargetSum.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <iostream> | ||
#include <vector> | ||
using namespace std; | ||
int findTotalWays(vector<int> arr, int i, int s, int target) | ||
{ | ||
if (s == target && i == arr.size()) | ||
return 1; | ||
if (i >= arr.size()) | ||
return 0; | ||
return findTotalWays(arr, i + 1, s + arr[i], target) | ||
+ findTotalWays(arr, i + 1, s - arr[i], target); | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
vector<int> arr = { 1, 1, 1, 1, 1 }; | ||
|
||
|
||
int target = 3; | ||
|
||
cout << findTotalWays(arr, 0, 0, target) << endl; | ||
|
||
return 0; | ||
} |
26 changes: 26 additions & 0 deletions
26
Program's_Contributed_By_Contributors/C++ Programs/Array/Union_of_two_array.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
void getUnion(int a[], int n, int b[], int m) | ||
{ | ||
set<int> s; | ||
for (int i = 0; i < n; i++) | ||
s.insert(a[i]); | ||
|
||
for (int i = 0; i < m; i++) | ||
s.insert(b[i]); | ||
cout << "Number of elements after union operation: " << s.size() << endl; | ||
cout << "The union set of both arrays is :" << endl; | ||
for (auto itr = s.begin(); itr != s.end(); itr++) | ||
cout << *itr | ||
<< " "; | ||
} | ||
|
||
int main() | ||
{ | ||
int a[9] = { 1, 2, 5, 6, 2, 3, 5, 7, 3 }; | ||
int b[10] = { 2, 4, 5, 6, 8, 9, 4, 6, 5, 4 }; | ||
|
||
getUnion(a, 9, b, 10); | ||
} |
17 changes: 17 additions & 0 deletions
17
Program's_Contributed_By_Contributors/C++ Programs/Array/buyandsell.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
vector<int> price = {7,1,5,3,6,4}; | ||
int mn =INT_MAX; | ||
int profit = 0; | ||
for(int i=0;i<price.size();i++) | ||
{ | ||
mn = min(mn, price[i]); | ||
profit = max(profit, price[i]-mn); | ||
} | ||
cout<<profit<<endl; | ||
|
||
return 0; | ||
} |
57 changes: 57 additions & 0 deletions
57
Program's_Contributed_By_Contributors/C++ Programs/Array/countinversion.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int merge(vector<int>& nums, vector<int>& temp, int low, int mid, int high) | ||
{ | ||
int i,j,k; | ||
int count = 0; | ||
i = low; | ||
j = mid; | ||
k = low; | ||
while(i<=mid-1 and j<=high) | ||
{ | ||
if(nums[i]<=nums[j]) | ||
{ | ||
temp[k++] = nums[i++]; | ||
} | ||
else | ||
{ | ||
temp[k++] = nums[j++]; | ||
count+= mid-i; | ||
} | ||
|
||
} | ||
while(i<mid) | ||
{ | ||
temp[k++]=nums[i++]; | ||
} | ||
while(j<=high) | ||
{ | ||
temp[k++] = nums[j++]; | ||
} | ||
for(int i=low;i<=high;i++) | ||
nums[i]=temp[i]; | ||
return count; | ||
} | ||
|
||
int mergesort(vector<int>& nums, vector<int>& temp, int low, int high) | ||
{ | ||
int mid, count=0; | ||
|
||
if(high>low) | ||
{ | ||
mid = (low+high)/2; | ||
count+=mergesort(nums, temp, low, mid); | ||
count+=mergesort(nums, temp, mid+1, high); | ||
count+=merge(nums, temp, low, mid+1, high); | ||
} | ||
return count; | ||
} | ||
int main() | ||
{ | ||
vector<int> nums = {5,2,3,4,1}; | ||
vector<int> temp(nums.size()); | ||
int ans = mergesort(nums, temp, 0, nums.size()-1); | ||
cout<<ans<<endl; | ||
return 0; | ||
} |
19 changes: 19 additions & 0 deletions
19
Program's_Contributed_By_Contributors/C++ Programs/Array/gridpath.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int m = 5; | ||
int n = 4; | ||
int N = m+n-2; | ||
int r = m-1; | ||
int res = 1; | ||
for(int i=0;i<r;i++) | ||
{ | ||
res*=(N-r+i+1); | ||
res/=(i+1); | ||
|
||
} | ||
cout<<res<<endl; | ||
return 0; | ||
} |
Oops, something went wrong.