-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Thanks to Mukul And Rajat | ||
Thanks to Mukul And Rajat. Your video is still helpful in 2021 | ||
Thanks to Mukul And Rajat. | ||
Thanks to Mukul And Rajat. Your video is still helpful in 2021. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import './covid.css' | ||
const Covid = () => { | ||
const [data, setData] = useState([]); | ||
const getCovidData = async () => { | ||
try { | ||
const res = await fetch('https://data.covid19india.org/data.json'); | ||
const actualData = await res.json(); | ||
console.log(actualData.statewise[0]); | ||
setData(actualData.statewise[0]); | ||
} catch(err){ | ||
console.log(err); | ||
} | ||
} | ||
|
||
useEffect(() =>{ | ||
getCovidData(); | ||
}, []); | ||
return ( | ||
<> | ||
<section> | ||
<h1>🔴 LIVE COVID-19 </h1> | ||
<h2> COVID-19 TRACKER DETAIL </h2> | ||
<ul> | ||
<li className="card 1"> | ||
<div className="card__main"> | ||
<div className="card__inner"> | ||
<p className="card__name"><span>OUR </span>COUNTRY</p> | ||
<p className="card__total card__small"></p>INDIA</div> | ||
</div> | ||
</li> | ||
<li className="card 2"> | ||
<div className="card__main"> | ||
<div className="card__inner"> | ||
<p className="card__name"><span>TOTAL </span>RECOVERED</p> | ||
<p className="card__total card__small"></p>{data.recovered}</div> | ||
</div> | ||
</li><li className="card 3"> | ||
<div className="card__main"> | ||
<div className="card__inner"> | ||
<p className="card__name"><span>TOATL </span>CONFIRMED</p> | ||
<p className="card__total card__small"></p>{data.confirmed}</div> | ||
</div> | ||
</li><li className="card 4"> | ||
<div className="card__main"> | ||
<div className="card__inner"> | ||
<p className="card__name"><span>TOATL </span>DEATHS</p> | ||
<p className="card__total card__small"></p>{data.deaths}</div> | ||
</div> | ||
</li><li className="card 5"> | ||
<div className="card__main"> | ||
<div className="card__inner"> | ||
<p className="card__name"><span>TOATL </span>ACTIVE</p> | ||
<p className="card__total card__small"></p>{data.active}</div> | ||
</div> | ||
</li><li className="card 6"> | ||
<div className="card__main"> | ||
<div className="card__inner"> | ||
<p className="card__name"><span>LAST </span>UPDATED</p> | ||
<p className="card__total card__small"></p>{data.lastupdatedtime}</div> | ||
</div> | ||
</li> | ||
</ul> | ||
</section> | ||
</> | ||
) | ||
} | ||
export default Covid |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
def knapsack(W, wt, val, n): | ||
|
||
dp = [[-1 for x in range(W + 1)] for y in range(n + 1)] | ||
for x in range(n + 1): | ||
for y in range(W + 1): | ||
if x == 0 or y == 0: | ||
dp[x][y] = 0 | ||
|
||
for x in range(1, n + 1): | ||
for y in range(1, W + 1): | ||
if wt[x - 1] <= y: | ||
dp[x][y] = max(val[x - 1] + dp[x - 1][y - wt[x - 1]], dp[x - 1][y]) | ||
else: | ||
dp[x][y] = dp[x - 1][y] | ||
return dp[-1][-1] | ||
|
||
n = 3 | ||
W = 4 | ||
wt = [4, 5, 1] | ||
val = [1, 2, 3] | ||
print(knapsack(W, wt, val, n)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def knapSack(self,W, wt, val, n): | ||
def knapsack(W, wt, val, n, memo = {}): | ||
if (n, W) in memo: | ||
return memo[(n, W)] | ||
|
||
if n == 0 or W == 0: | ||
return 0 | ||
|
||
elif wt[n - 1] <= W: | ||
memo[(n, W)] = max(val[n - 1] + knapsack(W - wt[n - 1], wt, val, n - 1, memo), knapsack(W, wt, val, n - 1, memo)) | ||
return memo[(n, W)] | ||
|
||
else: | ||
memo[(n, W)] = knapsack(W, wt, val, n - 1, memo) | ||
return memo[(n, W)] | ||
|
||
return knapsack(W, wt, val, n) | ||
|
||
N = 3 | ||
W = 3 | ||
values = [1,2,3] | ||
weight = [4,5,6] | ||
print(knapSack(W, weight, values, N)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
def knapsack(W, wt, val, n, memo): | ||
if memo[n][W] != -1: | ||
return memo[n][W] | ||
|
||
if n == 0 or W == 0: | ||
return 0 | ||
|
||
if wt[n - 1] <= W: | ||
temp = max(val[n - 1] + knapsack(W - wt[n - 1], wt, val, n - 1, memo), | ||
knapsack(W, wt, val, n - 1, memo)) | ||
memo[n][W] = temp | ||
return temp | ||
|
||
else: | ||
temp = knapsack(W, wt, val, n - 1, memo) | ||
memo[n][W] = temp | ||
return temp | ||
|
||
n = 3 | ||
W = 4 | ||
wt = [4, 5, 1] | ||
val = [1, 2, 3] | ||
memo = [[-1 for x in range(W + 1)] for y in range(n + 1)] | ||
print(knapsack(W, wt, val, n, memo)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def knapSack(W, wt, val, n): | ||
if n == 0 or W == 0: | ||
return 0 | ||
|
||
if wt[n - 1] <= W: | ||
return max(val[n - 1] + knapSack(W - wt[n - 1], wt, val, n - 1), | ||
knapSack(W, wt, val, n - 1)) | ||
|
||
else: | ||
return knapSack(W, wt, val, n - 1) | ||
|
||
n = 3 | ||
W = 4 | ||
wt = [4, 5, 1] | ||
val = [1, 2, 3] | ||
print(knapSack(W, wt, val, n)) |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <iostream> | ||
#include<string> | ||
#include<cstdio> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int len=8; | ||
char bin[len],one[len],two[len]; | ||
cout<<"Enter the Binary Number:"; | ||
gets(bin); | ||
int flag =0; | ||
for(int i=0;i<len;i++)//one's compliment | ||
{ | ||
if(bin[i]=='1') | ||
{ | ||
one[i]='0'; | ||
} | ||
else if(bin[i]=='0') | ||
{ | ||
one[i]='1'; | ||
} | ||
else | ||
{ | ||
cout<<"Invalid Binary Digits"; | ||
flag=1; | ||
return 0; | ||
} | ||
} | ||
int carry=1; | ||
for(int i=len-1;i>=0;i--)//two's compliment | ||
{ | ||
if(one[i]=='1' && carry==1) | ||
{ | ||
two[i]='0'; | ||
} | ||
else if(one[i]=='0' && carry==1) | ||
{ | ||
two[i]='1'; | ||
carry=0; | ||
} | ||
else | ||
{ | ||
two[i]=one[i]; | ||
} | ||
} | ||
if(flag==0) | ||
{ | ||
cout<<"Binary number is:"<<bin<<endl; | ||
cout<<"1's Compliment of the number is:"<<one<<endl; | ||
cout<<"2's Compliment of the number is:"<<two<<endl; | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Solution { | ||
public: | ||
int romanToInt(string s) | ||
{ | ||
map<char,int>m; | ||
m['I']=1; | ||
m['V']=5; | ||
m['X']=10; | ||
m['L']=50; | ||
m['C']=100; | ||
m['D']=500; | ||
m['M']=1000; | ||
int sum=0; | ||
for(int i=0;s[i]!='\0';i++) | ||
{ | ||
if(m[s[i]]<m[s[i+1]]) | ||
{ | ||
sum+=m[s[i+1]]-m[s[i]]; | ||
i++; | ||
} | ||
else | ||
sum+=m[s[i]]; | ||
} | ||
|
||
return sum; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Solution { | ||
public: | ||
bool searchMatrix(vector<vector<int> >& matrix, int target) { | ||
|
||
int row = matrix.size(); | ||
int col = matrix[0].size(); | ||
|
||
int rowIndex = 0; | ||
int colIndex = col-1; | ||
|
||
while(rowIndex < row && colIndex>=0 ) { | ||
int element = matrix[rowIndex][colIndex]; | ||
|
||
if(element == target) { | ||
return 1; | ||
} | ||
|
||
if(element < target){ | ||
rowIndex++; | ||
} | ||
else | ||
{ | ||
colIndex--; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Solution { | ||
public: | ||
int commonFactors(int a, int b) { | ||
int count=0; | ||
for(int i=1;i<=(a*b);i++) | ||
if(a%i==0 && b%i==0) | ||
count++; | ||
return count; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
You are given an integer array pref of size n. Find and return the array arr of size n that satisfies: | ||
|
||
pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]. | ||
Note that ^ denotes the bitwise-xor operation. | ||
|
||
It can be proven that the answer is unique. | ||
|
||
|
||
|
||
Example 1: | ||
|
||
Input: pref = [5,2,0,3,1] | ||
Output: [5,7,2,3,2] | ||
Explanation: From the array [5,7,2,3,2] we have the following: | ||
- pref[0] = 5. | ||
- pref[1] = 5 ^ 7 = 2. | ||
- pref[2] = 5 ^ 7 ^ 2 = 0. | ||
- pref[3] = 5 ^ 7 ^ 2 ^ 3 = 3. | ||
- pref[4] = 5 ^ 7 ^ 2 ^ 3 ^ 2 = 1. | ||
Example 2: | ||
|
||
Input: pref = [13] | ||
Output: [13] | ||
Explanation: We have pref[0] = arr[0] = 13. | ||
|
||
|
||
Constraints: | ||
|
||
1 <= pref.length <= 105 | ||
0 <= pref[i] <= 106 | ||
|
||
Solution | ||
class Solution { | ||
public: | ||
vector<int> findArray(vector<int>& pref) { | ||
for(int i=pref.size()-1;i>0;i--){ | ||
pref[i]=pref[i]^pref[i-1]; | ||
} | ||
return pref; | ||
} | ||
}; |