<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>write a c program to find the intersection of the two given rectangles. - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/write-a-c-program-to-find-the-intersection-of-the-two-given-rectangles/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/write-a-c-program-to-find-the-intersection-of-the-two-given-rectangles/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Sat, 11 Sep 2021 11:19:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>write a c program to find the intersection of the two given rectangles. - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/write-a-c-program-to-find-the-intersection-of-the-two-given-rectangles/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to check if two rectangles intersect or not ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 23:34:06 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[area of intersection of two rectangles]]></category>
		<category><![CDATA[area of intersection of two rectangles python]]></category>
		<category><![CDATA[area of overlapping rectangles algorithm]]></category>
		<category><![CDATA[area of overlapping rectangles java]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[check if two rotated rectangles intersect]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[determine if two rectangles overlap python]]></category>
		<category><![CDATA[find the intersection of two rectangles c]]></category>
		<category><![CDATA[FIS Global Business Solutions India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[how to find intersection of two rectangles in c]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[intersection of rectangles in c]]></category>
		<category><![CDATA[intersection of two rectangles in c]]></category>
		<category><![CDATA[L&T Infotech interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[overlapping rectangles]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[RBS India De interview questions and answers]]></category>
		<category><![CDATA[rectangle intersection algorithm]]></category>
		<category><![CDATA[rectangle overlap area c++]]></category>
		<category><![CDATA[rectangle overlap leetcode]]></category>
		<category><![CDATA[rectangle overlap lintcode]]></category>
		<category><![CDATA[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[to check if two rectangles are intersecting or not]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Virtusa Consulting Services Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Wells Fargo interview questions and answers]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[write a c program to find the intersection of the two given rectangles.]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=647</guid>

					<description><![CDATA[Answer : The following standard Java coding practices to solve...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-check-if-two-rectangles-intersect-or-not" class="color-pink" style="text-align: justify;">How to check if two rectangles intersect or not ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>The following standard Java coding practices to solve this problem.</li>
<li>We have an encapsulated two co-ordinates in a Point class and have Rectangle has two Point <a href="https://www.wikitechy.com/tutorials/ruby-on-rails/avoid-instance-variables-use-getters-and-setters" target="_blank" rel="noopener">instance variable</a> and an instance method like <a href="https://www.wikitechy.com/tutorials/java/java-strings-equals" target="_blank" rel="noopener">equals()</a> to check if another rectangle is overlapping or not.</li>
</ul>
</li>
</ul>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not.jpg" alt=" To Check Rectangle Intersects or Not" /></div>
</div>
<ul>
<li>A rectangle can be represented by two coordinates, top left, and bottom right. As part of the problem you will be given four coordinates L1, R1 and L2, R2, top left and bottom right coordinate of two rectangles and you need to write a function isOverlapping() which should return true if rectangles are overlapping or false if they are not.</li>
</ul>
</div>
</div>
<div class="text-center row" style="text-align: justify;"></div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-java" class="color-blue" style="text-align: justify;">Sample Code in Java:</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">public class Main {<br/><br/>  public static void main(String[] args) {<br/>  Point l1 = new Point(0, 10);<br/>  Point r1 = new Point(10, 0);<br/>  Point l2 = new Point(5, 5);<br/>  Point r2 = new Point(15, 0);<br/><br/>  Rectangle first = new Rectangle(l1, r1);<br/>  Rectangle second = new Rectangle(l2, r2);<br/><br/>  if (first.isOverLapping(second)) {<br/>  System.out<br/>  .println(&quot;Yes, two rectangles are intersecting with each other&quot;);<br/>  } else {<br/>  System.out<br/>  .println(&quot;No, two rectangles are not overlapping with each other&quot;);<br/>  }<br/>  }<br/><br/>}<br/><br/>class Point {<br/>  int x;<br/>  int y;<br/><br/>  public Point(int x, int y) {<br/>  super();<br/>  this.x = x;<br/>  this.y = y;<br/>  }<br/>}<br/><br/>class Rectangle {<br/><br/>  private final Point topLeft;<br/>  private final Point bottomRight;<br/><br/>  public Rectangle(Point topLeft, Point bottomRight) {<br/>  this.topLeft = topLeft;<br/>  this.bottomRight = bottomRight;<br/>  }<br/><br/>  public boolean isOverLapping(Rectangle other) {<br/>  if (this.topLeft.x &gt; other.bottomRight.x // R1 is right to R2<br/>  || this.bottomRight.x &lt; other.topLeft.x // R1 is left to R2<br/>  || this.topLeft.y &lt; other.bottomRight.y // R1 is above R2<br/>  || this.bottomRight.y &gt; other.topLeft.y) { // R1 is below R1<br/>  return false;<br/>  }<br/>  return true;<br/>  }<br/><br/>}</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs javascript" data-lang=""><span class="nt">Yes, two rectangles are intersecting <span class="hljs-keyword">with</span> each other</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
