From bca96ea837f3ff4f1e077b4cdd2b42de4355dc66 Mon Sep 17 00:00:00 2001 From: GAJAL999 <112615069+GAJAL999@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:15:29 +0530 Subject: [PATCH 1/3] Added Spiral Matrix code in java This is useful for beginners who are using gfg for practice, this is my way of solving spiral matrix --- Intermediate/algorithms/Spiral matrix.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Intermediate/algorithms/Spiral matrix.java diff --git a/Intermediate/algorithms/Spiral matrix.java b/Intermediate/algorithms/Spiral matrix.java new file mode 100644 index 00000000..ad1b79c5 --- /dev/null +++ b/Intermediate/algorithms/Spiral matrix.java @@ -0,0 +1,43 @@ +class Solution { + public List spiralOrder(int[][] matrix) { + ArrayList list = new ArrayList<>(); + int dir = 0, top = 0, left = 0, bottom = matrix.length - 1, right = matrix[0].length - 1; + + while (top <= bottom && left <= right) { + // Moving left to right + if (dir == 0) { + for (int i = left; i <= right; i++) { + list.add(matrix[top][i]); + } + top++; // move the top boundary down + dir = 1; + } + // Moving top to bottom + else if (dir == 1) { + for (int i = top; i <= bottom; i++) { + list.add(matrix[i][right]); + } + right--; // move the right boundary left + dir = 2; + } + // Moving right to left + else if (dir == 2) { + for (int i = right; i >= left; i--) { + list.add(matrix[bottom][i]); + } + bottom--; // move the bottom boundary up + dir = 3; + } + // Moving bottom to top + else if (dir == 3) { + for (int i = bottom; i >= top; i--) { + list.add(matrix[i][left]); + } + left++; // move the left boundary right + dir = 0; // reset the direction to start again + } + } + + return list; + } +} From fd0ffcc17ae9875d479c94fff01729dba0488aac Mon Sep 17 00:00:00 2001 From: GAJAL999 <112615069+GAJAL999@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:30:47 +0530 Subject: [PATCH 2/3] Update Spiral matrix.java --- Intermediate/algorithms/Spiral matrix.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Intermediate/algorithms/Spiral matrix.java b/Intermediate/algorithms/Spiral matrix.java index ad1b79c5..cb92c32c 100644 --- a/Intermediate/algorithms/Spiral matrix.java +++ b/Intermediate/algorithms/Spiral matrix.java @@ -1,3 +1,20 @@ +import java.util.*; + +public class SpiralOrderRunner { + public static void main(String[] args) { + int[][] matrix = { + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9} + }; + + Solution solution = new Solution(); + List result = solution.spiralOrder(matrix); + + System.out.println("Spiral order traversal: " + result); + } +} + class Solution { public List spiralOrder(int[][] matrix) { ArrayList list = new ArrayList<>(); From 1103c14aebe4a306d9534db029360f8fe94e9b07 Mon Sep 17 00:00:00 2001 From: GAJAL999 <112615069+GAJAL999@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:36:48 +0530 Subject: [PATCH 3/3] Diet Chart.html --- .../html-css-snippets/Diet Chart.html | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Intermediate/html-css-snippets/Diet Chart.html diff --git a/Intermediate/html-css-snippets/Diet Chart.html b/Intermediate/html-css-snippets/Diet Chart.html new file mode 100644 index 00000000..9a296152 --- /dev/null +++ b/Intermediate/html-css-snippets/Diet Chart.html @@ -0,0 +1,54 @@ + + + + Diet Chart + + +

Diet Chart

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Meal/Day of the weekMondayTuesdayWednesdayThursdayFriday
Breakfast1 bowl of poha or daliyaoats porridgeidli-sambhar1 egg-omlette1 besan chilla
Lunch2 chapatti with dal and curd2 chapatti with sabzi and salad1 bajra roti with dal and salad1 chapatti and rice with chole2 chapatti with sabzi and curd
Snack1 bowl of cut fruits1 glass fruit juice1 bowl soup1 bowl sprouts salad1 glass coconut water
Dinner2 chapatti with dal2 chapatti with palak paneer1 bajra roti with dal1 chapatti and rice with chole2 chapatti with sabzi
+

Hope it helps, Thank You

+

For more information please refer to link mentioned below. Want to lose wait fast

+ +