diff --git a/Geeks DSA.pdf b/Geeks DSA.pdf new file mode 100644 index 000000000..0bf8ea27a Binary files /dev/null and b/Geeks DSA.pdf differ diff --git a/POORNIMA b/POORNIMA new file mode 100644 index 000000000..b29b53765 --- /dev/null +++ b/POORNIMA @@ -0,0 +1,3 @@ +### +I am Poornima Raghuwanshi +Student of VIT Bhopal from CSE Core 2nd year student diff --git a/geekweek day2.pdf b/geekweek day2.pdf new file mode 100644 index 000000000..5068f40aa Binary files /dev/null and b/geekweek day2.pdf differ diff --git a/poornima835/HackerRank1 b/poornima835/HackerRank1 new file mode 100644 index 000000000..649938721 --- /dev/null +++ b/poornima835/HackerRank1 @@ -0,0 +1,22 @@ +##REVERSE AN ARRAY + +#include + + +using namespace std; +int main() +{ + int numElements; + cin >> numElements; + int arr[numElements]; + for (int i = 0; i < numElements; i++){ + cin >> arr[i]; + } + + for (int i = numElements - 1; i >= 0; i--){ + + + cout << arr[i] << " "; + } + return 0; +} diff --git a/poornima835/HackerRank2 b/poornima835/HackerRank2 new file mode 100644 index 000000000..c18201aee --- /dev/null +++ b/poornima835/HackerRank2 @@ -0,0 +1,53 @@ +##Dynamic Array + +import java.io.*; +import java.math.*; +import java.security.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.regex.*; + +public static void main(String[] args) { + +Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); + int q = sc.nextInt(); + int inc=0,inb=0; + int last = 0,x; + int a[][] = new int[q][3]; + int b[] = new int[100000]; + int c[] = new int[100000]; + + for(int i = 0; i max_sum || i == 0 && j == 0) + max_sum = temp_sum; + } + } + System.out.println(max_sum); + scanner.close(); + } +} diff --git a/poornima835/ReadMe.md b/poornima835/ReadMe.md new file mode 100644 index 000000000..e616ca463 --- /dev/null +++ b/poornima835/ReadMe.md @@ -0,0 +1,4 @@ +##About me +Name: POORNIMA RAGHUWANSHI +Registration number: 19BCE10444 +I'm CSE Core 2nd year student. I am a learner. I like new technologies and want to learn more diff --git a/poornima835/SnoopDog b/poornima835/SnoopDog new file mode 100644 index 000000000..f7fe6929f --- /dev/null +++ b/poornima835/SnoopDog @@ -0,0 +1,78 @@ +###MUSICAL APPLICATION USING C++ + + + +#include +#include +using namespace std; + +int main() + +{ + +unordered_map notes = { + {"a", 440}, + {"a#", 466}, + {"b", 493}, + {"c", 523}, + {"c#", 554}, + {"d", 587}, + {"d#", 622}, + {"e", 659}, + {"f", 698}, + {"f#", 739}, + {"g", 783}, + {"g#", 830}, + {"a5", 880}, +}; +string note; +long long int duration; + +vector> octave = { + + {"a", 400}, + {"b", 400}, + {"c", 400}, + {"d", 400}, + {"e", 400}, + {"f", 400}, + {"g", 400}, + {"a5", 400}, +}; + +vector> SnoopDogg = +{ + + {"d#", 600}, + {"a5", 600}, + {"a5", 300}, + {"g#", 300}, + {"a5", 600}, + {"g#", 300}, + {"f#", 300}, + {"g#", 600}, + {"g#", 300}, + {"f#", 300}, + {"d#", 300}, + {"f#", 300}, +}; + + + while (true) + { +cout<<"Input note: "; + cin >> note; + if(note == "x") + break; +Beep(notes[note], 750); + + + } +for(int k=0; k<2; k++){ +for(auto i: SnoopDogg) +{ + Beep(notes[i.first], i.second); +}} +return 0; + +} diff --git a/poornima835/TicTacToeGame b/poornima835/TicTacToeGame new file mode 100644 index 000000000..6b3651563 --- /dev/null +++ b/poornima835/TicTacToeGame @@ -0,0 +1,190 @@ +##TIC TAC TOE GAME USING PYTHON + +from tkinter import * +from tkinter import messagebox + +window = Tk() + +window.title("Welcome to the Gaming World of Tic Tac Toe") +window.geometry("400x300") + +lb1 = Label(window, text="Tic Tac Toe", font=("Helvetica", "15")) +lb1.grid(row=0, column=0) +lb1 = Label(window, text="Player 1:X", font=("Helvetica", "10")) +lb1.grid(row=1, column=0) +lb1 = Label(window, text="Player 2:0", font=("Helvetica", "10")) +lb1.grid(row=2, column=0) + +turn = 1 + + +def clicked1(): + global turn + if btn1["text"] == " ": + if turn == 1: + turn = 2; + btn1["text"] = "X" + elif turn == 2: + turn = 1; + btn1["text"] = "0" + check(); + + +def clicked2(): + global turn + if btn2["text"] == " ": + if turn == 1: + turn = 2; + btn2["text"] = "X" + elif turn == 2: + turn = 1; + btn2["text"] = "0" + check(); + + +def clicked3(): + global turn + if btn3["text"] == " ": + if turn == 1: + turn = 2; + btn3["text"] = "X" + elif turn == 2: + turn = 1; + btn3["text"] = "0" + check(); + + +def clicked4(): + global turn + if btn4["text"] == " ": + if turn == 1: + turn = 2; + btn4["text"] = "X" + elif turn == 2: + turn = 1; + btn4["text"] = "0" + check(); + + +def clicked5(): + global turn + if btn5["text"] == " ": + if turn == 1: + turn = 2; + btn5["text"] = "X" + elif turn == 2: + turn = 1; + btn5["text"] = "0" + check(); + + +def clicked6(): + global turn + if btn6["text"] == " ": + if turn == 1: + turn = 2; + btn6["text"] = "X" + elif turn == 2: + turn = 1; + btn6["text"] = "0" + check(); + + +def clicked7(): + global turn + if btn7["text"] == " ": + if turn == 1: + turn = 2; + btn7["text"] = "X" + elif turn == 2: + turn = 1; + btn7["text"] = "0" + check(); + + +def clicked8(): + global turn + if btn8["text"] == " ": + if turn == 1: + turn = 2; + btn8["text"] = "X" + elif turn == 2: + turn = 1; + btn8["text"] = "0" + check(); + + +def clicked9(): + global turn + if btn9["text"] == " ": + if turn == 1: + turn = 2; + btn9["text"] = "X" + elif turn == 2: + turn = 1; + btn9["text"] = "0" + check(); + + +flag = 1; + + +def check(): + global flag; + b1 = btn1["text"]; + b2 = btn2["text"]; + b3 = btn3["text"]; + b4 = btn4["text"]; + b5 = btn5["text"]; + b6 = btn6["text"]; + b7 = btn7["text"]; + b8 = btn8["text"]; + b9 = btn9["text"]; + flag = flag + 1; + if b1 == b2 and b1 == b3 and b1 == "0" or b1 == b2 and b1 == b3 and b1 == "X": + win(btn1["text"]) + if b4 == b5 and b4 == b6 and b4 == "0" or b4 == b5 and b4 == b6 and b4 == "X": + win(btn4["text"]) + if b7 == b8 and b7 == b9 and b7 == "0" or b7 == b8 and b7 == b9 and b7 == "X": + win(btn7["text"]) + if b1 == b4 and b1 == b7 and b1 == "0" or b1 == b4 and b1 == b7 and b1 == "X": + win(btn1["text"]) + if b2 == b5 and b2 == b8 and b2 == "0" or b2 == b5 and b2 == b8 and b2 == "X": + win(btn2["text"]) + if b3 == b6 and b3 == b9 and b3 == "0" or b3 == b6 and b3 == b9 and b3 == "X": + win(btn3["text"]) + if b1 == b5 and b1 == b9 and b1 == "0" or b1 == b5 and b1 == b9 and b1 == "X": + win(btn1["text"]) + if b7 == b5 and b7 == b3 and b7 == "0" or b7 == b5 and b7 == b3 and b7 == "X": + win(btn7["text"]) + if flag == 10: + messagebox.showinfo("Title", "Match Tied!!!") + window.destroy() + + +def win(player): + ans = "Game complete " + player + " Wins "; + messagebox.showinfo("Congratulations", ans) + window.destroy() + + +btn1 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked1) +btn1.grid(row=1, column=1) +btn2 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked2) +btn2.grid(row=1, column=2) +btn3 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked3) +btn3.grid(row=1, column=3) +btn4 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked4) +btn4.grid(row=2, column=1) +btn5 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked5) +btn5.grid(row=2, column=2) +btn6 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked6) +btn6.grid(row=2, column=3) +btn7 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked7) +btn7.grid(row=3, column=1) +btn8 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked8) +btn8.grid(row=3, column=2) +btn9 = Button(window, text=" ", bg="yellow", width="3", height="3", font=("Helvetica", "20"), command=clicked9) +btn9.grid(row=3, column=3) + +window.mainloop() diff --git a/poornima835/leetcode1 b/poornima835/leetcode1 new file mode 100644 index 000000000..47c458a96 --- /dev/null +++ b/poornima835/leetcode1 @@ -0,0 +1,34 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + public List < Integer > inorderTraversal(TreeNode root) { + List < Integer > res = new ArrayList < > (); + helper(root, res); + return res; + } + + public void helper(TreeNode root, List < Integer > res) { + if (root != null) { + if (root.left != null) { + helper(root.left, res); + } + res.add(root.val); + if (root.right != null) { + helper(root.right, res); + } + } + } +} diff --git a/poornima835/leetcode2 b/poornima835/leetcode2 new file mode 100644 index 000000000..604b4e24a --- /dev/null +++ b/poornima835/leetcode2 @@ -0,0 +1,20 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode(int x) { val = x; } + * } + */ +class Solution { + public boolean isSameTree(TreeNode p, TreeNode q) { + // p and q are both null + if (p == null && q == null) return true; + // one of p and q is null + if (q == null || p == null) return false; + if (p.val != q.val) return false; + return isSameTree(p.right, q.right) && + isSameTree(p.left, q.left); + } +} diff --git a/poornima835/leetcode3 b/poornima835/leetcode3 new file mode 100644 index 000000000..ac28fc59a --- /dev/null +++ b/poornima835/leetcode3 @@ -0,0 +1,29 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode() {} + * TreeNode(int val) { this.val = val; } + * TreeNode(int val, TreeNode left, TreeNode right) { + * this.val = val; + * this.left = left; + * this.right = right; + * } + * } + */ +class Solution { + + public boolean isSymmetric(TreeNode root) { + return isMirror(root, root); +} + +public boolean isMirror(TreeNode t1, TreeNode t2) { + if (t1 == null && t2 == null) return true; + if (t1 == null || t2 == null) return false; + return (t1.val == t2.val) + && isMirror(t1.right, t2.left) + && isMirror(t1.left, t2.right); +} +} diff --git a/poornima835/leetcode4 b/poornima835/leetcode4 new file mode 100644 index 000000000..8e468ad17 --- /dev/null +++ b/poornima835/leetcode4 @@ -0,0 +1,51 @@ +/** + * Definition for a binary tree node. + * public class TreeNode { + * int val; + * TreeNode left; + * TreeNode right; + * TreeNode(int x) { val = x; } + * } + */ +class BSTIterator { + + ArrayList nodesSorted; + int index; + + public BSTIterator(TreeNode root) { + + // Array containing all the nodes in the sorted order + this.nodesSorted = new ArrayList(); + + // Pointer to the next smallest element in the BST + this.index = -1; + + // Call to flatten the input binary search tree + this._inorder(root); + } + + private void _inorder(TreeNode root) { + + if (root == null) { + return; + } + + this._inorder(root.left); + this.nodesSorted.add(root.val); + this._inorder(root.right); + } + + /** + * @return the next smallest number + */ + public int next() { + return this.nodesSorted.get(++this.index); + } + + /** + * @return whether we have a next smallest number + */ + public boolean hasNext() { + return this.index + 1 < this.nodesSorted.size(); + } +} diff --git a/poornima835/leetcode5 b/poornima835/leetcode5 new file mode 100644 index 000000000..e9530247c --- /dev/null +++ b/poornima835/leetcode5 @@ -0,0 +1,13 @@ +class Solution { + public int removeDuplicates(int[] nums) { + if (nums.length == 0) return 0; + int i = 0; + for (int j = 1; j < nums.length; j++) { + if (nums[j] != nums[i]) { + i++; + nums[i] = nums[j]; + } + } + return i + 1; + } +}