-
Notifications
You must be signed in to change notification settings - Fork 25
feat: LeetCode 1929 only - by Dwight Blue #389
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
Changes from 2 commits
1cfb654
fa9ad5e
4843931
88cc7d7
9123096
d074a11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 { | ||
|
@@ -9,14 +10,32 @@ public class Lesson11 { | |
* https://leetcode.com/problems/concatenation-of-array | ||
*/ | ||
public int[] getConcatenation(int[] nums) { | ||
return null; | ||
} | ||
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; | ||
var words = new ArrayList<Integer>(); | ||
int wordArray = (words.length) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a semicolon on this line, but I don't think you need this anyway. |
||
// int newValue = (originalArray + 1); | ||
|
||
// int[] newArray = new int[words.length + 1]; | ||
|
||
for (int i=0; i<originalArray; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want |
||
if (words[i].contains(Character.toString(x))); | ||
// System.arraycopy(words,i,newArray,i,words.length); | ||
ArrayList.add(i); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ArrayList is a class, you want to make a new ArrayList instance and then call add on that object. var results = new ArrayList<Integer>();
results.add(5); |
||
|
||
} return ArrayList; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to run
./gradlew spotlessApply
to fix the formatting issues in this file.