Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 44 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
aa59061
Setting up GitHub Classroom Feedback
github-classroom[bot] May 25, 2023
0e9a234
hometown webpage setup done
snmirji1997 Jul 1, 2023
4550f6f
initial setup table done
snmirji1997 Jul 1, 2023
8472e80
list setup
snmirji1997 Jul 1, 2023
7b883f0
poem done
snmirji1997 Jul 1, 2023
9834d35
mini project initial setup
snmirji1997 Jul 27, 2023
bcf5e98
Merge pull request #2 from pesto-students/sachin
snmirji1997 Aug 19, 2023
ba9e86b
solution done
snmirji1997 Aug 19, 2023
09668a0
session6 to 12 & dsa upto week2
snmirji1997 Aug 26, 2023
abf6c9f
week 2
snmirji1997 Aug 26, 2023
5abd301
Merge pull request #3 from pesto-students/sachin
snmirji1997 Aug 26, 2023
881e2b4
assingment1
snmirji1997 Sep 16, 2023
86830bb
assignment 2
snmirji1997 Sep 23, 2023
9dc95c1
minor spell misstake
snmirji1997 Sep 23, 2023
707fd4b
withloggin
snmirji1997 Sep 23, 2023
b84ac14
withlogging implemented
snmirji1997 Sep 23, 2023
0dee8c5
03project setup
snmirji1997 Sep 23, 2023
8b02279
project clean up
snmirji1997 Sep 23, 2023
41c417c
Booklist comp
snmirji1997 Sep 23, 2023
19b264d
state setup
snmirji1997 Sep 23, 2023
c351ad0
Merge pull request #4 from pesto-students/sachin
snmirji1997 Sep 30, 2023
40367e0
initial setup
snmirji1997 Oct 29, 2023
9ee5202
api working
snmirji1997 Oct 29, 2023
83a2e96
react hooks
snmirji1997 Oct 30, 2023
52ce6d8
gitignore .env added
snmirji1997 Oct 30, 2023
320036c
giting
snmirji1997 Oct 30, 2023
03c437c
sql table schema
snmirji1997 Oct 30, 2023
e1fdd6a
query 1
snmirji1997 Oct 30, 2023
3018500
query 2
snmirji1997 Oct 30, 2023
52e5c6a
query 3
snmirji1997 Oct 30, 2023
7f31055
query 4
snmirji1997 Oct 30, 2023
c822905
query 5
snmirji1997 Oct 30, 2023
56ccc7d
query 6
snmirji1997 Oct 30, 2023
a81d044
movie
snmirji1997 Nov 5, 2023
d1fe4f6
node fundamentals
snmirji1997 Nov 5, 2023
c5e152e
Add renovate.json
renovate[bot] Dec 15, 2023
58bc90d
Merge pull request #5 from pesto-students/renovate/configure
snmirji1997 Dec 16, 2023
d086274
Update dependency @mui/material to v5.15.0
renovate[bot] Dec 16, 2023
370663b
Update dependency @testing-library/jest-dom to v6
renovate[bot] Dec 16, 2023
64c0574
Merge pull request #7 from pesto-students/renovate/testing-library-je…
snmirji1997 Dec 16, 2023
c4a1bf0
Merge pull request #6 from pesto-students/renovate/material-ui-monorepo
snmirji1997 Dec 16, 2023
3ffd91f
Merge branch 'master' of https://github.com/pesto-students/team-kunal…
snmirji1997 Dec 16, 2023
dc16642
onpen ai commented
snmirji1997 Dec 16, 2023
2999f36
Merge pull request #11 from pesto-students/sachin
snmirji1997 Dec 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions DSA-Assignments/week 1/Arrays 1/countElements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const countElements = arr => arr.length;

const arr1 = [1, 2, 3, 4, 5];
console.log(countElements(arr1)); // 5

const arr2 = [7, 8, 9, 10, 11, 12, 13, 14, 15];
console.log(countElements(arr2)); // 9

// Time complexity: O(1)
// Space complexity: O(1)
24 changes: 24 additions & 0 deletions DSA-Assignments/week 1/Arrays 1/intersectionOfTwoArrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const intersectionOfTwoArray = (arr1, arr2) => {
const mySet = new Set(arr2);

const intersectionArray = [];

for (let i = 0; i < arr1.length; i++) {
if (mySet.has(arr1[i])) {
intersectionArray.push(arr1[i]);
}
}

return intersectionArray;
};

const arr1 = [1, 2, 3, 4, 5];
const arr2 = [4, 5, 6, 7, 8];
console.log(intersectionOfTwoArray(arr1, arr2)); // [4, 5]

const arr3 = [1, 2, 3, 4, 5];
const arr4 = [5, 4, 3, 2, 1];
console.log(intersectionOfTwoArray(arr3, arr4)); // [1, 2, 3, 4, 5]

// Time complexity: O(N)
// Space complexity: O(N)
12 changes: 12 additions & 0 deletions DSA-Assignments/week 1/Arrays 1/minAndMax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const sumOfMinAndMaxOfArray = (arr) => {
return Math.max(...arr) + Math.min(...arr);
};

const arr1 = [5, 2, 9, 1, 7];
console.log(sumOfMinAndMaxOfArray(arr1)); // 10

const arr2 = [-10, 0, 100, -50, 20];
console.log(sumOfMinAndMaxOfArray(arr2)); // 50

// Time complexity: O(N)
// Space complexity: O(1)
24 changes: 24 additions & 0 deletions DSA-Assignments/week 1/Arrays 1/nonDuplicateElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const nonDuplicateElement = (arr) => {
const myMap = new Map();

for (let i = 0; i < arr.length; i++) {
if (myMap.has(arr[i])) {
myMap.set(arr[i], myMap.get(arr[i]) + 1);
} else {
myMap.set(arr[i], 1);
}
}

for (let [key, value] of myMap) {
if (value === 1) return key;
}
};

const arr1 = [5, 2, 3, 2, 5];
console.log(nonDuplicateElement(arr1)); // 3

const arr2 = [-1, -1, -2, -2, -3];
console.log(nonDuplicateElement(arr2)); // -3

// Time complexity: O(N)
// Space complexity: O(N)
38 changes: 38 additions & 0 deletions DSA-Assignments/week 1/Arrays 1/pairOfSum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// const pairOfSum = (arr, S) => {
// const pairs = [];

// for (let i = 0; i < arr.length - 1; i++) {
// for (let j = i + 1; j < arr.length; j++) {
// const sum = arr[i] + arr[j];
// if (sum === S) pairs.push([arr[i], arr[j]]);
// }
// };

// return pairs;
// }

const pairOfSum = (arr, S) => {
const mySet = new Set();
const pairs = [];

for (let i = 0; i < arr.length; i++) {
const compliment = S - arr[i];
if (mySet.has(compliment)) {
pairs.push([compliment, arr[i]]);
}
mySet.add(arr[i]);
}

return pairs;
};

const arr1 = [2, 4, 6, 8, 10];
const S1 = 12;
console.log(pairOfSum(arr1, S1)); // [ [ 2, 10 ], [ 4, 8 ] ]

const arr2 = [1, 1, 1, 1, 1];
const S2 = 2;
console.log(pairOfSum(arr2, S2)); // [ [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ] ]

// Time complexity: O(N)
// Space complexity: O(N)
13 changes: 13 additions & 0 deletions DSA-Assignments/week 1/Arrays 2/deleteElements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const deleteElementInArray = (arr) => {
const newArr = arr.filter((ele) => ele % 2 !== 0 && ele % 3 !== 0);
return newArr;
};

const arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
console.log(deleteElementInArray(arr1)); // [1, 5, 7]

const arr2 = [9, 12, 15, 18, 21];
console.log(deleteElementInArray(arr2)); // []

// Time complexity: O(N)
// Space complexity: O(N)
19 changes: 19 additions & 0 deletions DSA-Assignments/week 1/Arrays 2/oldKeyNewKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const oldKeyNewKey = (arr, oldKey, newKey) => {
for (let i = 0; i < arr.length; i++) {
if (arr[i] === oldKey) arr[i] = newKey;
};
return arr;
};

const arr1 = [1, 2, 3, 2, 4, 2, 5];
const oldKey1 = 2;
const newKey1 = 6;
console.log(oldKeyNewKey(arr1, oldKey1, newKey1)); // [1, 6, 3, 6, 4, 6, 5]

const arr2 = [5, 5, 5, 5];
const oldKey2 = 5;
const newKey2 = 2;
console.log(oldKeyNewKey(arr2, oldKey2, newKey2)); // [2, 2, 2, 2]

// Time complexity: O(N)
// Space complexity: O(1)
29 changes: 29 additions & 0 deletions DSA-Assignments/week 1/Arrays 2/productOfSubArray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const maxProductOfSubArray = (N, arr) => {
let maxProduct = arr[0];
let minProduct = arr[0];
let result = arr[0];

for (let i = 1; i < N; i++) {
if (arr[i] < 0) {
[maxProduct, minProduct] = [minProduct, maxProduct];
}

maxProduct = Math.max(maxProduct * arr[i], arr[i]);
minProduct = Math.min(minProduct * arr[i], arr[i]);

result = Math.max(result, maxProduct);
}

return result;
};

const arr1 = [2, 3, -2, 4, 5];
const N1 = 5;
console.log(maxProductOfSubArray(N1, arr1)); // 20

const arr2 = [-1, -2, -3, -4];
const N2 = 4;
console.log(maxProductOfSubArray(N2, arr2)); // 24

// Time complexity: O(N);
// Space complexity: O(1)
66 changes: 66 additions & 0 deletions DSA-Assignments/week 1/Arrays 2/sumOfTwoMatrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
function getInputArray(rows, cols, elements) {
elements = elements.split(',').map(Number);
let index = 0;
const matrix = [];
for (let i = 0; i < rows; i++) {
const row = [];
for (let j = 0; j < cols; j++) {
row.push(elements[index])
index++;
}
matrix.push(row)
}
return matrix;
}

const calculateSumOfArrays = (arr1, arr2) => {
const row1 = arr1.length;
const col1 = arr1[0].length;
const row2 = arr2.length;
const col2 = arr2[0].length;

if (!((row1 === row2) && (col1 === col2))) {
return "Arrays must have the same dimensions";
}

let result = [];
for (let i = 0; i < arr1.length; i++) {
let row = [];
for (let j = 0; j < arr1[i].length; j++) {
const sum = arr1[i][j] + arr2[i][j];
row.push(sum)
}
result.push(row);
}

return result;
}

const rows1 = 2;
const cols1 = 3;
const elements1 = '1, 2, 3, 4, 5, 6';

const rows2 = 2;
const cols2 = 3;
const elements2 = '7, 8, 9, 10, 11, 12';

const arr1 = getInputArray(rows1, cols1, elements1);
const arr2 = getInputArray(rows2, cols2, elements2);

console.log(calculateSumOfArrays(arr1, arr2)); // [ [ 8, 10, 12 ], [ 14, 16, 18 ] ]

const rows3 = 2;
const cols3 = 2;
const elements3 = '1, 2, 3, 4';

const rows4 = 2;
const cols4 = 2;
const elements4 = '5, 6, 7, 8';

const arr3 = getInputArray(rows3, cols3, elements3);
const arr4 = getInputArray(rows4, cols4, elements4);

console.log(calculateSumOfArrays(arr3, arr4)); // [ [ 6, 8 ], [ 10, 12 ] ]

// Time complexity: O(N^2)
// Space complexity: O(N^2)
60 changes: 60 additions & 0 deletions DSA-Assignments/week 1/Arrays 2/transposeAMatrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
1 2
3 4

1 3
2 4

1 2 3 4
5 6 7 8

1 5
2 6
3 7
4 8
*/
function getInputArray(rows, cols, elements) {
elements = elements.split(" ").map(Number);
let index = 0;
const matrix = [];
for (let i = 0; i < rows; i++) {
const row = [];
for (let j = 0; j < cols; j++) {
row.push(elements[index]);
index++;
}
matrix.push(row);
}
return matrix;
}

const transposeAMatrix = (matrix) => {
const rows = matrix.length;
const cols = matrix[0].length;

let output = "";

for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
output += matrix[j][i] + " ";
}
}
return output;
};

const rows1 = 2;
const cols1 = 2;
const elements1 = "1 2 3 4";

const matrix1 = getInputArray(rows1, cols1, elements1);
console.log(transposeAMatrix(matrix1)); // 1 3 2 4

const rows2 = 2;
const cols2 = 4;
const elements2 = "1 2 3 4 5 6 7 8";

const matrix2 = getInputArray(rows2, cols2, elements2);
console.log(transposeAMatrix(matrix2)); // 1 5 2 6 3 7 4 8

// Time complexity: O(N^2)
// Space complexity: O(1)
17 changes: 17 additions & 0 deletions DSA-Assignments/week 1/Intro to DSA/isLeapYear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function isLeapYear(year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}

function checkLeapYear() {
const year = prompt("Please enter a year");
if (!year) {
prompt("Please enter a year");
return;
}
return alert(isLeapYear(year) ? "Yes" : "No");
}

checkLeapYear();

// Time complexity: O(1)
// Space complexity: O(1)
27 changes: 27 additions & 0 deletions DSA-Assignments/week 1/Intro to DSA/isPalindrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function reversedNumber(num) {
let reversedNum = 0;
while (num !== 0) {
let remainder = num % 10;
reversedNum = reversedNum * 10 + remainder;
num = parseInt(num / 10);
}
return reversedNum;
}

function isPalindrome(num) {
const reversedNum = reversedNumber(num);
return num === reversedNum;
}

function checkPalindrome() {
const num = prompt("Please enter a number");
if (!num) {
prompt("Please enter a number");
}
alert(isPalindrome(num) ? "Yes" : "No");
}

checkPalindrome();

// Time complexity: O(log(N))
// Space complexity: O(1)
14 changes: 14 additions & 0 deletions DSA-Assignments/week 1/Intro to DSA/oddEven.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const isEvenOrOdd = num => num % 2 === 0;

const checkEvenOrOdd = () => {
const num = prompt('Please enter a number');
if (!num) {
prompt('Please enter a number');
}
return alert(isEvenOrOdd(num) ? "Even" : "Odd");
}

checkEvenOrOdd();

// Time complexity: O(1)
// Space complexity: O(1)
19 changes: 19 additions & 0 deletions DSA-Assignments/week 1/Intro to DSA/productOfHalfHCFAndLCM.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const productOfHCFAndLCM = (num1, num2) => {
let firstNumber = num1 > num2 ? num1 : num2;
let secondNumber = num1 > num2 ? num2 : num1;

while (secondNumber !== 0) {
let temp = secondNumber;
secondNumber = firstNumber % secondNumber;
firstNumber = temp;
}

const hcf = firstNumber;

const lcm = (num1 * num2) / hcf;

return lcm * hcf;
};

// Time complexity: O(log(N))
// Space complexity: O(1)
Loading