Find Kth Largest Sum Pair
Given two arrays sorted in ascending order, we want to find the Kth
largest sum such that one element is picked from 1st array and the second
element is picked from the 2nd array.
I am already aware of the O(Klogk) solution , using Max-Heap given here .
I've read somewhere that there exists a O(k) solution for this (using two
pointers may be) , which i am unable to figure out .
Any ideas/approaches people ?
Busler
Sunday, 1 September 2013
Saturday, 31 August 2013
bootstrap css data load
bootstrap css data load
i am using bootstrap framework for college project
i have data 50+
<div class="span12">
<div class="span4">
--- data ---
</div>
<div class="span4">
--- data ---
</div>
<div class="span4">
--- data ---
</div>
</div>
i want that every row only 4 data. after four data it will create new row
ie new
<div class="span12">
i am not able to do it dynamically plz help.
i tried this but didnt worked
if(mysql_num_rows($country)>0)
{
while($row=mysql_fetch_array($country))
{
$c=0;
echo "<div class='span12'>";
if($c==0 || $c==1 || $c==2)
{
echo "<div
class='span4'>".$row['countryName']."</div>";
$c++;
}
else
{
echo "</div>";
}
}
}
i am using bootstrap framework for college project
i have data 50+
<div class="span12">
<div class="span4">
--- data ---
</div>
<div class="span4">
--- data ---
</div>
<div class="span4">
--- data ---
</div>
</div>
i want that every row only 4 data. after four data it will create new row
ie new
<div class="span12">
i am not able to do it dynamically plz help.
i tried this but didnt worked
if(mysql_num_rows($country)>0)
{
while($row=mysql_fetch_array($country))
{
$c=0;
echo "<div class='span12'>";
if($c==0 || $c==1 || $c==2)
{
echo "<div
class='span4'>".$row['countryName']."</div>";
$c++;
}
else
{
echo "</div>";
}
}
}
JSP2 Expression Language
JSP2 Expression Language
I read tutorials at courses.coreservlets.com (it is on a PDF file so I
cannot directly link the exact part of the topic). On JSP2 Expression
Language topic, the author shows comparison between JSP1.2 and JSP2
On JSP1.2
<BODY>
<jsp:useBean id="randomNum"
type="coreservlets.NumberBean"
scope="request" />
<H2>Random Number:
<jsp:getProperty name="randomNum"
property="number" />
</H2>
</BODY></HTML>
On JSP2
<BODY>
<H2>Random Number:
${randomNum.number}
</H2>
</BODY></HTML>
randomNum is just a variable name of NumberBean class right? On jsp1.2 it
shows, but on JSP2 its just a one line.
My question is on jsp2 how will server know that randomNum is NumberBean
because I did not see any part of the code that will tell that randomNum
is NumberBean?
I hope I made question clear.
Thanks..
I read tutorials at courses.coreservlets.com (it is on a PDF file so I
cannot directly link the exact part of the topic). On JSP2 Expression
Language topic, the author shows comparison between JSP1.2 and JSP2
On JSP1.2
<BODY>
<jsp:useBean id="randomNum"
type="coreservlets.NumberBean"
scope="request" />
<H2>Random Number:
<jsp:getProperty name="randomNum"
property="number" />
</H2>
</BODY></HTML>
On JSP2
<BODY>
<H2>Random Number:
${randomNum.number}
</H2>
</BODY></HTML>
randomNum is just a variable name of NumberBean class right? On jsp1.2 it
shows, but on JSP2 its just a one line.
My question is on jsp2 how will server know that randomNum is NumberBean
because I did not see any part of the code that will tell that randomNum
is NumberBean?
I hope I made question clear.
Thanks..
Do I need to specify a webpage's url?
Do I need to specify a webpage's url?
pI've uploaded several files to my server and it's really quite baffling.
The home page is saved as codeindex.html/code, and when I type in the URL
of said page it miraculously, and quite successfully shows the right page.
What about my other pages? I have linked to them from the home page with
the following code:/p pcodelt;a href=http://www.example.com/about/gt;About
Uslt;/agt;/code/p pHow does my html file, presumably called about.html,
supposed to know that its URL is a href=http://www.example.com/about/
rel=nofollowhttp://www.example.com/about//a? I am dubbing this The
Unanswered Question because I have looked at numerous examples of metadata
and there is nothing about specifying the URL of a page./p
pI've uploaded several files to my server and it's really quite baffling.
The home page is saved as codeindex.html/code, and when I type in the URL
of said page it miraculously, and quite successfully shows the right page.
What about my other pages? I have linked to them from the home page with
the following code:/p pcodelt;a href=http://www.example.com/about/gt;About
Uslt;/agt;/code/p pHow does my html file, presumably called about.html,
supposed to know that its URL is a href=http://www.example.com/about/
rel=nofollowhttp://www.example.com/about//a? I am dubbing this The
Unanswered Question because I have looked at numerous examples of metadata
and there is nothing about specifying the URL of a page./p
Where does phpMyAdmin store the phpMyAdmin user password?
Where does phpMyAdmin store the phpMyAdmin user password?
During the setup of phpMyAdmin, a phpMyAdmin user was created and I can
see the user when I look at the phpMyAdmin database privileges. Which PHP
file stores the password for this user?
During the setup of phpMyAdmin, a phpMyAdmin user was created and I can
see the user when I look at the phpMyAdmin database privileges. Which PHP
file stores the password for this user?
Ant detects non-existent package while IDE shows error
Ant detects non-existent package while IDE shows error
My ant build is working fine (compile, jar goals execute without errors).
However, the IDE shows errors in the code. I have tried Eclipse and
IntelliJ-IDEA; both show the same behaviour.
For example, in the following line
import com.google.javascript.rhino.head.ErrorReporter;
my IDE points out that the package com.google.javascript.rhino.head does
not exist. And it is true as I verified that no such package exists at
that location.
I would like to configure my IDE to build correctly so that I can use
debug features. What am I missing here?
My ant build is working fine (compile, jar goals execute without errors).
However, the IDE shows errors in the code. I have tried Eclipse and
IntelliJ-IDEA; both show the same behaviour.
For example, in the following line
import com.google.javascript.rhino.head.ErrorReporter;
my IDE points out that the package com.google.javascript.rhino.head does
not exist. And it is true as I verified that no such package exists at
that location.
I would like to configure my IDE to build correctly so that I can use
debug features. What am I missing here?
Start transaction in one action class and commit it on another in struts 2
Start transaction in one action class and commit it on another in struts 2
I am writting a code in an action class to insert a record in database but
not commit it at the same time as I want to commit it later after some
other record has been inserted using a different action class. I am new to
hibernate and don't know how to do this. Please, guide me. I am using
struts 2.Thanks in advance. I am using the following code in an Action to
insert a record in database without commiting
public void addExamDetails( ExamDetails examDetails){
try {
sessionFactory = new
Configuration().configure().buildSessionFactory();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
session.save(examDetails);
} catch (Exception e) {
System.out.println("ExamDetailsDAO.addExamDetails()");
e.printStackTrace();
}
}
After this, in another action class I am writting the following code to
insert other record and commiting at the same time but I am not able to
commit the previous insertion
public void addExamShift( ExamShift examShift){
try {
sessionFactory = new
Configuration().configure().buildSessionFactory();
session = sessionFactory.getCurrentSession();
transaction = session.getTransaction();
transaction.begin();
session.save(examShift);
transaction.commit();
} catch (Exception e) {
System.out.println("ExamShiftDAO.addExamShift()");
e.printStackTrace();
}
}
I am writting a code in an action class to insert a record in database but
not commit it at the same time as I want to commit it later after some
other record has been inserted using a different action class. I am new to
hibernate and don't know how to do this. Please, guide me. I am using
struts 2.Thanks in advance. I am using the following code in an Action to
insert a record in database without commiting
public void addExamDetails( ExamDetails examDetails){
try {
sessionFactory = new
Configuration().configure().buildSessionFactory();
session = sessionFactory.getCurrentSession();
transaction = session.beginTransaction();
session.save(examDetails);
} catch (Exception e) {
System.out.println("ExamDetailsDAO.addExamDetails()");
e.printStackTrace();
}
}
After this, in another action class I am writting the following code to
insert other record and commiting at the same time but I am not able to
commit the previous insertion
public void addExamShift( ExamShift examShift){
try {
sessionFactory = new
Configuration().configure().buildSessionFactory();
session = sessionFactory.getCurrentSession();
transaction = session.getTransaction();
transaction.begin();
session.save(examShift);
transaction.commit();
} catch (Exception e) {
System.out.println("ExamShiftDAO.addExamShift()");
e.printStackTrace();
}
}
Subscribe to:
Comments (Atom)