From c31b5c18695542db45affb9778a2824530919b41 Mon Sep 17 00:00:00 2001 From: PabLim-Par Date: Mon, 21 Oct 2024 13:18:08 +0000 Subject: [PATCH 1/6] Feat: adds leetcode problem solutions --- .../codedifferently/lesson11/Lesson11.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java index 248938a9..5fef8b21 100644 --- a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java +++ b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java @@ -2,6 +2,7 @@ import java.util.List; + public class Lesson11 { /** @@ -9,14 +10,30 @@ public class Lesson11 { * https://leetcode.com/problems/concatenation-of-array */ public int[] getConcatenation(int[] nums) { - return null; + int n = nums.length; + int ans[] = new int [2*n]; + for (int i = 0; i < nums.length; i++){ + ans[i] = nums[i] + ans[i + n] = nums[i] + } + return ans; } - + // Had help to understand better solutions from Joseph, Kimberlee, Nile, and Angelica, we were on Jitsi// + /** * Provide the solution to LeetCode 2942 here: * https://leetcode.com/problems/find-words-containing-character/ */ + public class Solution{ public List findWordsContaining(String[] words, char x) { - return null; - } + List indices = new ArrayList<>(); + for(int i = 0; i < words.length; i++){ + if (words[i].contains(String.valueOf(x))){ + indices.add(i); + } + } + return indices; + } } + } + From 92bbe49f3d24119d4ade74a4ea02766097f222b1 Mon Sep 17 00:00:00 2001 From: PabLim-Par Date: Mon, 21 Oct 2024 13:21:26 +0000 Subject: [PATCH 2/6] Feat: updates first problem accidentally forgot ; in lines 16, 17 --- .../src/main/java/com/codedifferently/lesson11/Lesson11.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java index 5fef8b21..4ddf88b1 100644 --- a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java +++ b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java @@ -13,8 +13,8 @@ public int[] getConcatenation(int[] nums) { int n = nums.length; int ans[] = new int [2*n]; for (int i = 0; i < nums.length; i++){ - ans[i] = nums[i] - ans[i + n] = nums[i] + ans[i] = nums[i]; + ans[i + n] = nums[i]; } return ans; } From 6bd7e91975adb473f1edf683324ae4bf7fd59f50 Mon Sep 17 00:00:00 2001 From: PabLim-Par Date: Mon, 21 Oct 2024 13:24:18 +0000 Subject: [PATCH 3/6] Feat: updates import for Array List --- .../src/main/java/com/codedifferently/lesson11/Lesson11.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java index 4ddf88b1..2ee13bbe 100644 --- a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java +++ b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java @@ -1,8 +1,8 @@ package com.codedifferently.lesson11; +import java.util.ArrayList; import java.util.List; - public class Lesson11 { /** From 1eab28ebd352c3d0c802480457c95004cc779f07 Mon Sep 17 00:00:00 2001 From: PabLim-Par Date: Mon, 21 Oct 2024 14:12:21 +0000 Subject: [PATCH 4/6] Feat: adds in spotless apply --- .../codedifferently/lesson11/Lesson11.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java index 2ee13bbe..ade5d41c 100644 --- a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java +++ b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java @@ -11,29 +11,30 @@ public class Lesson11 { */ public int[] getConcatenation(int[] nums) { int n = nums.length; - int ans[] = new int [2*n]; - for (int i = 0; i < nums.length; i++){ + int ans[] = new int[2 * n]; + for (int i = 0; i < nums.length; i++) { ans[i] = nums[i]; ans[i + n] = nums[i]; } return ans; } - // Had help to understand better solutions from Joseph, Kimberlee, Nile, and Angelica, we were on Jitsi// - + + // Had help to understand better solutions from Joseph, Kimberlee, Nile, and Angelica, we were on + // Jitsi// + /** * Provide the solution to LeetCode 2942 here: * https://leetcode.com/problems/find-words-containing-character/ */ - public class Solution{ - public List findWordsContaining(String[] words, char x) { - List indices = new ArrayList<>(); - for(int i = 0; i < words.length; i++){ - if (words[i].contains(String.valueOf(x))){ - indices.add(i); - } + public class Solution { + public List findWordsContaining(String[] words, char x) { + List indices = new ArrayList<>(); + for (int i = 0; i < words.length; i++) { + if (words[i].contains(String.valueOf(x))) { + indices.add(i); } - return indices; + } + return indices; } -} } - +} From 55e57ebd253ddaad06d4df89a56b12581740a890 Mon Sep 17 00:00:00 2001 From: PabLim-Par Date: Mon, 21 Oct 2024 14:21:13 +0000 Subject: [PATCH 5/6] Feat: updates code, removed a class --- .../com/codedifferently/lesson11/Lesson11.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java index ade5d41c..a3775c28 100644 --- a/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java +++ b/lesson_11/arrays_java/arrays_app/src/main/java/com/codedifferently/lesson11/Lesson11.java @@ -26,15 +26,13 @@ public int[] getConcatenation(int[] nums) { * Provide the solution to LeetCode 2942 here: * https://leetcode.com/problems/find-words-containing-character/ */ - public class Solution { - public List findWordsContaining(String[] words, char x) { - List indices = new ArrayList<>(); - for (int i = 0; i < words.length; i++) { - if (words[i].contains(String.valueOf(x))) { - indices.add(i); - } + public List findWordsContaining(String[] words, char x) { + List indices = new ArrayList<>(); + for (int i = 0; i < words.length; i++) { + if (words[i].contains(String.valueOf(x))) { + indices.add(i); } - return indices; } + return indices; } } From 548f5f9726218b9716cda7f4c1b7f6cb78d3208b Mon Sep 17 00:00:00 2001 From: PabLim-Par Date: Mon, 21 Oct 2024 17:18:56 +0000 Subject: [PATCH 6/6] Feat: before hw explained, TS conversion of Concatenation and Find words --- lesson_11/arrays_ts/src/lesson11.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lesson_11/arrays_ts/src/lesson11.ts b/lesson_11/arrays_ts/src/lesson11.ts index 54af1ba0..ad31b15a 100644 --- a/lesson_11/arrays_ts/src/lesson11.ts +++ b/lesson_11/arrays_ts/src/lesson11.ts @@ -3,7 +3,13 @@ * https://leetcode.com/problems/concatenation-of-array */ export function getConcatenation(nums: number[]): number[] { - return []; + const n = nums.length; + const ans = new Array(2 * n); + for (let i = 0; i < n; i++) { + ans[i] = nums[i]; + ans[i + n] = nums[i]; + } + return ans; } /** @@ -11,5 +17,11 @@ export function getConcatenation(nums: number[]): number[] { * https://leetcode.com/problems/find-words-containing-character/ */ export function findWordsContaining(words: string[], x: string): number[] { - return []; + const indices: number[] = []; + for (let i = 0; i < words.length; i++) { + if (words[i].includes(x)) { + indices.push(i); + } + } + return indices; }