The Rise of Virtual Reality in Education: Shaping the Future of Learning Introduction: Virtual Reality (VR) is revolutionizing education by providing immersive and interactive learning experiences. With its potential to enhance comprehension, foster collaboration, and increase accessibility, VR is shaping the future of learning. In this blog, we will explore...
Did you know there’s a planet largely made of diamonds?
The Diamond planet Did you know there’s a planet largely made of diamonds? An exoplanet named 55 CANCRI E, the constellation cancer is confirmed to be largely made of diamonds. It is one of the largest planets in the universe and has a mass eight times that of the Earth....
Unlocking the Power of the Universe: The Ultimate Guide to Dyson Spheres
Unlocking the Power of the Universe: The Ultimate Guide to Dyson Spheres Have you ever heard about Dyson Sphere ??? No, yes ?? In this scientific era every day new discoveries happening .people are so interested in having deep knowledge about things around them. One famous and interesting topic of discussion is...
Debunking the Myth: Does Water Really Have a Memory?
Debunking the Myth: The Science Behind 'Water Has a Memory Sounds crazy right? Actually, that’s true but not many peoples are aware of it. So welcome to the world of water. we are surrounded by water around 70 % of the earth consists of water. we use water in...
How to use React createRef in material Table
React provides a feature known just as refs that object over there allow for dom access from components. The reader attaches a ref to an element in an object belonging to you, that object being your application to provide access to the element’s dom from anywhere within an object belonging...
leetcode Max Area of Island Solution (Max Area of Island) (leetcode june 2021 challenge)
Max Area of Island You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. The area of an island is the number of cells with a value 1 in the island. Return the maximum area of...
codeforces 45A Solution A. Codecraft lll (codeforces 45A) (rank 900*)
45A. Codecraft lllProblem Link: https://codeforces.com/problemset/problem/45/ASolution 1:import java.util.Scanner;public class A45 { public static Scanner scn = new Scanner(System.in); public static String[] str = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; public static int nextIdx(int currIdx, int change) { return (currIdx + change) % 12; } public static int currIdx(String myStr) { for (int i = 0; i < str.length; i++) { if (myStr.equals(str[i])) return i; } return -1; } public static void main(String[] argv) { String str2 = scn.next(); int change = scn.nextInt(); int idx = currIdx(str2); System.out.println(str[nextIdx(idx, change)]); }}
codeforces 282A Solution A. Bit++ (codeforces 282A) (rank 800*)
282A. Bit++Problem Link: https://codeforces.com/problemset/problem/282/ASolution 1:import java.util.*;public class A282 { public static Scanner scn = new Scanner(System.in); public static int finalAns(int n){ String str = ""; int ans = 0; for(int i=0;i<n;i++){ str=scn.next(); if(str.charAt(0)=='+' || str.charAt(2)=='+') ans++; else ans--; } return ans; } public static void main(String[] argv){ int n = scn.nextInt(); System.out.println(finalAns(n)); }}
codeforces 263A Solution A. Beautiful Matrix (codeforces 263A) (rank 800*)
263A. Beautiful MatrixProblem Link: https://codeforces.com/problemset/problem/263/ASolution 1:import java.util.*;public class A263 { public static Scanner scn = new Scanner(System.in); public static void input(int[][] arr) { for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) arr[i][j] = scn.nextInt(); } public static int TotalMoves(int[][] arr) { boolean flag = true; int x = 0, y = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (arr[i][j] == 1) { x = i; y = j; flag = false; break; } } if (!flag) break; } return Math.abs(3-(x+1))+Math.abs(3-(y+1)); } public static void main(String[] argv){ int[][] arr = new int[5][5]; input(arr); System.out.println(TotalMoves(arr)); }}
codeforces 43D Solution D.Journey (codeforces 43D) (rank 2000*)
43D. JourneyProblem Link: "https://codeforces.com/problemset/problem/43/D"Solution 1:import java.util.*;public class traveseKing { public static Scanner scn = new Scanner(System.in); public static int counter = 0; public static boolean isTelepoter(int[][] arr, int i, int j, int n, int m, int count, ArrayList<int[]> al, int[][] dirEven, int[][] dirOdd) { if (n == 1 && m == 1) { System.out.println(0 + "n" + 1 + "t" + 1); return true; } if (count >= n * m - 1 && ((i == 1 && j == 2) || (i == 2 && j == 1))) { System.out.println(0 + "n" + 1 + "t" + 1); for (int x = 0; x < al.size(); x++) { for (int y = 0; y < 2; y++) { System.out.print(al.get(x)[y] + "t"); } System.out.println(); } System.out.println(1 + "t" + 1); return true; } if (count >= n * m - 1) counter = count + 1; if (counter >= n * m) return false; boolean recAns = false; for (int x = 0; x < dirEven.length; x++) { int newi = 0, newj = 0; if (m % 2 == 0) { newi = i + dirEven[x][0]; newj = j + dirEven[x][1]; } else { newi = i + dirOdd[x][0]; newj = j + dirOdd[x][1]; } if ((newi <= n && newi >= 1) && (newj <= m && newj >= 1) && arr[newi - 1][newj - 1] < 1) { al.add(new int[] { newi,newj }); arr[newi - 1][newj - 1]++; recAns = isTelepoter(arr, newi, newj, n, m, count + 1, al, dirEven, dirOdd); al.remove(al.size() - 1); arr[newi - 1][newj - 1]--; } if (recAns) return true; } return recAns; } public static void traverse(int[][] arr, int i, int j, int n, int m, ArrayList<int[]> al) { boolean isTele = true; int[][] dirOdd = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } }; int[][] dirEven = { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } }; isTele = isTelepoter(arr, 1, 1, n, m, 0, al, dirEven, dirOdd); if (!isTele) { System.out.println(1); if (n % 2 == 1) System.out.println(n + "t" + m + "t" + 1 + "t" + 1); else System.out.println(n + "t" + 1 + "t" + 1 + "t" + 1); for (int x = 0; x < n; x++) { if (x % 2 == 0) for (int y = 0; y < m; y++) { System.out.println((x + 1) + "t" + (y + 1)); } else for (int y = m - 1; y >= 0; y--) { System.out.println((x + 1) + "t" + (y + 1)); } } System.out.println(1 + "t" + 1); } } public static void main(String[] argv) { int n = scn.nextInt(); int m = scn.nextInt(); ArrayList<int[]> al = new ArrayList<>(); int[][] arr = new int[n][m]; traverse(arr, 1, 1, n, m, al); }}Solution 2: Better than First:import java.util.*;public class traveseKing { public static Scanner scn = new Scanner(System.in); public static int counter = 0; public static boolean isTelepoter(int[][] arr, int i, int j, int n, int m, int count, ArrayList<int[]> al, int[][] dir) { if (n == 1 && m == 1) { System.out.println(0 + "n" + 1 + "t" + 1); return true; } if (count >= n * m - 1 && ((i == 1 && j == 2) || (i == 2 && j == 1))) { System.out.println(0 + "n" + 1 + "t" + 1); for (int x = 0; x < al.size(); x++) { for (int y = 0; y < 2; y++) { System.out.print(al.get(x)[y] + "t"); } System.out.println(); } System.out.println(1 + "t" + 1); return true; } if (count >= n * m - 1) counter = count + 1; if (counter >= n * m) return false; boolean recAns = false; for (int x = 0; x < dir.length; x++) { int newi = 0, newj = 0; newi = i + dir[x][0]; newj = j + dir[x][1]; if ((newi <= n && newi >= 1) && (newj <= m && newj >= 1) && arr[newi - 1][newj - 1] < 1) { al.add(new int[] { newi, newj }); arr[newi - 1][newj - 1]++; recAns = isTelepoter(arr, newi, newj, n, m, count + 1, al, dir); al.remove(al.size() - 1); arr[newi - 1][newj - 1]--; } if (recAns) return true; } return recAns; } public static void traverse(int[][] arr, int i, int j, int n, int m, ArrayList<int[]> al) { boolean istele= false; int[][] dirOdd = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } }; int[][] dirEven = { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } }; if (m % 2 == 1 && !(n % 2 == 1 && m % 2 == 1)) istele = isTelepoter(arr, 1, 1, n, m, 0, al, dirOdd); if(m%2==0 && !(n % 2 == 1 && m % 2 == 1)) istele = isTelepoter(arr, 1, 1, n, m, 0, al, dirEven); if (!istele) { System.out.println(1); if (n % 2 == 1) System.out.println(n + "t" + m + "t" + 1 + "t" + 1); else System.out.println(n + "t" + 1 + "t" + 1 + "t" + 1); for (int x = 0; x < n; x++) { if (x % 2 == 0) for (int y = 0; y < m; y++) { System.out.println((x + 1) + "t" + (y + 1)); } else for (int y = m - 1; y >= 0; y--) { System.out.println((x + 1) + "t" + (y + 1)); } } System.out.println(1 + "t" + 1); } } public static void main(String[] argv) { int n = scn.nextInt(); int m = scn.nextInt(); ArrayList<int[]> al = new ArrayList<>(); int[][] arr = new int[n][m]; traverse(arr, 1, 1, n, m, al); }}