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

pratiksha #605

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Geeks DSA.pdf
Binary file not shown.
24 changes: 24 additions & 0 deletions Pratiksha Jain/DSA1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//reverse array in c++

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main()

{
int size;
cin>> size;
int arr[size];
for (int i=0;i<size; i++){
cin>>arr[i];
}
for (int i=size-1;i>=0; i--){
cout<<arr[i]<<" ";
}
return 0;
}
71 changes: 71 additions & 0 deletions Pratiksha Jain/DSA2
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//haurglass 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 class TestHourGlass {


public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int arr[][] = new int[6][6];
int hourGlassSum[] = new int[16];
int pos = 0;

//Reads data from user input and store in 6*6 Array
for (int arr_i = 0; arr_i < 6; arr_i++) {
for (int arr_j = 0; arr_j < 6; arr_j++) {
arr[arr_i][arr_j] = in.nextInt();
}
}
//Find each possible hourGlass and calculate sum of each hourGlass
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
hourGlassSum[pos] = calculateHourGlassSum(arr, i, i + 2, j, j + 2);
pos++;
}
}
System.out.println(findmax(hourGlassSum));

}
/**
* @param arr
* @param pos1 - Row startPoint
* @param pos2 - Row endPoint
* @param pos3 - column startPoint
* @param pos4 - column endPoint
* @return
*/
public static int calculateHourGlassSum(int arr[][], int pos1, int pos2, int pos3, int pos4) {

int sum = 0;
int exclRowNum = pos1 + 1;
int exclColNum1 = pos3;
int exclColNum2 = pos4;
for (int arr_i = pos1; arr_i <= pos2; arr_i++) {
for (int arr_j = pos3; arr_j <= pos4; arr_j++) {
sum = sum + arr[arr_i][arr_j];
}
}
sum = sum - (arr[exclRowNum][exclColNum1] + arr[exclRowNum][exclColNum2]);
return sum;
}

/**
* @param arr
* @return max elem of Array
*/
public static int findmax(int arr[]) {
int max = arr[0];
for (int i = 0; i < arr.length; i++) {
if (arr[i] >= max)
max = arr[i];
}
return max;
}
}
59 changes: 59 additions & 0 deletions Pratiksha Jain/DSA3
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//dynamic array

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Solution {

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<q ; i++)
{
for(int j=0;j<3;j++)
a[i][j] = sc.nextInt();

x = ((a[i][1]^last)%n); //sequence s1 or s0
if(a[i][0] == 1) // query 1 or 0
{
if(x == 0)
b[inb++] = a[i][2];
else
c[inc++] = a[i][2];
}
else{

if(x == 0)
last = b[a[i][2]%(inb)];
else
last = c[a[i][2]%(inc)];

System.out.println(last);


}


}


}
}
Binary file added Pratiksha Jain/DSA_5.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pratiksha Jain/DSA_5.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pratiksha Jain/DSA_5.3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pratiksha Jain/DSA_5.4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pratiksha Jain/DSA_5.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions Pratiksha Jain/DSA_day6.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.*;
import java.io.*;

class Node {
Node left;
Node right;
int data;

Node(int data) {
this.data = data;
left = null;
right = null;
}
}

class Solution {


public static void inOrder(Node root) {
Deque<Node> stack = new ArrayDeque<Node>();
while(!stack.isEmpty() || root!=null){
if(root!=null){
stack.push(root);
root = root.left;
}else{
root = stack.pop();
System.out.print(root.data+" ");
root = root.right;
}
}
}


51 changes: 51 additions & 0 deletions Pratiksha Jain/DSA_day6.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution {

// Complete the reverseArray function below.
static int[] reverseArray(int[] a) {


}

private static final Scanner scanner = new Scanner(System.in);

public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

int arrCount = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

int[] arr = new int[arrCount];

String[] arrItems = scanner.nextLine().split(" ");
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

for (int i = 0; i < arrCount; i++) {
int arrItem = Integer.parseInt(arrItems[i]);
arr[i] = arrItem;
}

int[] res = reverseArray(arr);

for (int i = 0; i < res.length; i++) {
bufferedWriter.write(String.valueOf(res[i]));

if (i != res.length - 1) {
bufferedWriter.write(" ");
}
}

bufferedWriter.newLine();

bufferedWriter.close();

scanner.close();
}
}
4 changes: 4 additions & 0 deletions Pratiksha Jain/DSA_day6.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def print_list(head):
if head is not None:
print(head.data)
print_list(head.next)
14 changes: 14 additions & 0 deletions Pratiksha Jain/DSA_day6.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int d = scan.nextInt();
int[] array = new int[n];
for(int i=0; i<n;i++) {
array[(i+n-d)%n] = scan.nextInt();
}
for(int i=0; i<n;i++) {
System.out.print(array[i] + " ");
}
}
}
25 changes: 25 additions & 0 deletions Pratiksha Jain/DSA_day6.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Node* InsertNth(Node *head, int data, int position)
{
Node newNode = (Node)malloc(sizeof(Node));
newNode->data = data;

if (head == NULL) {
return newNode;
}

if (position == 0) {
newNode->next = head;
return newNode;
}

Node *currentNode = head;
while (position - 1 > 0) {
currentNode = currentNode->next;
position--;
}

newNode->next = currentNode->next;
currentNode->next = newNode;

return head;
}
5 changes: 5 additions & 0 deletions Pratiksha Jain/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Name: Pratiksha Jain

Registration Number: 19BCY10172

I'm 2nd year student from CSE(cyber securtiy and digital forensics).
13 changes: 13 additions & 0 deletions Pratiksha Jain/leetcode
Original file line number Diff line number Diff line change
@@ -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;
}
}
34 changes: 34 additions & 0 deletions Pratiksha Jain/leetcode1
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
20 changes: 20 additions & 0 deletions Pratiksha Jain/leetcode2
Original file line number Diff line number Diff line change
@@ -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);
}
}
29 changes: 29 additions & 0 deletions Pratiksha Jain/leetcode3
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading