Skip to content

NileJackson Lesson11Hw #371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
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
@@ -0,0 +1,10 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package org.example

class Library {
fun someLibraryMethod(): Boolean {
return true
}
}
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 @@ -12,11 +13,39 @@ public int[] getConcatenation(int[] nums) {
return null;
}

class Solution {
public int[] getConcatenation(int[] nums) {
int answer[] = new int[2 * nums.length];
for (int i = 0; i < nums.length; i++) {
answer[i] = nums[i];
}
int index = nums.length;
for (int i = 0; i < nums.length; i++) {
answer[index] = nums[i];
index++;
}
return answer;
}
}

/**
* 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;
}
}

class Solution {
public List<Integer> findWordsContaining(String[] words, char x) {
List<Integer> resultWords = new ArrayList<>();
for (int i = 0; i < words.length; i++) {
if (words[i].indexOf(x) != -1) {
resultWords.add(i);
}
}
return resultWords;
}
}
Loading