jeso
BAN USER
- 7of 9 votes
AnswersEliminate all ‘b’ and ‘ac’ in an array of characters, you have to replace them in-place, and you are only allowed to iterate over the char array once.
- jeso in Switzerland
Examples:
abc -> ac
ac->''
react->rt| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays
Hi guys,
why over complicating it so much. The op just asks for flattening a list of lists of integers and implementing next and hasNext. No need for implementing Iterator thus far. Just forward requests to a backing list that just encapsulates the list of lists.
public class FlattenList {
int index = 0;
List<Integer> flattenedList = new ArrayList<>();
private FlattenList(){
}
public static FlattenList getList(List<List<Integer>> lists){
FlattenList flattenList = new FlattenList();
flattenList.flatten(lists);
return flattenList;
}
private void flatten(List<List<Integer>> lists) {
for(List<Integer> list : lists){
flattenedList.addAll(list);
}
}
public boolean hasNext(){
return flattenedList.size() > index;
}
public Integer next(){
Integer result = flattenedList.get(index);
index++;
return result;
}
}
and the test should look like this
public class FlattenListTest {
@Before
public void setUp() throws Exception {
}
@Test
public void test() {
FlattenList flattenList = FlattenList.getList(Arrays.asList(
Arrays.asList(6, 8),
Arrays.asList(4)
));
assertEquals(new Integer(6), flattenList.next());
assertEquals(new Integer(8), flattenList.next());
assertEquals(new Integer(4), flattenList.next());
assertEquals(false, flattenList.hasNext());
}
}
Repdeloresrdaniels, Cloud Support Associate at JDA
Crossed the country marketing wool in Nigeria. Was quite successful How to Get Girlfriend Back By Vashikaran Mantra . Spent a ...
Repjbacklit, abc at 247quickbookshelp
I am working as a news anchor and i love my job i an working from last 4 years under ...
Repmakaylamelua, Blockchain Developer at AMD
I am a sound editing and music composer with experience of handling a wide variety of programs.During my free ...
Repjaydkelvey, Accountant at Apkudo
I am 34 years old and live in Houston with my family. I am working as a Human resources consultant ...
RepJaneBraun, Associate at ASAPInfosystemsPvtLtd
Hi, I am Jane From York,PA.My goal is to create a life that I don’t want to ...
Replisapyara, abc at 247quickbookshelp
I am motivated and organized professional with proven years of experience in mail services and industry having vast experience as ...
Repamysamson688, Accountant
Hi, I am an art teacher, good in all areas of art history, from ancient art through to contemporary art ...
Repleancpuryear, Data Scientist at Adjetter Media Network Pvt Ltd.
Hi guys!! My name is Lean C Puryear and I love fashion, I hope to some day get into the ...
RepSpent 2001-2004 selling UFOs for the government. Have some experience with Internet Marketing Services New York. Set new standards for ...
Repceciliajbaker24, Area Sales Manager at ABC TECH SUPPORT
I work as an Aide at the Alhambra Maker-space, consulting ASU students who come into the space with their projects ...
this would only cater for the case of finding "direct" children/parents, the questions of the OP says "all the children nodes and all the parents"...
- jeso April 28, 2013