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,22 +1,38 @@
package com.codedifferently.lesson11;

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

public class Lesson11 {

/**
* Provide the solution to LeetCode 1929 here:
* https://leetcode.com/problems/concatenation-of-array
*/
public int[] getConcatenation(int[] nums) {
return null;
}
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;
}

/**
* 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;
}
public List<Integer> findWordsContaining(String[] words, char x) {
List<Integer> result = new ArrayList<>();

for (int i = 0; i < words.length; i++) {
if (words[i].indexOf(x) != -1) {
result.add(i);
}
}

return result;
}
}
Loading