From 0bc66b6741df8b224b05dc3519a5959a1ea22ba5 Mon Sep 17 00:00:00 2001 From: Sdunsmore2006 Date: Mon, 21 Oct 2024 13:36:06 +0000 Subject: [PATCH 1/2] Feat: adds Shawn Dunsmore Lesson11 java. --- .../codedifferently/lesson11/Lesson11.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 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 248938a96..983557771 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,5 +1,5 @@ package com.codedifferently.lesson11; - +import java.util.ArrayList; import java.util.List; public class Lesson11 { @@ -9,14 +9,32 @@ 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 < n; i++) { + ans[i] = nums[i]; + ans[i + n] = nums[i]; + } + + return ans; +} + /** * Provide the solution to LeetCode 2942 here: * https://leetcode.com/problems/find-words-containing-character/ */ - public List findWordsContaining(String[] words, char x) { - return null; - } + public List findWordsContaining(String[] words, char x) { + List indices = new ArrayList<>(); + + for (int i = 0; i < words.length; i++) { + if (words[i].indexOf(x) != -1) { + indices.add(i); + } + } + + return indices; + } } From 695b63540787689a43633b62be01bf8a61efe67c Mon Sep 17 00:00:00 2001 From: Sdunsmore2006 Date: Mon, 21 Oct 2024 14:12:25 +0000 Subject: [PATCH 2/2] Feat: adds Shawn Dunsmore Lesson 11 SpotlessApply. --- .../codedifferently/lesson11/Lesson11.java | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 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 983557771..c89c4a5a0 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,4 +1,5 @@ package com.codedifferently.lesson11; + import java.util.ArrayList; import java.util.List; @@ -9,32 +10,30 @@ public class Lesson11 { * https://leetcode.com/problems/concatenation-of-array */ public int[] getConcatenation(int[] nums) { - int n = nums.length; - int[] ans = new int[2 * n]; - - - for (int i = 0; i < n; i++) { - ans[i] = nums[i]; - ans[i + n] = nums[i]; - } - - return ans; -} + int n = nums.length; + int[] ans = new int[2 * n]; + + for (int i = 0; i < n; i++) { + ans[i] = nums[i]; + ans[i + n] = nums[i]; + } + return ans; + } /** * Provide the solution to LeetCode 2942 here: * https://leetcode.com/problems/find-words-containing-character/ */ - public List findWordsContaining(String[] words, char x) { - List indices = new ArrayList<>(); - - for (int i = 0; i < words.length; i++) { - if (words[i].indexOf(x) != -1) { - indices.add(i); - } - } + public List findWordsContaining(String[] words, char x) { + List indices = new ArrayList<>(); - return indices; + for (int i = 0; i < words.length; i++) { + if (words[i].indexOf(x) != -1) { + indices.add(i); + } } + + return indices; + } }