Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.codedifferently.lesson11;

import java.util.ArrayList;
import java.util.List;

public class Lesson11 {
Expand All @@ -9,14 +10,35 @@ public class Lesson11 {
* https://leetcode.com/problems/concatenation-of-array
*/
public int[] getConcatenation(int[] nums) {
return null;
// used AI to implement this solution
if (nums == null || nums.length == 0) {
return new int[0];
}
int originalLength = nums.length;
int[] result = new int[originalLength * 2];

for (int i = 0; i < originalLength; i++) {
result[i] = nums[i];
result[i + originalLength] = nums[i];
}
return result;
}

/**
* Provide the solution to LeetCode 2942 here:
* https://leetcode.com/problems/find-words-containing-character/
*/
public List<Integer> findWordsContaining(String[] words, char x) {
return null;
// Montell helped me out with with coding implementation
// need to create a string array
List<Integer> search = new ArrayList<>();
// iterate through elements in string array and compare them with the character
for (int i = 0; i < words.length; i++) {
if (words[i].contains(String.valueOf(x))) {
search.add(i);
}
}
// return the index of the element in the string array that contains the character provided
return search;
}
}