Skip to content

"Feat lesson 11 leet code" #420

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
wants to merge 1 commit into from
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
@@ -1,5 +1,6 @@
package com.codedifferently.lesson11;

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

public class Lesson11 {
Expand All @@ -8,15 +9,34 @@ public class Lesson11 {
* Provide the solution to LeetCode 1929 here:
* https://leetcode.com/problems/concatenation-of-array
*/
public int[] getConcatenation(int[] nums) {
return null;
}
class Solution {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class shouldn't be here, just needed to modify the existing function.

public int[] getConcatenation(int[] nums) {
int n = nums.length;
int [] ans = new int[n * 2];

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) {
ArrayList <Integer> result = new ArrayList<>();

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

return result;
}
}

11 changes: 5 additions & 6 deletions lesson_11/arrays_ts/src/lesson11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
* Provide the solution to LeetCode 1929 here:
* https://leetcode.com/problems/concatenation-of-array
*/
export function getConcatenation(nums: number[]): number[] {
return [];
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just adding extra spaces?


/**
* Provide the solution to LeetCode 2942 here:
* https://leetcode.com/problems/find-words-containing-character/
*/
export function findWordsContaining(words: string[], x: string): number[] {
return [];
}




Loading