PayPal Interview Question
Web Developers{
//Find unique pair in an array
int[] findPair = {3,7,2,5,6,4,3,5,4};
int length = findPair.length;
List<Integer> myList = new ArrayList<Integer>();
for(int i = 0; i < length; i++){
if(myList.contains(i))
continue;
for(int j = i+1; j < length; j++){
if(myList.contains(j))
continue;
if((findPair[i]+findPair[j]) == 9){
System.out.println("Found Pair " + findPair[i] + ","+ findPair[j]);
myList.add(findPair[i]);
myList.add(findPair[j]);
}
}
}
}
<pre lang="" line="1" title="CodeMonkey68078" class="run-this"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- Anonymous August 03, 2011<html>
<head>
<title>Javascript Tabbed Forms</title>
<style>
div.tabs {
font-size: 80%;
font-weight: bold;
}
.label {
background-color: #CCCCCC;
border: none;
}
a.tab {
background-color: #f0f0f0;
border: 1px solid #000000;
border-bottom-width: 0px;
padding: 2px 1em 2px 1em;
text-decoration: none;
}
a.tab, a.tab:visited {
color: #808080;
}
a.tab:hover {
background-color: #d0d0d0;
color: #606060;
}
/*
* note that by default all tab content areas
* have display set to 'none'
*/
div.tabContent {
padding: 4px;
border: 2px solid #000000;
background-color: #CCCCCC;
display: none;
}
</style>
<script>
// this is a bit of a hack here
// just list the tab content divs here
var tabs = ["tab1","tab2"];
function showTab( tab ){
// first make sure all the tabs are hidden
for(i=0; i < tabs.length; i++){
var obj = document.getElementById(tabs[i]);
obj.style.display = "none";
}
// show the tab we're interested in
var obj = document.getElementById(tab);
obj.style.display = "block";
document.forms["myForm2"]["fieldThree"].value = document.forms["myForm"]["fieldOne"].value;
}
</script>
</head>
<body>
<h1>Javascript Tabbed Forms</h1>
<hr/>
<div class="tabs">
<a class="tab" onclick="showTab('tab1')">Tab One</a>
<a class="tab" onclick="showTab('tab2')">Tab Two</a>
</div>
<!-- note that for the first tab we need to
manually set the display to visible -->
<div id="tab1" class="tabContent" style="display:block">
<form name="myForm" action="javascript:void();" onSubmit="showTab('tab2')">
<table>
<tr>
<td>Name: </td>
<td><input type="text" name="fieldOne" required /></td>
</tr>
<tr>
<td>Address: </td>
<td><input type="text" name="fieldTwo" required /></td>
</tr>
</table>
<input type="submit" value="Submit">
</form>
</div>
<div id="tab2" class="tabContent">
<form name="myForm2" onSubmit="alert('Form saved successfully!');">
<table>
<tr>
<td>The information you have submitted is: </td>
<td><input class="label" readonly type="text" name="fieldThree"/></td>
</tr>
</table>
<input type="button" value="Back to form" onClick="showTab('tab1');">
<input type="submit" value="Save form">
</form>
</div>
<hr>
</body>
</html>
</pre><pre title="CodeMonkey68078" input="yes">
</pre>