<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2099323611936963033</id><updated>2024-09-12T10:10:27.448+05:30</updated><category term="String"/><category term="Array"/><category term="C"/><category term="Google Code Jam"/><category term="Recursion"/><category term="codejam"/><category term="Adobe"/><category term="Interview Questions"/><category term="Microsoft"/><category term="Permutation"/><category term="Sorting"/><category term="amazon"/><category term="pattern"/><category term="Anagram"/><category term="Cassandra"/><category term="Codeing"/><category term="Connected Set"/><category term="Decoding"/><category term="Duplicate"/><category term="Google"/><category term="Linkedlist"/><category term="NoSQL"/><category term="Number Game"/><category term="Password"/><category term="Pythagorean triples"/><category term="Reverse"/><category term="STRING MASKING"/><category term="Tic Tac Toe"/><category term="Triangle"/><category term="Valid"/><category term="atoi"/><category term="find coordinate"/><category term="image"/><category term="matrix"/><category term="palindrome"/><category term="python"/><category term="rotation"/><title type='text'>CODES</title><subtitle type='html'>some learning from problems.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-9011155239297717260</id><published>2015-11-17T18:13:00.000+05:30</published><updated>2015-11-17T18:13:30.737+05:30</updated><title type='text'>PERL SCRIPT for killing CLOSE_WAIT</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Some time our application gets chocked because of large number of connection in COSE WAIT state, In such case there is only way to get rid of it by closing application, but in production we cann&#39;t kill our application this frequently, so here is a hack I come accross for it.&lt;br /&gt;
&lt;br /&gt;
Ultimate solution :: optimise and find reason in your application.&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
netstat -tulnap | grep CLOSE_WAIT | awk &#39;{print $4,$5}&#39; | &amp;nbsp;sed &#39;s/:/ /g&#39; | awk &#39;{print $2, $3, $5, $6}&#39;| &amp;nbsp;while read line; do&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo $line&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; perl kill_cw.pl $line;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/perl-Net-RawIP-0.25-1.el6.rf.x86_64.rpm&lt;br /&gt;
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/perl-Net-Pcap-0.16-1.el6.rf.x86_64.rpm&lt;br /&gt;
wget http://www6.atomicorp.com/channels/atomic/centos/6/i386/RPMS/perl-NetPacket-0.41.1-1.el6.art.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
rpm -Uvh &amp;nbsp;perl-Net-RawIP-0.25-1.el6.rf.x86_64.rpm&lt;br /&gt;
rpm -Uvh perl-Net-Pcap-0.16-1.el6.rf.x86_64.rpm&lt;br /&gt;
yum install perl-Net-Pcap&lt;br /&gt;
&lt;br /&gt;
rpm -Uvh &amp;nbsp;perl-NetPacket-0.41.1-1.el6.art.noarch.rpm&lt;br /&gt;
&lt;br /&gt;
(http://pkgs.org/centos-6/atomic-i386/perl-NetPacket-0.41.1-1.el6.art.noarch.rpm.html)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/9011155239297717260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2015/11/perl-script-for-killing-closewait.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/9011155239297717260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/9011155239297717260'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2015/11/perl-script-for-killing-closewait.html' title='PERL SCRIPT for killing CLOSE_WAIT'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-8107988864850741563</id><published>2013-12-20T20:30:00.001+05:30</published><updated>2013-12-20T20:34:37.008+05:30</updated><title type='text'>Install PhantomJS on Ubuntu</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; white-space: normal;&quot;&gt;
cd /usr/local/share&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; white-space: normal;&quot;&gt;
sudo wget http://phantomjs.googlecode.com/files/phantomjs-1.9.2-linux-x86_64.tar.bz2&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; white-space: normal;&quot;&gt;
sudo tar xjf phantomjs-1.9.2-linux-x86_64.tar.bz2&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; white-space: normal;&quot;&gt;
sudo ln -s /usr/local/share/phantomjs-1.9.2-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; white-space: normal;&quot;&gt;
sudo ln -s /usr/local/share/phantomjs-1.9.2-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; white-space: normal;&quot;&gt;
sudo ln -s /usr/local/share/phantomjs-1.9.2-linux-x86_64/bin/phantomjs /usr/bin/phantomjs&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
on this,&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;phantomjs -v&lt;/code&gt;&lt;/pre&gt;
it will give&lt;br /&gt;
&lt;b&gt;1.9.2&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/8107988864850741563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2013/12/install-phantomjs-on-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8107988864850741563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8107988864850741563'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2013/12/install-phantomjs-on-ubuntu.html' title='Install PhantomJS on Ubuntu'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-1017589877009152629</id><published>2013-10-22T15:04:00.002+05:30</published><updated>2013-10-22T22:42:15.185+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cassandra"/><category scheme="http://www.blogger.com/atom/ns#" term="NoSQL"/><title type='text'>Some learning on Cassandra - I</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;In this post we will not talk about &amp;nbsp;&lt;span style=&quot;background-color: white; color: #222222; font-family: &#39;Lucida Grande&#39;, &#39;Lucida Sans Unicode&#39;, Helvetica, Arial, sans-serif;&quot;&gt;&lt;b&gt;Cassandra –&amp;nbsp;Data&amp;nbsp;Model,&amp;nbsp;&lt;/b&gt;&lt;/span&gt;There are many blogs on them and one of the best describe is by &lt;a href=&quot;http://anismiles.wordpress.com/2010/05/18/cassandra-data-model/&quot; target=&quot;_blank&quot;&gt;Animesh Kumar&lt;/a&gt;, oh yup Animesh sir is my collage(ISM) senior.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;
How should we store Object&lt;span style=&quot;font-size: x-small;&quot;&gt;*&lt;/span&gt;&amp;nbsp;into Cassandra database ?&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;*object: like a list&amp;lt;String&amp;gt;,&amp;nbsp;instances&amp;nbsp;of a class, etc&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote style=&quot;background-color: white; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; color: #222222; font-family: arial; font-size: small; margin: 0px 0px 0px 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;; font-size: small;&quot;&gt;poor approach:&lt;/span&gt;&lt;/blockquote&gt;
&lt;pre class=&quot; language-java&quot; style=&quot;-webkit-hyphens: none; background-color: #f5f2f0; border: 0px; direction: ltr; margin-bottom: 0.5em; margin-top: 0.5em; overflow: auto; padding: 1em; tab-size: 4; text-shadow: white 0px 1px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: 14px; line-height: 17px;&quot;&gt;Serialize the Object into JSON.
Now store this JSON as a string into Cassandra.
When need to get the object, read JSON string, deserialize the JSON.&lt;/span&gt;&lt;/pre&gt;
The above approach is fine and works well, but It have its own disadvantage. Say we have&lt;br /&gt;
Object(as JSON):&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; name: &quot;nijju&quot;&lt;br /&gt;
&amp;nbsp; country: &quot;IN&quot;&lt;br /&gt;
&amp;nbsp; email: &quot;niraj.nijju@gmail.com&quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
and we store it into a column into cassandra( as string).&lt;br /&gt;
When we need to update a field say country then we need to read the whole JSON string, then we need to deserialize it, and then to change the object attribute and again serialize the resulting object into JSON and storing this JSON at that key.&lt;br /&gt;
&lt;br /&gt;
As in cassandra write is much faster than read operation, so making a read before write will not be a good approach.&lt;br /&gt;
Even if your application is mostly write-once data then for reading a single field will make to read all.&lt;br /&gt;
&lt;br /&gt;
In conclusion, we can better performance by storing all the fields into a separate column. For making an update on a field we only need to re-write the corresponding column.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white;&quot;&gt;
A&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;mong the given two ways, what is the better method to store into cassandra ?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote style=&quot;border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; color: #222222; margin: 0px 0px 0px 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;Storing 1 millions of rows with 10 column each.&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote style=&quot;border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; color: #222222; margin: 0px 0px 0px 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;Storing 100 of row with 100K columns each.&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/ul&gt;
It totally depends on our read behavior, as rows will be store on random disk, so reading from various rows at same time will be slow.&lt;br /&gt;
and If rows will be too long then these columns will be stored together on same node so we may have scalability challenges. &lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;i style=&quot;background-color: #fefdfa; color: #333333; font-family: sans-serif; font-size: 13px; line-height: 17px; text-align: center;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Let me know your thoughts&lt;/i&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/1017589877009152629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2013/10/some-learning-on-cassandra-i.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/1017589877009152629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/1017589877009152629'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2013/10/some-learning-on-cassandra-i.html' title='Some learning on Cassandra - I'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-5113329672179251318</id><published>2013-09-28T20:00:00.000+05:30</published><updated>2013-09-30T11:26:40.340+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Python script for get the files_from_directory, using_grep_on_file, on_day_increment</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;How can I find all files in directory with the extension .txt in python?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/3964681/find-all-files-in-directory-with-extension-txt-with-python&quot;&gt;http://stackoverflow.com/questions/3964681/find-all-files-in-directory-with-extension-txt-with-python&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;lang-py prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; os
#&lt;strike&gt;os&lt;/strike&gt;&lt;/span&gt;&lt;strike&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;chdir&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;/mydir&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;/strike&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; files &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;*.txt&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; files&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;python grep on file&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;pre class=&quot;bbcode_code&quot; style=&quot;background-color: #efefef; background-image: none; background-repeat: repeat no-repeat; border: 1px inset; direction: ltr; font-family: &#39;Ubuntu Mono&#39;, monospace; font-size: 14px; height: 60px; line-height: 14.399999618530273px; overflow: auto; padding: 6px; word-wrap: normal;&quot;&gt;for line in open(&quot;file_name&quot;):
 if &quot;search_string&quot; in line:
   print line&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Python increment day in datetime:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;lang-py prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; line-height: 17.27272605895996px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; color: darkblue; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; datetime
today = datetime.datetime.today()
&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;today += datetime&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;timedelta&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;days&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;background-color: transparent; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/5113329672179251318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2013/09/python-script-for-get.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/5113329672179251318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/5113329672179251318'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2013/09/python-script-for-get.html' title='Python script for get the files_from_directory, using_grep_on_file, on_day_increment'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-2140663914449333396</id><published>2013-04-14T15:47:00.000+05:30</published><updated>2013-04-17T11:21:21.679+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="codejam"/><category scheme="http://www.blogger.com/atom/ns#" term="Google Code Jam"/><title type='text'>Google Code Jam Problem C. Fair and Square</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;background-color: white; border: 0px; margin: 0px; outline: 0px; padding: 0px 0px 8px; position: relative; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;Below is my solution for&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: Arial, sans-serif; font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif;&quot;&gt;Problem&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;C.&amp;nbsp;&lt;a href=&quot;https://code.google.com/codejam/contest/2270488/dashboard#s=p2&quot; style=&quot;color: #7d181e; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Fair and Square&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;Well I qualified for&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://code.google.com/codejam/&quot; style=&quot;border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Google Code Jam 2013&lt;/a&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;&amp;nbsp;with only 60 points.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;* Still to add method to handle Large Input 2.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial, sans-serif;&quot;&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;br /&gt;&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal; margin: 0px; position: relative;&quot;&gt;
Problem&lt;/h3&gt;
&lt;div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
Little John likes palindromes, and thinks them to be fair (which is a fancy word for nice). A&lt;i&gt;palindrome&lt;/i&gt;&amp;nbsp;is just an integer that reads the same backwards and forwards - so 6, 11 and 121 are all palindromes, while 10, 12, 223 and 2244 are not (even though 010=10, we don&#39;t consider leading zeroes when determining whether a number is a palindrome).&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
He recently became interested in squares as well, and formed the definition of a&amp;nbsp;&lt;i&gt;fair and square&lt;/i&gt;&amp;nbsp;number - it is a number that is a palindrome&amp;nbsp;&lt;b&gt;and&lt;/b&gt;&amp;nbsp;the&amp;nbsp;&lt;i&gt;square of a palindrome&lt;/i&gt;&amp;nbsp;at the same time. For instance, 1, 9 and 121 are fair and square (being palindromes and squares, respectively, of 1, 3 and 11), while 16, 22 and 676 are&amp;nbsp;&lt;b&gt;not&lt;/b&gt;&amp;nbsp;fair and square: 16 is not a palindrome, 22 is not a square, and while 676 is a palindrome and a square number, it is the square of 26, which is not a palindrome.&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
Now he wants to search for bigger fair and square numbers. Your task is, given an interval Little John is searching through, to tell him how many fair and square numbers are there in the interval, so he knows when he has found them all.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal; margin: 0px; position: relative;&quot;&gt;
Solving this problem&lt;/h3&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
Usually, Google Code Jam problems have 1 Small input and 1 Large input. This problem has 1 Small input and 2 Large inputs. Once you have solved the Small input, you will be able to download any of the two Large inputs. As usual, you will be able to retry the Small input (with a time penalty), while you will get only one chance at each of the Large inputs.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal; margin: 0px; position: relative;&quot;&gt;
Input&lt;/h3&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;lines follow. Each line contains two integers,&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;- the endpoints of the interval Little John is looking at.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal; margin: 0px; position: relative;&quot;&gt;
Output&lt;/h3&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
For each test case, output one line containing &quot;Case #x: y&quot;, where x is the case number (starting from 1) and y is the number of fair and square numbers greater than or equal to&lt;b&gt;A&lt;/b&gt;&amp;nbsp;and smaller than or equal to&amp;nbsp;&lt;b&gt;B&lt;/b&gt;.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal; margin: 0px; position: relative;&quot;&gt;
Limits&lt;/h3&gt;
&lt;h4 style=&quot;color: #d52a33; font-family: Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif; font-size: 14.545454025268555px; font-weight: normal; line-height: normal; margin: 0px; position: relative;&quot;&gt;
Small dataset&lt;/h4&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 100.&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;≤ 1000.&lt;/div&gt;
&lt;h4 style=&quot;color: #d52a33; font-family: Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif; font-size: 14.545454025268555px; font-weight: normal; line-height: normal; margin: 0px; position: relative;&quot;&gt;
First large dataset&lt;/h4&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 10000.&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;≤ 10&lt;sup&gt;14&lt;/sup&gt;.&lt;/div&gt;
&lt;h4 style=&quot;color: #d52a33; font-family: Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif; font-size: 14.545454025268555px; font-weight: normal; line-height: normal; margin: 0px; position: relative;&quot;&gt;
Second large dataset&lt;/h4&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 1000.&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;A&lt;/b&gt;&amp;nbsp;≤&amp;nbsp;&lt;b&gt;B&lt;/b&gt;&amp;nbsp;≤ 10&lt;sup&gt;100&lt;/sup&gt;.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal; margin: 0px; position: relative;&quot;&gt;
Sample&lt;/h3&gt;
&lt;div class=&quot;problem-io-wrapper&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 467.9971618652344px;&quot;&gt;
&lt;table style=&quot;border-collapse: collapse; border-width: 0pt; font-size: small; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;io-table-header&quot; style=&quot;font-size: 12.727272033691406px;&quot;&gt;Input&lt;/span&gt;&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;io-table-header&quot; style=&quot;font-size: 12.727272033691406px;&quot;&gt;Output&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;code style=&quot;font-family: &#39;bogus font here&#39;, monospace; font-size: 12.727272033691406px;&quot;&gt;3&lt;br /&gt;1 4&lt;br /&gt;10 120&lt;br /&gt;100 1000&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;code style=&quot;font-family: &#39;bogus font here&#39;, monospace; font-size: 12.727272033691406px;&quot;&gt;Case #1: 2&lt;br /&gt;Case #2: 0&lt;br /&gt;Case #3: 2&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;div&gt;
&lt;i&gt;Input is taken from a file(C-small-practice.in)&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;b&gt;Method 1:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;* @author niraj.nijju&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;package gcj.TwelveThirteen;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.BufferedReader;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.DataInputStream;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.FileInputStream;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.InputStreamReader;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;public class SmallOfFairAndSquare {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String [] args){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.println(Double.MAX_VALUE);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.exit(0);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;FileInputStream fstream = new FileInputStream(&quot;C-small-practice.in&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;DataInputStream in = new DataInputStream(fstream);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;BufferedReader br = new BufferedReader(new InputStreamReader(in));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;String strLine;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;strLine = br.readLine();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;int T = Integer.valueOf(strLine);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.out.println(&quot;T: &quot;+T);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;int i=1;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;while ((strLine = br.readLine()) != null) &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.out.println (strLine);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;String [] str = strLine.split(&quot; &quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;double x = Double.valueOf(str[0].trim() );&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;double y = Double.valueOf(str[1].trim() );&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;int count= getFairSqur(x,y);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: &quot;+count);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;in.close();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}catch (Exception e){//Catch exception if any&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.err.println(&quot;Error: &quot; + e.getMessage());&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;e.printStackTrace();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static int getFairSqur(double x, double y){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int count=0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;long x1 = (long)Math.ceil(Math.sqrt(x));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;long y1 = (long)Math.sqrt(y);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(long i=x1; i&amp;lt;=y1; i++ ){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(checkPalindrom(i)){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;long sq=i*i;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(checkPalindrom(sq)){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;System.out.println(&quot;(&quot;+i+&quot;)&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;count++;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return count;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp; public static Boolean checkPalindrom(long n)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String normal = String.valueOf(n);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//reverse the letters in string&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int length = normal.length(); //length of string&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;StringBuffer result = new StringBuffer(length);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int i;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(i = length - 1; i&amp;gt;=0; i--)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;result.append(normal.charAt(i));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;long r = Long.valueOf(result.toString());&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(r==n)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return true;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return false;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 12px;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;b&gt;Method 2:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Arial, sans-serif;&quot;&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;* @author niraj.nijju&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;package gcj.TwelveThirteen;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.BufferedReader;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.DataInputStream;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.FileInputStream;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.InputStreamReader;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;
&lt;/span&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;import org.omg.CORBA.INTERNAL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;public class CopyOfFairAndSquare {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static long [] array = new long[10000010];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String [] args){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;fillArray();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.println(Double.MAX_VALUE);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.exit(0);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;FileInputStream fstream = new FileInputStream(&quot;C-small-practice.in&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;DataInputStream in = new DataInputStream(fstream);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;BufferedReader br = new BufferedReader(new InputStreamReader(in));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;String strLine;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;strLine = br.readLine();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;int T = Integer.valueOf(strLine);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.out.println(&quot;T: &quot;+T);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;int i=1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;while ((strLine = br.readLine()) != null) &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.out.println (strLine);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;String [] str = strLine.split(&quot; &quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;double x = Double.valueOf(str[0].trim() );&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;double y = Double.valueOf(str[1].trim() );&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;//int count= getFairSqur(x,y);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;long count=0;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;int xr = (int)Math.sqrt(x);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;int yr = (int)Math.sqrt(y);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;count = array[yr]-array[xr];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;if(xr*xr == (int)x){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;nbsp;&amp;nbsp;if(checkPalindrom(xr) &amp;amp;&amp;amp; &amp;nbsp;checkPalindrom(xr*xr)){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&amp;nbsp;&amp;nbsp;count++;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: &quot;+count);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&amp;nbsp;in.close();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}catch (Exception e){//Catch exception if any&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;System.err.println(&quot;Error: &quot; + e.getMessage());&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;&amp;nbsp;e.printStackTrace();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void fillArray(){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;long count = 0;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=1;i&amp;lt;array.length;i++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;long j = (long)i;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(!checkPalindrom(j))&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;array[i]= count;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;else if(!checkPalindrom(j*j))&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;array[i]= count;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;else{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;count++;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;array[i]= count;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp; public static Boolean checkPalindrom(long n)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String normal = String.valueOf(n);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//reverse the letters in string&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int length = normal.length(); //length of string&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;StringBuffer result = new StringBuffer(length);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int i;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(i = length - 1; i&amp;gt;=0; i--)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;result.append(normal.charAt(i));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;long r=0;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;try{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;r= Long.valueOf(result.toString());&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}catch(Exception e){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;System.out.println(&quot;i:&quot;+i+&quot;\tr:&quot;+r+&quot;\tn:&quot;+n);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(r==n)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return true;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return false;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;div style=&quot;font-family: Arial, sans-serif;&quot;&gt;
&lt;div&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;
&lt;/span&gt;
&lt;div style=&quot;font-size: small;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/2140663914449333396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2013/04/google-code-jam-problem-c-fair-and-square-by-niraj-nijju.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/2140663914449333396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/2140663914449333396'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2013/04/google-code-jam-problem-c-fair-and-square-by-niraj-nijju.html' title='Google Code Jam Problem C. Fair and Square'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>4</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.5680234999999989 37.654286000000042 49.7553915 120.27147400000004</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-736029908042467951</id><published>2013-04-14T15:27:00.000+05:30</published><updated>2013-04-14T15:28:16.158+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="codejam"/><category scheme="http://www.blogger.com/atom/ns#" term="Google"/><category scheme="http://www.blogger.com/atom/ns#" term="Google Code Jam"/><title type='text'>Google Code Jam Problem B. Lawnmower</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;background-color: white; border: 0px; margin: 0px; outline: 0px; padding: 0px 0px 8px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;Below is my solution for&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Bitstream Charter, serif;&quot;&gt;Problem B:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #333333; font-family: Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;&lt;a href=&quot;https://code.google.com/codejam/contest/2270488/dashboard#s=p1&quot; target=&quot;_blank&quot;&gt;Lawnmower&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;Well I qualified for&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://code.google.com/codejam/&quot; style=&quot;background-color: white; border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Google Code Jam 2013&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;&amp;nbsp;with only 60 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;br /&gt;&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Problem&lt;/h3&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Problem&lt;/h3&gt;
Alice and Bob have a lawn in front of their house, shaped like an&amp;nbsp;&lt;b&gt;N&lt;/b&gt;&amp;nbsp;metre by&amp;nbsp;&lt;b&gt;M&lt;/b&gt;&amp;nbsp;metre rectangle. Each year, they try to cut the lawn in some interesting pattern. They used to do their cutting with shears, which was very time-consuming; but now they have a new automatic lawnmower with multiple settings, and they want to try it out.&lt;br /&gt;
The new lawnmower has a height setting - you can set it to any height&amp;nbsp;&lt;b&gt;h&lt;/b&gt;&amp;nbsp;between 1 and 100 millimetres, and it will cut all the grass higher than&amp;nbsp;&lt;b&gt;h&lt;/b&gt;&amp;nbsp;it encounters to height&amp;nbsp;&lt;b&gt;h&lt;/b&gt;. You run it by entering the lawn at any part of the edge of the lawn; then the lawnmower goes in a straight line, perpendicular to the edge of the lawn it entered, cutting grass in a swath 1m wide, until it exits the lawn on the other side. The lawnmower&#39;s height can be set only when it is not on the lawn.&lt;br /&gt;
Alice and Bob have a number of various patterns of grass that they could have on their lawn. For each of those, they want to know whether it&#39;s possible to cut the grass into this pattern with their new lawnmower. Each pattern is described by specifying the height of the grass on each 1m x 1m square of the lawn.&lt;br /&gt;
The grass is initially 100mm high on the whole lawn.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Input&lt;/h3&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow. Each test case begins with a line containing two integers:&amp;nbsp;&lt;b&gt;N&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;M&lt;/b&gt;. Next follow&amp;nbsp;&lt;b&gt;N&lt;/b&gt;&amp;nbsp;lines, with the&amp;nbsp;&lt;i&gt;i&lt;/i&gt;th line containing&amp;nbsp;&lt;b&gt;M&lt;/b&gt;&amp;nbsp;integers&amp;nbsp;&lt;b&gt;a&lt;sub&gt;i,j&lt;/sub&gt;&lt;/b&gt;&amp;nbsp;each, the number&amp;nbsp;&lt;b&gt;a&lt;sub&gt;i,j&lt;/sub&gt;&lt;/b&gt;&amp;nbsp;describing the desired height of the grass in the&amp;nbsp;&lt;i&gt;j&lt;/i&gt;th square of the&amp;nbsp;&lt;i&gt;i&lt;/i&gt;th row.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Output&lt;/h3&gt;
For each test case, output one line containing &quot;Case #x: y&quot;, where x is the case number (starting from 1) and y is either the word &quot;YES&quot; if it&#39;s possible to get the x-th pattern using the lawnmower, or &quot;NO&quot;, if it&#39;s impossible (quotes for clarity only).&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Limits&lt;/h3&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 100.&lt;br /&gt;
&lt;h4 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Small dataset&lt;/h4&gt;
1 ≤&amp;nbsp;&lt;b&gt;N&lt;/b&gt;,&amp;nbsp;&lt;b&gt;M&lt;/b&gt;&amp;nbsp;≤ 10.&lt;br /&gt;
1 ≤&amp;nbsp;&lt;b&gt;a&lt;sub&gt;i,j&lt;/sub&gt;&lt;/b&gt;&amp;nbsp;≤ 2.&lt;br /&gt;
&lt;h4 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Large dataset&lt;/h4&gt;
1 ≤&amp;nbsp;&lt;b&gt;N&lt;/b&gt;,&amp;nbsp;&lt;b&gt;M&lt;/b&gt;&amp;nbsp;≤ 100.&lt;br /&gt;
1 ≤&amp;nbsp;&lt;b&gt;a&lt;sub&gt;i,j&lt;/sub&gt;&lt;/b&gt;&amp;nbsp;≤ 100.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Sample&lt;/h3&gt;
&lt;div class=&quot;problem-io-wrapper&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 467.9971618652344px;&quot;&gt;
&lt;table style=&quot;border-collapse: collapse; border-width: 0pt; font-size: small; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;io-table-header&quot; style=&quot;font-size: 12.727272033691406px;&quot;&gt;Input&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;io-table-header&quot; style=&quot;font-size: 12.727272033691406px;&quot;&gt;Output&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;code style=&quot;font-family: &#39;bogus font here&#39;, monospace; font-size: 12.727272033691406px;&quot;&gt;3&lt;br /&gt;3 3&lt;br /&gt;2 1 2&lt;br /&gt;1 1 1&lt;br /&gt;2 1 2&lt;br /&gt;5 5&lt;br /&gt;2 2 2 2 2&lt;br /&gt;2 1 1 1 2&lt;br /&gt;2 1 2 1 2&lt;br /&gt;2 1 1 1 2&lt;br /&gt;2 2 2 2 2&lt;br /&gt;1 3&lt;br /&gt;1 2 1&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;code style=&quot;font-family: &#39;bogus font here&#39;, monospace; font-size: 12.727272033691406px;&quot;&gt;Case #1: YES&lt;br /&gt;Case #2: NO&lt;br /&gt;Case #3: YES&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;i&gt;Input is taken from a file(B-small-practice.in)&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;* @author niraj.nijju&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;*/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;&lt;span style=&quot;font-size: 12px;&quot;&gt;package gcj.TwelveThirteen;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.BufferedReader;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.DataInputStream;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.FileInputStream;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;import java.io.InputStreamReader;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;public class Lawnmower {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String [] args){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;FileInputStream fstream = new FileInputStream(&quot;B-small-practice.in&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;DataInputStream in = new DataInputStream(fstream);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;BufferedReader br = new BufferedReader(new InputStreamReader(in));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;String strLine;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;strLine = br.readLine();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;int T = Integer.valueOf(strLine);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;System.out.println(&quot;T: &quot;+T);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;int i=1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;while(T-- &amp;gt; 0){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;strLine = br.readLine();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;String [] nm = strLine.split(&quot; &quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;int n = Integer.valueOf(nm[0].trim());&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;int m = Integer.valueOf(nm[1].trim());&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;String [][] lawn = new String[n+1][m+1];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;for(int j=0;j&amp;lt;n;j++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;String ms = br.readLine();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;ms+= &quot; 0&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;lawn[j]=ms.split(&quot; &quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;if(canDo(lawn,n,m) ){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: YES&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;}else{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: NO&quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;in.close();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}catch (Exception e){//Catch exception if any&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;System.err.println(&quot;Error: &quot; + e.getMessage());&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;e.printStackTrace();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static Boolean canDo(String [][] lawn, int n, int m){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;getLargest(lawn,n,m);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=0;i&amp;lt;n;i++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(int j=0;j&amp;lt;m;j++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(Integer.valueOf(lawn[i][j])&amp;lt;Integer.valueOf(lawn[i][m])&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;&amp;amp;&amp;amp; Integer.valueOf(lawn[i][j]) &amp;lt;Integer.valueOf(lawn[n][j]) )&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;return false;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return true;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void getLargest(String [][] lawn,int n, int m){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=0;i&amp;lt;n;i++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;int hMax=0;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(int j=0;j&amp;lt;m;j++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;int val=Integer.valueOf(lawn[i][j]);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(hMax &amp;lt; val){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;hMax = val;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;lawn[i][m]=String.valueOf(hMax);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=0;i&amp;lt;m;i++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;int vMax=0;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(int j=0;j&amp;lt;n;j++){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;int val=Integer.valueOf(lawn[j][i]);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(vMax &amp;lt; val){&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;vMax = val;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;lawn[n][i]=String.valueOf(vMax);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-size: 12px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 12px;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: 12px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/736029908042467951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2013/04/Google-code-jam-problem-B-Lawnmower-by-niraj-nijju.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/736029908042467951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/736029908042467951'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2013/04/Google-code-jam-problem-B-Lawnmower-by-niraj-nijju.html' title='Google Code Jam Problem B. Lawnmower'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>2</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.5680234999999989 37.654286000000042 49.7553915 120.27147400000004</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-3717797058307455913</id><published>2013-04-14T15:18:00.000+05:30</published><updated>2013-04-14T15:18:16.921+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="codejam"/><category scheme="http://www.blogger.com/atom/ns#" term="Google Code Jam"/><category scheme="http://www.blogger.com/atom/ns#" term="Tic Tac Toe"/><title type='text'>Google Code Jam Problem A. Tic-Tac-Toe-Tomek</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;background-color: white; border: 0px; margin: 0px; outline: 0px; padding: 0px 0px 8px; text-rendering: optimizelegibility; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;Below is my solution for&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-size: 14px; font-weight: normal; line-height: 23px;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, Bitstream Charter, serif;&quot;&gt;Problem A: &lt;a href=&quot;https://code.google.com/codejam/contest/2270488/dashboard#s=p0&quot; target=&quot;_blank&quot;&gt;Tic-Tac-Toe-Tomek&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;Well I qualified for&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://code.google.com/codejam/&quot; style=&quot;background-color: white; border: 0px; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Google Code Jam 2013&lt;/a&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;&amp;nbsp;with only 60 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 14px; line-height: 23px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;br /&gt;
&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Problem&lt;/h3&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
Tic-Tac-Toe-Tomek is a game played on a 4 x 4 square board. The board starts empty, except that a single &#39;T&#39; symbol may appear in one of the 16 squares. There are two players: X and O. They take turns to make moves, with X starting. In each move a player puts her symbol in one of the empty squares. Player X&#39;s symbol is &#39;X&#39;, and player O&#39;s symbol is &#39;O&#39;.&lt;/div&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
After a player&#39;s move, if there is a row, column or a diagonal containing 4 of that player&#39;s symbols, or containing 3 of her symbols and the &#39;T&#39; symbol, she wins and the game ends. Otherwise the game continues with the other player&#39;s move. If all of the fields are filled with symbols and nobody won, the game ends in a draw. See the sample input for examples of various winning positions.&lt;/div&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
Given a 4 x 4 board description containing &#39;X&#39;, &#39;O&#39;, &#39;T&#39; and &#39;.&#39; characters (where &#39;.&#39; represents an empty square), describing the current state of a game, determine the status of the Tic-Tac-Toe-Tomek game going on. The statuses to choose from are:&lt;/div&gt;
&lt;ul style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;li style=&quot;margin-bottom: 0.25em;&quot;&gt;&quot;X won&quot; (the game is over, and X won)&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em;&quot;&gt;&quot;O won&quot; (the game is over, and O won)&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em;&quot;&gt;&quot;Draw&quot; (the game is over, and it ended in a draw)&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0.25em;&quot;&gt;&quot;Game has not completed&quot; (the game is not over yet)&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial, sans-serif; font-size: x-small;&quot;&gt;If there are empty cells, and the game is not over, you should output &quot;Game has not completed&quot;, even if the outcome of the game is inevitable.&lt;/span&gt;&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Input&lt;/h3&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
The first line of the input gives the number of test cases,&amp;nbsp;&lt;b&gt;T&lt;/b&gt;.&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;test cases follow. Each test case consists of 4 lines with 4 characters each, with each character being &#39;X&#39;, &#39;O&#39;, &#39;.&#39; or &#39;T&#39; (quotes for clarity only). Each test case is followed by an empty line.&lt;/div&gt;
&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Output&lt;/h3&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
For each test case, output one line containing &quot;Case #x: y&quot;, where x is the case number (starting from 1) and y is one of the statuses given above. Make sure to get the statuses exactly right. When you run your code on the sample input, it should create the sample output exactly, including the &quot;Case #1: &quot;, the capital letter &quot;O&quot; rather than the number &quot;0&quot;, and so on.&lt;/div&gt;
&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Limits&lt;/h3&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
The game board provided will represent a valid state that was reached through play of the game Tic-Tac-Toe-Tomek as described above.&lt;/div&gt;
&lt;h4 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Small dataset&lt;/h4&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 10.&lt;/div&gt;
&lt;h4 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Large dataset&lt;/h4&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
1 ≤&amp;nbsp;&lt;b&gt;T&lt;/b&gt;&amp;nbsp;≤ 1000.&lt;/div&gt;
&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Sample&lt;/h3&gt;
&lt;div&gt;
&lt;div class=&quot;problem-io-wrapper&quot; style=&quot;background-color: #efefef; border: 1px solid rgb(204, 204, 204); font-family: Arial, sans-serif; font-size: small; margin-bottom: 2em; overflow-x: auto; overflow-y: hidden; padding-bottom: 2em; width: 467.9971618652344px;&quot;&gt;
&lt;table style=&quot;border-collapse: collapse; border-width: 0pt; font-size: small; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;br /&gt;&lt;span class=&quot;io-table-header&quot; style=&quot;font-size: 12.727272033691406px;&quot;&gt;Input&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;br /&gt;&lt;span class=&quot;io-table-header&quot; style=&quot;font-size: 12.727272033691406px;&quot;&gt;Output&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px; vertical-align: top;&quot;&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;code style=&quot;font-family: &#39;bogus font here&#39;, monospace; font-size: 12.727272033691406px;&quot;&gt;6&lt;br /&gt;XXXT&lt;br /&gt;....&lt;br /&gt;OO..&lt;br /&gt;....&lt;br /&gt;&lt;br /&gt;XOXT&lt;br /&gt;XXOO&lt;br /&gt;OXOX&lt;br /&gt;XXOO&lt;br /&gt;&lt;br /&gt;XOX.&lt;br /&gt;OX..&lt;br /&gt;....&lt;br /&gt;....&lt;br /&gt;&lt;br /&gt;OOXX&lt;br /&gt;OXXX&lt;br /&gt;OX.T&lt;br /&gt;O..O&lt;br /&gt;&lt;br /&gt;XXXO&lt;br /&gt;..O.&lt;br /&gt;.O..&lt;br /&gt;T...&lt;br /&gt;&lt;br /&gt;OXXX&lt;br /&gt;XO..&lt;br /&gt;..O.&lt;br /&gt;...O&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;border-collapse: collapse; border-width: 0pt; margin: 0px; padding: 0px 1em; vertical-align: top;&quot;&gt;&lt;code style=&quot;font-family: &#39;bogus font here&#39;, monospace; font-size: 12.727272033691406px;&quot;&gt;Case #1: X won&lt;br /&gt;Case #2: Draw&lt;br /&gt;Case #3: Game has not completed&lt;br /&gt;Case #4: O won&lt;br /&gt;Case #5: O won&lt;br /&gt;Case #6: O won&lt;br /&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;h3 style=&quot;font-family: Arial, sans-serif; font-size: 14.545454025268555px; font-weight: normal;&quot;&gt;
Note&lt;/h3&gt;
&lt;div style=&quot;font-family: Arial, sans-serif; font-size: small;&quot;&gt;
Although your browser might not render an empty line after the last test case in the sample input, in a real input file there would be one.&lt;/div&gt;
&lt;/div&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;i&gt;Input is taken from a file(A-small-practice.in)&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;/*&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;* @author niraj.nijju&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: Monaco, Consolas, &#39;Andale Mono&#39;, &#39;DejaVu Sans Mono&#39;, monospace; font-size: 12px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
package gcj.TwelveThirteen;&lt;br /&gt;
&lt;br /&gt;
import java.io.BufferedReader;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.InputStreamReader;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
public class TicTacToeTomek {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String [] args){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;FileInputStream fstream = new FileInputStream(&quot;A-small-practice.in&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;DataInputStream in = new DataInputStream(fstream);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;BufferedReader br = new BufferedReader(new InputStreamReader(in));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;String strLine;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;strLine = br.readLine();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;int T = Integer.valueOf(strLine);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;System.out.println(&quot;T: &quot;+T);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;int i=1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;while ((strLine = br.readLine()) != null) &amp;nbsp; {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;List&amp;lt;String&amp;gt; string = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;string.add(strLine);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;string.add(br.readLine());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;string.add(br.readLine());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;string.add(br.readLine());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;if (T-- &amp;gt;0){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;br.readLine();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;int st = status(string, 1);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;if(st==1)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: X won&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;if(st==2)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: O won&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;if(st==0)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: Draw&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;if(st==3)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp;System.out.println (&quot;Case #&quot;+i++ +&quot;: Game has not completed&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;//System.out.println (strLine);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;in.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}catch (Exception e){//Catch exception if any&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;System.err.println(&quot;Error: &quot; + e.getMessage());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp;e.printStackTrace();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static int status(List&amp;lt;String&amp;gt; string, int t){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int status=0; // (1.X &amp;nbsp;2.O &amp;nbsp;0.draw &amp;nbsp;3.incomplete)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int i=0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Boolean ic=false;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;List&amp;lt;String&amp;gt; sl = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sl.add(&quot;&quot;);sl.add(&quot;&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sl.add(&quot;&quot;);sl.add(&quot;&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;4;i++){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String s = string.get(i);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(s.contains(&quot;.&quot;))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;ic = true;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(int z=0;z&amp;lt;4;z++){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sl.set(z, sl.get(z)+s.charAt(z));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(s.equalsIgnoreCase(&quot;XXXX&quot;))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;return 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;else if(s.equalsIgnoreCase(&quot;OOOO&quot;))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;return 2;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(s.contains(&quot;T&quot;)){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;int xCount=0, oCount=0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;for(int j=0;j&amp;lt;4;j++){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;if( s.charAt(j) == &#39;X&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;xCount++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;else if( s.charAt(j) == &#39;O&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;oCount++;&lt;br /&gt;
//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;else if( s.charAt(j) == &#39;.&#39;)&lt;br /&gt;
//&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;ic = true;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(xCount==3)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;return 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(oCount==3)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;return 2;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if( (string.get(0).charAt(0)==&#39;X&#39; || string.get(0).charAt(0)==&#39;T&#39; )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(1).charAt(1)==&#39;X&#39; ||string.get(1).charAt(1)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(2).charAt(2)==&#39;X&#39; ||string.get(2).charAt(2)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3).charAt(3)==&#39;X&#39; ||string.get(3).charAt(3)==&#39;T&#39;) )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if( (string.get(0).charAt(0)==&#39;O&#39; || string.get(0).charAt(0)==&#39;T&#39; )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(1).charAt(1)==&#39;O&#39; ||string.get(1).charAt(1)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(2).charAt(2)==&#39;O&#39; ||string.get(2).charAt(2)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3).charAt(3)==&#39;O&#39; ||string.get(3).charAt(3)==&#39;T&#39;) )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return 2;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if( (string.get(3-0).charAt(0)==&#39;X&#39; || string.get(3-0).charAt(0)==&#39;T&#39; )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3-1).charAt(1)==&#39;X&#39; ||string.get(3-1).charAt(1)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3-2).charAt(2)==&#39;X&#39; ||string.get(3-2).charAt(2)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3-3).charAt(3)==&#39;X&#39; ||string.get(3-3).charAt(3)==&#39;T&#39;) )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if( (string.get(3-0).charAt(0)==&#39;O&#39; || string.get(0).charAt(3-0)==&#39;T&#39; )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3-1).charAt(1)==&#39;O&#39; ||string.get(3-1).charAt(1)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3-2).charAt(2)==&#39;O&#39; ||string.get(3-2).charAt(2)==&#39;T&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;amp;&amp;amp; (string.get(3-3).charAt(3)==&#39;O&#39; ||string.get(3-3).charAt(3)==&#39;T&#39;) )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return 2;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(t==1){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return status(sl,2);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(ic)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return 3;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return status;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/3717797058307455913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2013/04/Google-code-jam-problem-A--Tic-Tac-Toe-Tomek-by-niraj-nijju.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/3717797058307455913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/3717797058307455913'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2013/04/Google-code-jam-problem-A--Tic-Tac-Toe-Tomek-by-niraj-nijju.html' title='Google Code Jam Problem A. Tic-Tac-Toe-Tomek'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-8988696152020270817</id><published>2012-11-25T20:05:00.000+05:30</published><updated>2012-11-25T20:17:30.993+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interview Questions"/><category scheme="http://www.blogger.com/atom/ns#" term="pattern"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>write a function to check given string matches with given pattern</title><content type='html'>&lt;span style=&quot;background-color: #f2f2f2; color: #333333; font-family: sans-serif; font-size: 14px; line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: normal;&quot;&gt;write a function to check given string matches with given pattern&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: normal;&quot;&gt;Condition: only one wildcard used in the pattern, that is &#39;*&#39;, but can be used in the pattern more than once.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: small; line-height: normal;&quot;&gt;Example:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;pattern: *abc*def*.doc*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;string: adsfabcxyzdefgh.docx&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;output : Matching&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;pattern: *abc*def*.doc*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;string: adsfabcxyzdefgh.do1cx&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;output : Not Matching&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;
&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
public class isMatchingWithWildcard {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String [] args){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String pattern = &quot;*abc*def*.doc*&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String str = &quot;adsfabcxyzdefgh.do1docx&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(isMatching(str, pattern))&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.print(&quot;Matching&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.print(&quot;Not Matching&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static Boolean isMatching(String str, String pattern){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int l = pattern.length();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(pattern.lastIndexOf(&quot;*&quot;) == l-1)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;pattern= (String) pattern.subSequence(0, l-1);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(pattern.charAt(0) == &#39;*&#39;)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;pattern= (String) pattern.subSequence(1, pattern.length());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pattern = pattern.replace(&quot;*&quot;, &quot;__&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String [] patternArray = pattern.split(&quot;__&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String sorttenString =str;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(String aPattern:patternArray){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String [] temp = sorttenString.split(aPattern);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(temp.length==1 &amp;amp;&amp;amp; (aPattern == patternArray[patternArray.length-1]&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&amp;amp;&amp;amp; !sorttenString.toLowerCase().contains(aPattern.toLowerCase())))&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;return false;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;str.substring(temp[0].length()+aPattern.length());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return true;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;Let me know your thoughts&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/8988696152020270817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/11/write-function-to-check-given-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8988696152020270817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8988696152020270817'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/11/write-function-to-check-given-string.html' title='write a function to check given string matches with given pattern'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-4516902869988323730</id><published>2012-11-25T14:54:00.001+05:30</published><updated>2012-11-25T14:56:18.658+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interview Questions"/><category scheme="http://www.blogger.com/atom/ns#" term="Pythagorean triples"/><title type='text'>Finding Pythagorean triplets in an array.</title><content type='html'>&lt;br /&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white;&quot;&gt;
Finding Pythagorean triplets in an array.&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
Input : &amp;nbsp; &amp;nbsp; 3 9 4 8 6 11 12&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
Output : &amp;nbsp;No such solution exist&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
Input : &amp;nbsp; &amp;nbsp;3 5 4 8 6 11 10&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
Output :&amp;nbsp;&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;5.0, 3.0, 4.0 &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;10.0, 6.0, 8.0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;// &amp;nbsp; WORKING code in java with &amp;nbsp;time O(n^2)&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
import java.util.Arrays;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
public class PythagoreanTripletsInArray {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static double [] getSquare(String [] args){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;double [] array = new double[args.length];&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(int i=0;i&amp;lt;args.length;i++){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;double j=Integer.parseInt(args[i]);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;array[i]=j*j;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return array;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String [] args ){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;double [] array =getSquare(args);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Arrays.sort(array);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Boolean flage = true;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(double aInt : array){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(int i=0,j=(array.length-1);i&amp;lt;j;){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;double sum = array[i]+array[j];&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(aInt == sum){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;System.out.println(Math.sqrt(aInt)+&quot;, &quot;+Math.sqrt(array[i])+&quot;, &quot;+Math.sqrt(array[j]));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;flage = false;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;break;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;else if(aInt &amp;gt; sum)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;i++;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;else&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;j--;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(flage)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.print(&quot;No such solution exist&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif; font-size: x-small;&quot;&gt;Let me know your thoughts&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/4516902869988323730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/11/finding-pythagorean-triplets-in-array.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/4516902869988323730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/4516902869988323730'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/11/finding-pythagorean-triplets-in-array.html' title='Finding Pythagorean triplets in an array.'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-7393192754374666958</id><published>2012-10-02T21:13:00.000+05:30</published><updated>2012-10-02T21:13:19.198+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Adobe"/><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="Codeing"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft"/><title type='text'>Re-arrange the odd/even to odd/even places</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-6161364587741830584&quot; itemprop=&quot;articleBody&quot; style=&quot;background-color: #fefdfa; position: relative; width: 586px;&quot;&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal;&quot;&gt;
Given an array of integers [3,1,4,5,7,6,10,8],&lt;br /&gt;
re arrange elements such that either even numbers in even locations or odd numbers in odd locations.&lt;br /&gt;
in O(n)&lt;br /&gt;
&lt;br /&gt;
output : &amp;nbsp;6 1 4 5 8 3 10 7&lt;/div&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;void Swap (int A[], int i, int j)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; int temp = A[i];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; A[i]=A[j];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; A[j]=temp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; int A[] = {3,1,4,5,7,6,10,8};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; int i=0,j=1,n;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; n=sizeof(A)/sizeof(int);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; while(i&amp;lt;n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(i&amp;lt;n &amp;amp;&amp;amp; A[i]%2 == 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i+=2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(j&amp;lt;n &amp;amp;&amp;amp; A[j]%2 == 1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j+=2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(i&amp;lt;n &amp;amp;&amp;amp; j&amp;lt;n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Swap(A,i,j);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; }// end of while&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot; %d&quot;,A[i]);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;
&lt;i style=&quot;font-family: sans-serif; line-height: 17px; text-align: center;&quot;&gt;Let me know your thoughts&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/7393192754374666958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/10/re-arrange-oddeven-to-oddeven-places.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/7393192754374666958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/7393192754374666958'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/10/re-arrange-oddeven-to-oddeven-places.html' title='Re-arrange the odd/even to odd/even places'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-1110082953816906767</id><published>2012-09-14T19:54:00.000+05:30</published><updated>2012-10-02T21:07:47.964+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Adobe"/><category scheme="http://www.blogger.com/atom/ns#" term="amazon"/><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>Sort an Array of 0 1&amp; 2 in one pass</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal;&quot;&gt;
&amp;nbsp;G&lt;span style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;iven an array&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;int a[] = {0, 1, 1 ,0, 2, 2, 1, 0 ,1, 2, 1,0 }&lt;/span&gt;&lt;br /&gt;
to be converted into&amp;nbsp;&lt;span style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;{0, 0, 0, 0, 1, 1, 1, 1, 1 ,2 ,2 ,2}&lt;/span&gt;&lt;br /&gt;
inplace and single pass&lt;br /&gt;
&lt;br /&gt;
Input :&amp;nbsp;&lt;span style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;int A[] = {2,2,2,1,1,1,0,0,0,1,2,0};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;Output: &amp;nbsp;0 0 0 0 1 1 1 1 2 2 2 2&lt;/span&gt;&lt;/div&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int A[] = {2,2,2,1,1,1,0,0,0,1,2,0};&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int j,i,x,y,n,t=A[0];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; n=sizeof(A)/sizeof(A[0]);&lt;br /&gt;
printf(&quot;Size of array : %d\n&quot;,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(x=i=0,y=j=n-1;i&amp;lt;=j;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(t==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A[x]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t=A[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(t==2)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t=A[y];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A[y]=2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y--;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j--;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t=A[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while(x&amp;lt;=y)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A[x++]=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot; %d&quot;,A[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;i style=&quot;background-color: #fefdfa; color: #333333; font-family: sans-serif; font-size: 13px; line-height: 17px; text-align: center;&quot;&gt;Let me know your thoughts.&lt;/i&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/1110082953816906767/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/09/sort-array-of-0-1-2-in-one-pass.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/1110082953816906767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/1110082953816906767'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/09/sort-array-of-0-1-2-in-one-pass.html' title='Sort an Array of 0 1&amp; 2 in one pass'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-204915126363289532</id><published>2012-07-25T21:34:00.001+05:30</published><updated>2012-07-25T21:34:10.354+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="amazon"/><category scheme="http://www.blogger.com/atom/ns#" term="Connected Set"/><category scheme="http://www.blogger.com/atom/ns#" term="matrix"/><title type='text'>Given a 2–d matrix , which has only 1’s and 0’s in it. Find the total number of connected sets in that matrix.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;rating&quot; style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
Connected
set can be defined as group of cell(s) which has 1 mentioned on it and have at
least one other cell in that set with which they share the neighbor
relationship. A cell with 1 in it and no surrounding neighbor having 1 in it
can be considered as a set with one cell in it. Neighbors can be defined as all
the cells adjacent to the given cell in 8 possible directions ( i.e N , W , E ,
S , NE , NW , SE , SW direction ). A cell is not a neighbor of itself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;strong&gt;Input
format :&lt;/strong&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
First
line of the input contains T , number of test-cases.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
Then
follow T testcases. Each testcase has given format.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
N [
representing the dimension of the matrix N X N ].&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
Followed
by N lines , with N numbers on each line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;strong&gt;Ouput
format :&lt;/strong&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
For
each test case print one line , &amp;nbsp;number of connected component it has.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;strong&gt;Sample
Input :&lt;/strong&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
4&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
4&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
1 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
1 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 1
0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 1
1 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
4&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
0 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 1
1 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
0 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
5&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
0 1 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
1 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
0 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 1
1 1 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
0 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
8&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
1 0 0 1 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
0 0 0 0 0 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
1 0 0 1 0 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 1
0 0 0 1 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
0 0 0 0 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
1 1 0 1 1 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1 0
1 1 0 1 1 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
0 0
0 0 0 0 0 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;strong&gt;Sample
output :&lt;/strong&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
3&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
3&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
9&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;strong&gt;Constraint
:&lt;/strong&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
0
&amp;lt; T &amp;lt; 6&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
0
&amp;lt; N &amp;lt; 1009&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
=================WORKING CODE=================&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;int count_connected_set(int A[1015][1015],int i,int j,int n)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; A[i][j]=2;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i-1][j-1]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n ) &amp;nbsp; &amp;nbsp; //NW&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i-1,j-1,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i-1][j]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n) &amp;nbsp; &amp;nbsp; &amp;nbsp; //N&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i-1,j,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i-1][j+1]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n)// &amp;nbsp; //NE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i-1,j+1,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i][j-1]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n) &amp;nbsp; &amp;nbsp; &amp;nbsp; //W&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i,j-1,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i][j+1]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n) &amp;nbsp; &amp;nbsp; &amp;nbsp; //E&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i,j+1,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i+1][j-1]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n) &amp;nbsp; &amp;nbsp; //SW&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i+1,j-1,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i+1][j]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n) &amp;nbsp; &amp;nbsp; &amp;nbsp; //S&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i+1,j,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(A[i+1][j+1]==1 &amp;amp;&amp;amp; i&amp;gt;0 &amp;amp;&amp;amp; j&amp;gt;0 &amp;amp;&amp;amp; i&amp;lt;=n &amp;amp;&amp;amp; j&amp;lt;=n) &amp;nbsp; &amp;nbsp; //SE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count_connected_set(A,i+1,j+1,n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;return 1;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;}// end of count_connected_set()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;int main()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; int i,j,t,k,n,A[1015][1015],count;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;t);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; while(t--)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=n;i++)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=1;j&amp;lt;=n;j++)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;A[i][j]); // geting input a test case;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count =0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=n;i++)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=1;j&amp;lt;=n;j++)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(A[i][j]==1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(count_connected_set(A,i,j,n))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }// of for&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d\n&quot;,count);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&amp;nbsp; &amp;nbsp; }// end of while&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;return 0;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 17px;&quot;&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: #333333; font-family: sans-serif; line-height: 17.27272605895996px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/204915126363289532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/given-2d-matrix-which-has-only-1s-and.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/204915126363289532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/204915126363289532'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/given-2d-matrix-which-has-only-1s-and.html' title='Given a 2–d matrix , which has only 1’s and 0’s in it. Find the total number of connected sets in that matrix.'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-4244044162199936817</id><published>2012-07-14T18:56:00.002+05:30</published><updated>2012-07-14T18:56:29.301+05:30</updated><title type='text'>REVERSE  a string and if any charecter is repeating then keep that one comes last</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; INPUT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OUTPUT&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CBA&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; ABBC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CBA&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; NHHGFDGS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SGDFHN&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; ABBCC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CBA&lt;/div&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; char S[20],S1[20];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i,x,j,l,A[26]={0},count=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gets(S); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// UPPER CASE ONLY&lt;br /&gt;
&amp;nbsp; &amp;nbsp; l=strlen(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;l;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x=S[i]-&#39;A&#39;+1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!A[x])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A[x]++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; S1[count]=NULL;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(j=l-1,i=0;count&amp;gt;i;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x=S[j]-&#39;A&#39;+1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(A[x]&amp;gt;0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; S1[i++]=S[j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; A[x]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j--;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n&amp;gt; %s&quot;,S1);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/4244044162199936817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/reverse-string-and-if-any-charecter-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/4244044162199936817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/4244044162199936817'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/reverse-string-and-if-any-charecter-is.html' title='REVERSE  a string and if any charecter is repeating then keep that one comes last'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-5487126608695962013</id><published>2012-07-10T11:20:00.000+05:30</published><updated>2012-07-10T11:28:45.418+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>WAP to find the position of a given word in a given text</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; list-style: none; margin: 0px 0px 18px; padding: 7px 14px;&quot;&gt;&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;WAP to find the position of a given word in a given text.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;&amp;nbsp; INPUT &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #444444;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #444444;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Text : my name is kumar name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #444444;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Word : name&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #444444;&quot;&gt;&amp;nbsp;OUTPUT :&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #444444;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Position &amp;nbsp;: 3 17&lt;/span&gt;&lt;/div&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; char S[100],W[20];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i,j,l,m,flage=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;Enter Text : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gets(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\nEnter Word : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gets(W);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; l=strlen(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; m=strlen(W);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;l;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(S[i]==W[0])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=1;j&amp;lt;m;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(S[i+j]!=W[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(j==m)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!flage)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nPosition : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flage =1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot; %d&quot;,i);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //flage=&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(!flage)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nNot found \n&quot;);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/5487126608695962013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/wap-to-find-position-of-given-word-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/5487126608695962013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/5487126608695962013'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/wap-to-find-position-of-given-word-in.html' title='WAP to find the position of a given word in a given text'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-1185082239830534415</id><published>2012-07-09T11:46:00.000+05:30</published><updated>2012-07-09T11:48:14.185+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Triangle"/><title type='text'>Which type of triangle is ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: left;&quot;&gt;&lt;div style=&quot;background-color: white; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;
Write a function that receives three integer inputs for the lengths of the sides of&lt;br /&gt;a triangle and returns one of four values to determine the triangle type&lt;br /&gt;(1=scalene, 2=isosceles, 3=equilateral, 4=error).&lt;/span&gt;&lt;/div&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int which_triangle(int a,int b,int c)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if( !(a&amp;amp;&amp;amp;b&amp;amp;&amp;amp;c&amp;amp;&amp;amp;(a+b)&amp;gt;c&amp;amp;&amp;amp;(a+c)&amp;gt;b&amp;amp;&amp;amp;(b+c)&amp;gt;a) )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 4;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else if(a==b &amp;amp;&amp;amp; a==c)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 3;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else if(a==b || a==c || b==c)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int a,b,c,x;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;enter 3 side length : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d %d %d&quot;,&amp;amp;a,&amp;amp;b,&amp;amp;c);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; x=which_triangle(a,b,c);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; switch(x){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case 1:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nScalene Triangle\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case 2:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nIsoscalene Triangle\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case 3:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nEquilateral Triangle\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case 4:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nError\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }// end of switch&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/1185082239830534415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/which-type-of-triangle-is.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/1185082239830534415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/1185082239830534415'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/which-type-of-triangle-is.html' title='Which type of triangle is ?'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-2960191871338722236</id><published>2012-07-08T21:11:00.002+05:30</published><updated>2012-07-08T21:14:20.917+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="palindrome"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>Find the number of substrings of a string that are palindromes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;ul class=&quot;breadcrumb&quot; style=&quot;-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; background-color: #fbfbfb; background-image: -webkit-linear-gradient(top, rgb(255, 255, 255), rgb(245, 245, 245)); background-repeat: repeat no-repeat; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(221, 221, 221); box-shadow: rgb(255, 255, 255) 0px 1px 0px inset; color: #333333; font-family: proximanova-regular, HelveticaNeue-Light, &#39;Helvetica Neue Light&#39;, &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Lucida Grande&#39;, sans-serif; font-size: 14px; line-height: 18px; list-style: none; margin: 0px 0px 18px; padding: 7px 14px; text-align: -webkit-auto;&quot;&gt;&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
&lt;br /&gt;// INPUT : w3asd1dsaf&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
// OUTPUT&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
asd1dsa&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
sd1ds&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
d1d&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: black; font-family: &#39;Times New Roman&#39;; font-size: medium; line-height: normal; text-align: left;&quot;&gt;
total 3 palindrom in given string&lt;/div&gt;
&lt;/ul&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int is_palindrom(char S[20],int f,int l)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(;f&amp;lt;=l;f++,l--)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(S[f]!=S[l])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
return 1;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; char S[20];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i,l,j,k,count=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gets(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; l=strlen(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;l;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=i+1;j&amp;lt;l;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(S[i]==S[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(is_palindrom(S,i,j))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(k=i;k&amp;lt;=j;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%c&quot;,S[k]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n\nTotal &amp;lt;&amp;lt; %d &amp;gt;&amp;gt; no of palindrom in given string\n&quot;,count);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/2960191871338722236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/find-number-of-substrings-of-string.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/2960191871338722236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/2960191871338722236'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/find-number-of-substrings-of-string.html' title='Find the number of substrings of a string that are palindromes'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-8164042690599480306</id><published>2012-07-07T23:49:00.001+05:30</published><updated>2012-07-07T23:53:29.017+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="Recursion"/><title type='text'>To copy the contents of an array A to contents of Array B without using loops and any standard string copy functions.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int Copy_Array(int A[],int B[], int n,int i)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(i==n)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; B[i]=A[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Copy_Array(A,B,n,i+1);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int A[10],B[10],i,n;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;Enter size : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;Enter Array : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;A[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\nArray A : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;,A[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Copy_Array(A,B,n,0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\nArray B : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;,B[i]);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/8164042690599480306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/how-can-you-copy-contents-of-array-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8164042690599480306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8164042690599480306'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/how-can-you-copy-contents-of-array-to.html' title='To copy the contents of an array A to contents of Array B without using loops and any standard string copy functions.'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-5421248486925329652</id><published>2012-07-07T19:02:00.003+05:30</published><updated>2012-07-08T00:08:08.204+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Password"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><category scheme="http://www.blogger.com/atom/ns#" term="Valid"/><title type='text'>Verify if the given password is valid or not</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Verify if the given password is valid or not.&lt;br /&gt;for a valid password it should follow these 2 condition&lt;br /&gt;1. must be 5-12 characters long&lt;br /&gt;2. must contain atleast one number and one lowercase &amp;amp; one upper character and a symbol&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; char S[20],c;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i=0,l,L=0,U=0,N=0,Sy=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; gets(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; l=strlen(S);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(l&amp;gt;12 || l&amp;lt;5)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\Invalid password \n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while(S[i++]!=NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(S[i-1]&amp;gt;=&#39;a&#39;&amp;amp;&amp;amp;S[i-1]&amp;lt;=&#39;z&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; L=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(S[i-1]&amp;gt;=&#39;A&#39;&amp;amp;&amp;amp;S[i-1]&amp;lt;=&#39;Z&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; U=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(S[i-1]&amp;gt;=&#39;0&#39;&amp;amp;&amp;amp;S[i-1]&amp;lt;=&#39;9&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else Sy=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(L&amp;amp;&amp;amp;U&amp;amp;&amp;amp;N&amp;amp;&amp;amp;Sy)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nvalid \n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else printf(&quot;\n\Invalid password \n&quot;);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/5421248486925329652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/verify-if-given-password-is-valid-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/5421248486925329652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/5421248486925329652'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/verify-if-given-password-is-valid-or.html' title='Verify if the given password is valid or not'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-6591218363001566084</id><published>2012-07-07T17:57:00.001+05:30</published><updated>2012-07-07T17:57:23.422+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Number Game"/><category scheme="http://www.blogger.com/atom/ns#" term="pattern"/><title type='text'>Find the seed of a number.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Eg : 1716 = 143*1*4*3 =1716&lt;/span&gt;so 143 is the seed of 1716.&lt;br /&gt;find all possible seed for a given number.&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;// Input &amp;nbsp; || &amp;nbsp;OUTPUT&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;// &amp;nbsp;1250 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;125 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;// &amp;nbsp;174720 &amp;nbsp; &amp;nbsp; &amp;nbsp;1456 &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int n,i,j,m,f=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(j)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m=m*(j%10);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j=j/10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(m==n)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n%d&quot;,i);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(!f)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nNo such number exit\n\n&quot;);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/6591218363001566084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/find-seed-of-number.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/6591218363001566084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/6591218363001566084'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/find-seed-of-number.html' title='Find the seed of a number.'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-4426807653472240925</id><published>2012-07-06T22:38:00.000+05:30</published><updated>2012-07-06T22:41:02.088+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="Duplicate"/><title type='text'>Find duplicates in O(n) time and O(1) extra space</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Given an array of n elements which contains elements from 0 to n-1, with any of these numbers appearing any number of times.&lt;/span&gt;Find these repeating numbers in O(n) and using only constant memory space.&lt;/span&gt;&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


&lt;span style=&quot;background-color: white; font-size: small;&quot;&gt;For example, let n be 7 and array be {1, 2, 3, 1, 3, 0, 6}, the answer should be 1 &amp;amp; 3.&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;math.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int n,A[15],i,flage,cycle=0,j,temp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\nEnter size of array : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\nEnter elements of array( %d space saperated &amp;nbsp;integer) : \n&quot;,n );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;A[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; flage=0;j=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n OUTPUT : &quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if( A[abs(A[i])] &amp;gt;= 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A[abs(A[i])]=-A[abs(A[i])];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot; %d&quot;,abs(A[i]) );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/4426807653472240925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/find-duplicates-in-on-time-and-o1-extra.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/4426807653472240925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/4426807653472240925'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/find-duplicates-in-on-time-and-o1-extra.html' title='Find duplicates in O(n) time and O(1) extra space'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-8663700224720184287</id><published>2012-07-06T20:46:00.001+05:30</published><updated>2012-07-06T20:48:05.245+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="Linkedlist"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>Kahan We Met</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;Geet is travelling to meet her boyfriend in Mumbai.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;Aditya is travelling to Mumbai for his business meeting.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;Geet starts from Delhi while Aditya starts from Bangalore. Both of them are travelling on bus passing from town to town.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;They meet at a nondescript city and end up travelling together to Mumbai. By the end of the journey they fall in love and settle down.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;Enough of Bollywood stories, The problem at hand is to find Kahan they met?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;For all interested programmers, Represent this as a programming problem(Data Structure) and find the location where Geet and Aditya would have met.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;P.S. No need to actually find any city on the map where they met.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; ===========================================================================&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp;Input Formate :&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12 13 14 21 22 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(these are 5 city pincode(2 disit integer pincoede for each city they pass through))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31 32 33 42 20 21 22 &amp;nbsp; &amp;nbsp; &amp;nbsp;(these are 7 city pincode )&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;//&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; &amp;nbsp; Output : 21 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(pincode of the city where they will met)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; ===================================================================&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;int kahan_they_met(int A[20],int G[20],int g,int a)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; int i_g=0,i_a=0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; if(g&amp;gt;a)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i_g+=g-a;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; else &amp;nbsp;i_a+=a-g;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; while(i_g &amp;lt;= g)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(A[i_a]==G[i_g])&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return A[i_a];&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i_g++;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i_a++;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;return 0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;int convert_input(int K[],char string[200])&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; int j=0,i=0,temp=0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; while(string[i]!=&#39;\0&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(string[i]!=&#39; &#39; &amp;amp;&amp;amp; string[i]!=&#39;\0&#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=temp*10 + (string[i++]-&#39;0&#39;) ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(string[i]==&#39; &#39;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; K[j++]=temp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;return j-1;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;int main()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; char string[200];&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; int g,a,i,G[20],A[20],met;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; printf(&quot;\nEnter city beetween D and M for GEET (eg: 12 13 14 21 22 ) : &quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; gets(string);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; g=convert_input(G,string);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; printf(&quot;\n-----------------\nEnter city beetween B and M for &amp;nbsp;for Aditya visit : &quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; gets(string);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; a=convert_input(A,string);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;=g;i++)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;// &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n%d&amp;gt;&amp;gt;%d&quot;,i,G[i]);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp;met=kahan_they_met(A,G,g,a);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp;if(met)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\nGeet and Aditya will met at : %d\n&quot;,met);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\nGeet and Aditya will met at Mumbai\n&quot;);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;return 0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;span style=&quot;line-height: 1px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;line-height: 1px;&quot;&gt;
&lt;span style=&quot;color: #303031; font-family: &#39;Myriad Pro&#39;, Arial, Verdana, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/8663700224720184287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/kahan-we-met.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8663700224720184287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/8663700224720184287'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/kahan-we-met.html' title='Kahan We Met'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-2782591572273999854</id><published>2012-07-06T15:28:00.001+05:30</published><updated>2012-07-06T15:32:23.945+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="image"/><category scheme="http://www.blogger.com/atom/ns#" term="rotation"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;INPUT &amp;nbsp;&amp;gt; &amp;nbsp; OUTPUT &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;INPUT &amp;nbsp; &amp;nbsp;&amp;gt; &amp;nbsp;&amp;gt; &amp;nbsp; &amp;nbsp;OUTPUT &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;4 &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;1 2 3 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 1 1 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 11 12 13 14 &amp;nbsp; &amp;nbsp; &amp;nbsp;41 31 21 11&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;1 2 3 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 2 2 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21 22 23 24 &amp;nbsp; &amp;nbsp; &amp;nbsp;42 32 22 12&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;1 2 3 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 3 3 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31 32 33 34 &amp;nbsp; &amp;nbsp; &amp;nbsp;43 33 23 13&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #f3f3f3;&quot;&gt;1 2 3 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 4 4 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 41 42 43 44 &amp;nbsp; &amp;nbsp; &amp;nbsp;44 34 24 14&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
void rotate(int I[10][10],int O[10][10],int j,int i)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int k,l,temp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(k=0;k&amp;lt;j;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=I[k+i][i]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// copy of Left in temp&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; O[k+i][i]=I[i+j-1][i+k]; &amp;nbsp; &amp;nbsp; // copy bottom to left&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; O[i+j-1][i+k]=I[i+j-k-1][i+j-1]; &amp;nbsp; // copy right to bottom&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; O[i+j-k-1][i+j-1]=I[i][i+j-k-1]; &amp;nbsp; // copy top to right&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; O[i][i+j-k-1]=temp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// copy temp(left) to top&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}// end of rotate&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int I[10][10],O[10][10],i,j,N;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;N);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;N;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;N;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;I[i][j]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; i=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; j=N;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while(j&amp;gt;0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rotate(I,O,j,i); &amp;nbsp;// i is base, &amp;nbsp;j is size&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j=j-2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;N;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;N;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;,O[i][j]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/2782591572273999854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/given-image-represented-by-nxn-matrix.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/2782591572273999854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/2782591572273999854'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/given-image-represented-by-nxn-matrix.html' title='Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-7928993531611325063</id><published>2012-07-06T15:23:00.003+05:30</published><updated>2012-07-06T15:31:51.068+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>Reduce  aabcccccaaa to a2b1c5a3  for new string is of smaller size otherwise live it original</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;char s[20],o[20],temp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int i=0,j=0,c=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;gets(s);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;while(s[i]!=NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;temp=s[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while(s[i]== temp)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;o[j++]=temp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;o[j++]=c+48;// ASCII of 0 is 48&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}// end of while&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(strlen(o)&amp;lt;strlen(s))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; puts(o);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; puts(s);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/7928993531611325063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/reduce-aabcccccaaa-to-a2b1c5a3-for-new.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/7928993531611325063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/7928993531611325063'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/reduce-aabcccccaaa-to-a2b1c5a3-for-new.html' title='Reduce  aabcccccaaa to a2b1c5a3  for new string is of smaller size otherwise live it original'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-3867771909135386048</id><published>2012-07-06T15:02:00.000+05:30</published><updated>2012-07-06T15:16:10.168+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="Permutation"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>Write a method to decide if two strings are premutation of each other or not.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
int check_permutation(char s1[], char s2[])&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int c[27],i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;27;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(strlen(s1)!=strlen(s2))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;s1[i]!=NULL;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c[0]= s1[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(c[0]&amp;gt;96)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c[0]=c[0]-96;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else c[0]=c[0]-64;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c[c[0]]++;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c[0]= s2[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(c[0]&amp;gt;96)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c[0]=c[0]-96;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else c[0]=c[0]-64;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c[c[0]]--;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;27;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(c[i]!=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; char s1[20],s2[20];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%s%s&quot;,&amp;amp;s1,&amp;amp;s2);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if( check_permutation(s1,s2) )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n Permutation of each other&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n NOT a Permutation &quot;);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/3867771909135386048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/write-method-to-decide-if-two-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/3867771909135386048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/3867771909135386048'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/write-method-to-decide-if-two-strings.html' title='Write a method to decide if two strings are premutation of each other or not.'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2099323611936963033.post-6237932713687552587</id><published>2012-07-06T14:56:00.000+05:30</published><updated>2012-07-06T15:16:28.161+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Array"/><category scheme="http://www.blogger.com/atom/ns#" term="String"/><title type='text'>Implement an algorithm to determine if a string has all unique characters.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;string.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; char input[27];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i,l,check[28];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,&amp;amp;input);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; l=strlen(input);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;27;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; check[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;l;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; check[27]=input[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(check[27]&amp;gt;96)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; check[27]=check[27]-96;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; check[27]=check[27]-64;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!check[check[27]])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; check[check[27]]=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nNOT&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n unique&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;center&gt;&lt;i&gt;Let me know your thoughts.&lt;/i&gt;&lt;/center&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codes-to-problem.blogspot.com/feeds/6237932713687552587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/implement-algorithm-to-determine-if.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/6237932713687552587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2099323611936963033/posts/default/6237932713687552587'/><link rel='alternate' type='text/html' href='http://codes-to-problem.blogspot.com/2012/07/implement-algorithm-to-determine-if.html' title='Implement an algorithm to determine if a string has all unique characters.'/><author><name>niraj.nijju</name><uri>http://www.blogger.com/profile/02292877595504129823</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpA7OdXVl_CnSRgXK0P85--STO1dHLvAocpOHz8SDB-oej4foYdMMyjkeeceMpsGK7EHymbMTKrw7tH7uvWbAI9ymlFv70cJ1CjN37kJeSPoIdBaDVmNcGNN9UHKvTUQ/s220/nijju_black.jpg'/></author><thr:total>0</thr:total></entry></feed>