jeso
BAN USER
- 8of 10 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());
}
}
RepVickiShaw, abc at 8x8
I'm a virtual cartographer, navigating the terrain of pixels and polygons in the vast realm of map editing. My ...
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 ...
Repabigailbeyer415, Data entry keyer at Opentable
Outside the world of data entry, I find joy and relaxation in a unique hobby—Reddy Anna Casino. Whether it ...
RepVirginiaSlifer, Analyst at A9
In my professional life, I am a dedicated genetics nurse with a deep interest in understanding the intricacies of human ...
RepGladysPhillips, Associate at ADP
I have dedicated my professional career to fostering vibrant and harmonious communities.I have successfully navigated the complexities of community ...
RepMixMaster, abc at A9
I am mixmaster , a compassionate and dedicated Addictions Nurse with a deep understanding of the intricate challenges associated with addiction ...
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