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..97d454265 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,22 +1,26 @@ package com.codedifferently.lesson11; +import java.util.ArrayList; import java.util.List; public class Lesson11 { - /** - * Provide the solution to LeetCode 1929 here: - * https://leetcode.com/problems/concatenation-of-array - */ public int[] getConcatenation(int[] nums) { - return null; + int answer[] = new int[nums.length * 2]; + for (int i = 0; i < nums.length; i++) { + answer[i] = nums[i]; + answer[i + nums.length] = nums[i]; + } + return answer; } - /** - * Provide the solution to LeetCode 2942 here: - * https://leetcode.com/problems/find-words-containing-character/ - */ public List findWordsContaining(String[] words, char x) { - return null; + var result = new ArrayList(); + for (int i = 0; i < words.length; i++) { + if (words[i].contains(String.valueOf(x))) { + result.add(i); + } + } + return result; } } diff --git a/lesson_11/arrays_ts/src/lesson11.ts b/lesson_11/arrays_ts/src/lesson11.ts index 54af1ba03..02f3483d5 100644 --- a/lesson_11/arrays_ts/src/lesson11.ts +++ b/lesson_11/arrays_ts/src/lesson11.ts @@ -1,15 +1,32 @@ -/** - * Provide the solution to LeetCode 1929 here: - * https://leetcode.com/problems/concatenation-of-array - */ + export function getConcatenation(nums: number[]): number[] { - return []; -} + if (nums.length === 0) { + return []; + } + const result = [...nums]; + for (const num of nums) { + result.push(num); + } + return result; + } + + + /** * Provide the solution to LeetCode 2942 here: * https://leetcode.com/problems/find-words-containing-character/ */ export function findWordsContaining(words: string[], x: string): number[] { - return []; -} + if (words.length === 0) { + return []; + } + const result = []; + for (let i = 0; i < words.length; i++) { + if (words[i].includes(x)) { + result.push(i); + } + } + return result; + } +//Received help from copiliot and Meiko and Bryana. \ No newline at end of file