<?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-8986378270648386320</id><updated>2025-10-10T03:33:14.681+05:30</updated><title type='text'>diaries</title><subtitle type='html'>LWS - Learn With Saras</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-8013293101548366647</id><published>2025-02-11T17:49:00.002+05:30</published><updated>2025-02-11T17:49:52.133+05:30</updated><title type='text'>IIT JEE Mains/JEE Advanced @LWS - Learn With Saras</title><content type='html'>&lt;h3&gt;Chemistry from Aayushi Ma&#39;m (Former Chemistry Faculty at Aakash, AskIITian)&amp;nbsp;&lt;/h3&gt;&lt;p data-end=&quot;65&quot; data-start=&quot;0&quot;&gt;&lt;/p&gt;&lt;p data-end=&quot;147&quot; data-start=&quot;72&quot;&gt;&lt;strong data-end=&quot;147&quot; data-start=&quot;72&quot;&gt;🚀 Unlock Your Potential with Expert Chemistry Coaching for IIT JEE! 🚀&lt;/strong&gt;&lt;/p&gt;&lt;p data-end=&quot;372&quot; data-start=&quot;149&quot;&gt;Are you aspiring to crack the IIT JEE and secure your future in one of India&#39;s prestigious engineering institutions? Let our&amp;nbsp;&lt;strong data-end=&quot;307&quot; data-start=&quot;274&quot;&gt;Experienced Chemistry Teacher&lt;/strong&gt;&amp;nbsp;guide you through the toughest concepts and ensure your success!&lt;/p&gt;&lt;p data-end=&quot;392&quot; data-start=&quot;374&quot;&gt;&lt;strong data-end=&quot;392&quot; data-start=&quot;374&quot;&gt;Why Choose Us?&lt;/strong&gt;&lt;/p&gt;&lt;ul data-end=&quot;962&quot; data-start=&quot;394&quot;&gt;&lt;li data-end=&quot;482&quot; data-start=&quot;394&quot;&gt;&lt;strong data-end=&quot;416&quot; data-start=&quot;396&quot;&gt;Qualified Expert&lt;/strong&gt;: IIT JEE Chemistry teacher with a proven track record of success.&lt;/li&gt;&lt;li data-end=&quot;568&quot; data-start=&quot;483&quot;&gt;&lt;strong data-end=&quot;510&quot; data-start=&quot;485&quot;&gt;Personalized Coaching&lt;/strong&gt;: Tailored lessons based on your strengths and weaknesses.&lt;/li&gt;&lt;li data-end=&quot;663&quot; data-start=&quot;569&quot;&gt;&lt;strong data-end=&quot;597&quot; data-start=&quot;571&quot;&gt;Comprehensive Coverage&lt;/strong&gt;: In-depth coverage of Physical, Organic, and Inorganic Chemistry.&lt;/li&gt;&lt;li data-end=&quot;767&quot; data-start=&quot;664&quot;&gt;&lt;strong data-end=&quot;691&quot; data-start=&quot;666&quot;&gt;Strategic Study Plans&lt;/strong&gt;: Focused approach on problem-solving, time management, and exam techniques.&lt;/li&gt;&lt;li data-end=&quot;869&quot; data-start=&quot;768&quot;&gt;&lt;strong data-end=&quot;792&quot; data-start=&quot;770&quot;&gt;Regular Mock Tests&lt;/strong&gt;: Get real-time experience with IIT JEE level practice tests and evaluations.&lt;/li&gt;&lt;li data-end=&quot;962&quot; data-start=&quot;870&quot;&gt;&lt;strong data-end=&quot;899&quot; data-start=&quot;872&quot;&gt;Doubt Clearing Sessions&lt;/strong&gt;: Clear your doubts anytime to stay on top of your preparation.&lt;/li&gt;&lt;/ul&gt;&lt;p data-end=&quot;1089&quot; data-start=&quot;964&quot;&gt;Whether you&#39;re starting your preparation or looking for that final push,&amp;nbsp;&lt;strong data-end=&quot;1089&quot; data-start=&quot;1037&quot;&gt;we are here to help you achieve your IIT dreams!&lt;/strong&gt;&lt;/p&gt;&lt;p data-end=&quot;1117&quot; data-start=&quot;1091&quot;&gt;🌟&amp;nbsp;&lt;strong data-end=&quot;1115&quot; data-start=&quot;1094&quot;&gt;Classes Available&lt;/strong&gt;:&lt;/p&gt;&lt;ul data-end=&quot;1186&quot; data-start=&quot;1118&quot;&gt;&lt;li data-end=&quot;1155&quot; data-start=&quot;1118&quot;&gt;Online (Flexible Timings)&lt;/li&gt;&lt;li data-end=&quot;1186&quot; data-start=&quot;1156&quot;&gt;One-on-one or Group sessions&lt;/li&gt;&lt;/ul&gt;&lt;p data-end=&quot;1271&quot; data-start=&quot;1188&quot;&gt;&lt;b&gt;How to Contact:&lt;/b&gt;&amp;nbsp;Leave comment with your contact details. Our team will connect with you.&lt;/p&gt;&lt;p data-end=&quot;1331&quot; data-is-last-node=&quot;&quot; data-start=&quot;1278&quot;&gt;&lt;/p&gt;&lt;hr data-end=&quot;1276&quot; data-start=&quot;1273&quot; /&gt;&lt;h3 style=&quot;line-height: 21.528px; margin-bottom: 10pt;&quot;&gt;&lt;span style=&quot;font-size: 11pt; line-height: 16.8667px; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-bidi-font-size: 10.5pt; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;&quot;&gt;Math and Physics from Saras Ojha (B.Tech NIT Jaipur, M.Tech IIT (BHU))&lt;/span&gt;&lt;/h3&gt;&lt;p data-end=&quot;150&quot; data-start=&quot;89&quot;&gt;&lt;strong data-end=&quot;150&quot; data-start=&quot;89&quot;&gt;🚀 Master IIT JEE Math &amp;amp; Physics with Expert Guidance! 🚀&lt;/strong&gt;&lt;/p&gt;&lt;p data-end=&quot;293&quot; data-start=&quot;152&quot;&gt;Are you aiming to crack the IIT JEE exams with top scores in Math and Physics? Get personalized coaching from an experienced IIT JEE teacher!&lt;/p&gt;&lt;p data-end=&quot;321&quot; data-start=&quot;295&quot;&gt;🔹&amp;nbsp;&lt;strong data-end=&quot;318&quot; data-start=&quot;298&quot;&gt;Subjects Offered&lt;/strong&gt;:&lt;/p&gt;&lt;ul data-end=&quot;357&quot; data-start=&quot;322&quot;&gt;&lt;li data-end=&quot;341&quot; data-start=&quot;322&quot;&gt;&lt;strong data-end=&quot;339&quot; data-start=&quot;324&quot;&gt;Mathematics&lt;/strong&gt;&lt;/li&gt;&lt;li data-end=&quot;357&quot; data-start=&quot;342&quot;&gt;&lt;strong data-end=&quot;355&quot; data-start=&quot;344&quot;&gt;Physics&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p data-end=&quot;861&quot; data-start=&quot;359&quot;&gt;🔹&amp;nbsp;&lt;strong data-end=&quot;380&quot; data-start=&quot;362&quot;&gt;Why Choose Me?&lt;/strong&gt;&lt;br data-end=&quot;383&quot; data-start=&quot;380&quot; /&gt;✔️&amp;nbsp;&lt;strong data-end=&quot;409&quot; data-start=&quot;386&quot;&gt;Experienced Teacher&lt;/strong&gt;&amp;nbsp;with a proven track record of success in IIT JEE coaching.&lt;br data-end=&quot;471&quot; data-start=&quot;468&quot; /&gt;✔️&amp;nbsp;&lt;strong data-end=&quot;505&quot; data-start=&quot;474&quot;&gt;In-depth Conceptual Clarity&lt;/strong&gt;&amp;nbsp;— Building a strong foundation for both subjects.&lt;br data-end=&quot;558&quot; data-start=&quot;555&quot; /&gt;✔️&amp;nbsp;&lt;strong data-end=&quot;587&quot; data-start=&quot;561&quot;&gt;Regular Doubt Clearing&lt;/strong&gt;&amp;nbsp;— No question is too small!&lt;br data-end=&quot;618&quot; data-start=&quot;615&quot; /&gt;✔️&amp;nbsp;&lt;strong data-end=&quot;653&quot; data-start=&quot;621&quot;&gt;Mock Tests &amp;amp; Practice Papers&lt;/strong&gt;&amp;nbsp;— Get exam-ready with realistic test simulations.&lt;br data-end=&quot;706&quot; data-start=&quot;703&quot; /&gt;✔️&amp;nbsp;&lt;strong data-end=&quot;735&quot; data-start=&quot;709&quot;&gt;Personalized Attention&lt;/strong&gt;&amp;nbsp;— One-on-one coaching and customized study plans.&lt;br data-end=&quot;788&quot; data-start=&quot;785&quot; /&gt;✔️&amp;nbsp;&lt;strong data-end=&quot;822&quot; data-start=&quot;791&quot;&gt;Focused on Speed &amp;amp; Accuracy&lt;/strong&gt;&amp;nbsp;— Improve your problem-solving skills.&lt;/p&gt;&lt;p data-end=&quot;889&quot; data-start=&quot;863&quot;&gt;🔹&amp;nbsp;&lt;strong data-end=&quot;886&quot; data-start=&quot;866&quot;&gt;Mode of Teaching&lt;/strong&gt;:&lt;/p&gt;&lt;ul data-end=&quot;994&quot; data-start=&quot;890&quot;&gt;&lt;li data-end=&quot;950&quot; data-start=&quot;890&quot;&gt;Online (Flexible according to your preference)&lt;/li&gt;&lt;li data-end=&quot;994&quot; data-start=&quot;951&quot;&gt;Batch and One-on-One Classes available.&lt;/li&gt;&lt;/ul&gt;&lt;p data-end=&quot;1035&quot; data-start=&quot;996&quot;&gt;🔹&amp;nbsp;&lt;strong data-end=&quot;1011&quot; data-start=&quot;999&quot;&gt;Location&lt;/strong&gt;: [Your Location/Online]&lt;/p&gt;&lt;p data-end=&quot;1161&quot; data-start=&quot;1037&quot;&gt;🔹&amp;nbsp;&amp;nbsp;&lt;b&gt;How to Contact&lt;/b&gt;: Leave comment with your contact details. Our team will connect with you.&lt;br data-end=&quot;1060&quot; data-start=&quot;1057&quot; /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p data-end=&quot;1203&quot; data-start=&quot;1163&quot;&gt;Let&#39;s make your IIT JEE dream a reality!&lt;/p&gt;&lt;hr data-end=&quot;1208&quot; data-start=&quot;1205&quot; /&gt;&lt;p data-end=&quot;1282&quot; data-is-last-node=&quot;&quot; data-start=&quot;1210&quot;&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: 18.4px; margin-bottom: 10pt;&quot;&gt;&lt;span style=&quot;font-size: 11pt; line-height: 16.8667px; mso-ascii-font-family: Calibri; mso-bidi-font-family: Calibri; mso-bidi-font-size: 10.5pt; mso-fareast-font-family: Calibri; mso-hansi-font-family: Calibri;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/8013293101548366647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/8013293101548366647' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/8013293101548366647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/8013293101548366647'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2025/02/iit-jee-mainsjee-advanced-lws-learn.html' title='IIT JEE Mains/JEE Advanced @LWS - Learn With Saras'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-7764289244916088081</id><published>2025-02-07T17:40:00.011+05:30</published><updated>2025-02-11T15:55:09.735+05:30</updated><title type='text'>Some Interesting Excerpts from the book, &quot;Brighter than the Thousand Suns&quot;</title><content type='html'>I&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Oppenheimer taught not only at Berkeley but also at the California Institute of
Technology in Pasadena. As soon as he ended a course of lectures at the
university most of his students would follow him, for the ensuing term, to this
second seat of learning near Los Angeles. Despite his youth, &#39;Oppie&#39;, as they
called him, had come to be looked upon as a master and model by the rising
generation of physicists in America, just as the great men of atomic research in
Europe had been regarded by himself only a few years before. The veneration
felt by the students for their hero was so great that consciously or unconsciously
they imitated many of his personal peculiarities. They held their heads a little on
one side just as he did. They coughed Slightly and paused significantly between
successive sentences. They held their hands in front of their lips when they
spoke. Their ways of expressing themselves were often difficult to understand.
They were fond of making obscure comparisons which Sounded most pregnant
and sometimes actually were so. Oppenheimer, himself a confirmed smoker, had
the habit of clicking open his lighter and jumping up whenever anyone took out
a cigarette or pipe. His students could be recognized from afar in the campus
cafeterias Of Berkeley and Pasadena by their custom of darting about from time
to time, like marionettes on invisible strings, with tiny flames between their
fingers.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;II&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&#39;Many physicists only have high-voltage current in their veins,&#39; said someone
who had known him a long time. ‘But Sam has blood. He knows that the world
contains other interesting things besides equations and cyclotrons.&#39; It was typical
of Goudsmit that he gave the following advice to a young nuclear physicist who
wanted to go to an atom-bomb test in Nevada. &#39;If you want to see a show, why
don&#39;t you buy a ticket to one of the current Broadway musicals? That might help
you more with your work than going west. Pauli won the Nobel prize by going
to the theatre, you know. He was watching a revue in Copenhagen when the
exclusion principle came to him.&#39;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;III&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;As early as the spring of 1945 a study group within the Manhattan Project was
given the task of selecting a target for the first employment of the bomb. The
group comprised mathematicians, theoretical physicists, specialists on the effects
of explosions and meteorological experts. This team, mainly composed of
scientists, including Robert Oppenheimer, came to the conclusion, according to a
report published later in a limited edition by the Manhattan Engineer District,
that targets for this peculiar type of bomb must satisfy the following conditions:
 (a) Since the atomic bomb is expected to produce its greatest amount of
damage by primary blast effect and next greatest by fires, the targets should
contain a large percentage of closely built frame buildings and other construction
that would be most susceptible to damage by blast and fire;
 (b) the maximum blast effect of the bomb is calculated to extend over an area
of approximately one mile in radius. Therefore the selected targets should
contain a densely built-up area of at least this size;
 (c) the targets selected should possess high military and strategic value; (d) the
first target should if possible be one that has escaped earlier bombardments, so
that the effect of a single atomic bomb can be ascertained.
 It was further resolved that four Japanese cities should be deliberately spared
bombardment by the American formations which by 1945 could reconnoitre any
target they pleased in Japan with practically no resistance. This deceptive period
of grace was granted these four cities so they could be doomed to a ruin all the
more dreadful by the new bomb.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;IV&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;On 21 May 1946, not quite a year later, Slotin was carrying out an experiment,
similar to those he had so often successfully performed in the past. It was
connected with the preparation of the second atom-bomb test, to be performed in 
the waters of the South Sea atoll of Bikini. Suddenly his screwdriver slipped. The
hemispheres came too close together and the material became critical. The whole
room was instantly filled with a dazzling, bluish glare. Slotin, instead of ducking
and thereby possibly saving himself, tore the two hemispheres apart with his
hands and thus interrupted the chain reaction. By this action he saved the lives of
the seven other persons in the room. He had realized at once that he himself
would be bound to succumb to the effects of the excessive radiation dose which
he had absorbed. But he did not lose his self-control for a moment. He told his
colleagues to go and stand exactly where they had been at the instant of the
disaster. He then drew on the blackboard, with his own hand, an accurate sketch
of their relative positions, so that the doctors could ascertain the degree of
radiation to which each of those present had been exposed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;V&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Strange to say, a terrible fate was also in store for the complement of the
cruiser Indianapolis, which took to Tinian the greater part of the explosive heart of
the first atom bomb destined for use against Japan. Only three men aboard the
vesse2 the fastest in the American fleet, had any idea what she was carrying. The
rest simply supposed that there must be something very important in the big
wooden case which had been hoisted aboard, with every precaution, on the
morning of 16 July shortly before the ship put to sea. During the voyage from
San Francisco to Tinian very special security measures were taken for defence
against hostile submarines. Everyone heaved a sigh of relief when the
Indianapolis, after unloading her secret cargo at Tinian, stood for the offing. But
before the cruiser had reached her second port of call she was struck, at five
minutes past midnight on 30 July, by a torpedo. Owing to a series of unfortunate
circumstances news of the sinking did not reach naval headquarters for another
four days. Signals from another ship were wrongly taken to be routine reports
from the Indianapolis of her position and owing to one more misunderstanding
she was not reported as overdue at Leyte harbour. Therefore, salvage units
arrived too late at the scene of the disaster, and of the ship&#39;s 1,196 men only 316
were rescued. Some days before the first test of the bomb it was an open secret in
Alamogordo, even among the wives and children of the Los Alamos scientists,
that some particularly important and exciting event was in preparation. The test
was referred to under the code name &#39;Trinity&#39;. No clear explanation has hitherto
been forthcoming as to why this blasphemous expression was employed, above
all in such a connexion. One probability is that it was taken from the name of a
turquoise mine near Los Alamos, which had been laid under a curse and
therefore abandoned by the superstitious Indians. Another guess supposes that it
was chosen because at that time the first three atom bombs were approaching
completion, and that the code name was derived simply and solely from the
existence of that hellish trinity.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;VI&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;During the ensuing period of waiting, which seemed an eternity, hardly a
word was spoken. Everyone was giving free play to his thoughts. But so far as
those who have been asked can remember, these thoughts were not apocalyptic.
Most of the people concerned, it appears, were trying to work out how long it
would be before they could shift their uncomfortable position and obtain some
kind of view of the spectacle awaited. Fermi, experimental- minded as ever, was
holding scraps of paper, with which he meant to gauge the air pressure and
thereby estimate the strength of the explosion the moment it occurred. Frisch was
intent on memorizing the phenomenon as precisely as possible, without allowing
either excitement or preconceived notions to interfere with his faculties of
perception. Groves was wondering for the hundredth time whether he had taken
every possible step to ensure rapid evacuation in the case of a disaster.
Oppenheimer oscillated between fears that the experiment would fail and fears
that it would succeed.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;VII&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Even so cool and matter-of-fact a person as Enrico Fermi received a profound
shock, in spite of the retort he had made to all the objections of his colleagues to
the bomb during the discussions of the past few weeks. He had always said:
&#39;Don&#39;t bother me with your conscientious scruples! After all, the thing&#39;s superb
physics!&#39; Never before had he allowed anyone else to drive his car. But on this
occasion he confessed that he did not feel capable of sitting at the wheel and
asked a friend to take it for him on the road back to Los Alamos. He told his wife,
the morning after his return, that it had seemed to him as if the car were jumping
from curve to curve, skipping the straight stretches in between.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;VIII&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Nishina started next day, for the second time, on his flight to Hiroshima, still
hoping that he might after all have been mistaken. In addition to the sorrow he
felt as a patriot he was also tormented by the fear that if a scientific superweapon of this kind had really been constructed and used, the scientists of the
West, his friends over so many years, in the eyes of the Japanese people would
now be inhuman monsters. When on the afternoon of 8 August his aircraft came
within sight of the huge, smoking heap of ruins that had once been a flourishing
city, all his fears were confirmed. Later he told the American officers who cross examined him: &#39;As I surveyed the damage from the air, I decided at a glance that
nothing but an atomic bomb could have created such devastation. &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/7764289244916088081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/7764289244916088081' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/7764289244916088081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/7764289244916088081'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2025/02/some-interesting-excerpts-from-book.html' title='Some Interesting Excerpts from the book, &quot;Brighter than the Thousand Suns&quot;'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-8528424141675349086</id><published>2023-10-29T15:03:00.003+05:30</published><updated>2023-11-04T20:15:31.295+05:30</updated><title type='text'>Worksheets</title><content type='html'>We have created some free worksheets for students of IB (MYP 4 and MYP 5), IB AA HL, Cambridge IGCSE, and AS and A Level students.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Worksheets are documented topic wise and can be accessed via left hand navigation.&lt;/div&gt;&lt;div&gt;You can post your answers in the comment section and I will respond to it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thank you.&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/8528424141675349086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/8528424141675349086' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/8528424141675349086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/8528424141675349086'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2023/10/this-blog-is-initiative-to-provide-free.html' title='Worksheets'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-4048927216841734759</id><published>2021-10-21T23:27:00.004+05:30</published><updated>2023-11-04T19:51:11.685+05:30</updated><title type='text'>Leet Code Java Solution - Container with Most Water</title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Given&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;n&lt;/code&gt;&amp;nbsp;non-negative integers&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;a&lt;span style=&quot;bottom: -0.25em; box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; vertical-align: baseline;&quot;&gt;1&lt;/span&gt;, a&lt;span style=&quot;bottom: -0.25em; box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; vertical-align: baseline;&quot;&gt;2&lt;/span&gt;, ..., a&lt;span style=&quot;bottom: -0.25em; box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; vertical-align: baseline;&quot;&gt;n&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;bottom: -0.25em; box-sizing: border-box; font-size: 10.5px; line-height: 0; position: relative; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/span&gt;, where each represents a point at coordinate&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;(i, a&lt;span style=&quot;bottom: -0.25em; box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; vertical-align: baseline;&quot;&gt;i&lt;/span&gt;)&lt;/code&gt;.&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;n&lt;/code&gt;&amp;nbsp;vertical lines are drawn such that the two endpoints of the line&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;i&lt;/code&gt;&amp;nbsp;is at&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;(i, a&lt;span style=&quot;bottom: -0.25em; box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; vertical-align: baseline;&quot;&gt;i&lt;/span&gt;)&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;(i, 0)&lt;/code&gt;. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Notice&lt;/span&gt;&amp;nbsp;that you may not slant the container.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 1:&lt;/span&gt;&lt;/p&gt;&lt;img alt=&quot;&quot; src=&quot;https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/17/question_11.jpg&quot; style=&quot;background-color: white; border-style: none; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; height: 287px; max-width: 100%; vertical-align: middle; width: 600px;&quot; /&gt;&lt;span face=&quot;-apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;&quot; style=&quot;background-color: white; color: #263238; font-size: 14px;&quot;&gt;&lt;/span&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; height = [1,8,6,2,5,4,8,3,7]
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 49
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Explanation:&lt;/span&gt; The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain&amp;nbsp;is 49.
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 2:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; height = [1,1]
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 1
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 3:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; height = [4,3,2,1,4]
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 16
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 4:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; height = [1,2,1]
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 2
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Constraints:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;n == height.length&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;2 &amp;lt;= n &amp;lt;= 10&lt;span style=&quot;box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; top: -0.5em; vertical-align: baseline;&quot;&gt;5&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;0 &amp;lt;= height[i] &amp;lt;= 10&lt;span style=&quot;box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; top: -0.5em; vertical-align: baseline;&quot;&gt;4&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;My Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;class Solution {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public int maxArea(int[] height) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int maxWater = 0;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int left = 0;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int right=height.length -1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (left&amp;lt;right){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; maxWater = Math.max(maxWater, (right-left)*Math.min(height[left],height[right]));&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (height[left]&amp;lt;height[right]) left ++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else right --;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return maxWater;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&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;br /&gt;&lt;/div&gt;&lt;div&gt;Alternate Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;class Solution {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public int maxArea(int[] height) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int [] [] area = new int[height.length][height.length];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int prod = 0;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i = 0; i&amp;lt;height.length;i++){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int j=i+1;j&amp;lt; height.length;j++){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int distance = Math.abs(j-i);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (height[i]&amp;lt;height[j]){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; area[i][j-1] = height[i]*distance;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; area[i][j-1] = height[j]*distance;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i = 0; i&amp;lt;height.length;i++){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int j =0; j&amp;lt;height.length;j++){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (area[i][j]&amp;gt;prod){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prod = area[i][j];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return prod;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/4048927216841734759/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/4048927216841734759' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/4048927216841734759'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/4048927216841734759'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-java-solution-container-with.html' title='Leet Code Java Solution - Container with Most Water'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-1480777413522179872</id><published>2021-10-21T13:53:00.002+05:30</published><updated>2023-11-04T19:52:47.574+05:30</updated><title type='text'>Reversing a String - Practice</title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
              crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;div&gt;Problem: The output should be reverse of a string input.&lt;/div&gt;&lt;div&gt;For example, Input:&amp;nbsp; greatlearning;&lt;/div&gt;&lt;div&gt;Output:&amp;nbsp;gninraeltaerg;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: to;&lt;/div&gt;&lt;div&gt;Output: ot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class reversingString {&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;public static void main(String[] args) {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;// TODO Auto-generated method stub&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;String original = &quot;greatlearning&quot;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;reversingString obj = new reversingString();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;char [] get_result = obj.mirrorstring(original);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;System.out.println(get_result);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;public char[] mirrorstring(String original){&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;char [] chars = original.toCharArray();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;for (int i=0,j=0; i&amp;lt;chars.length &amp;amp;&amp;amp; j&amp;lt;chars.length/2; i++,j++){&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;char ch = chars[chars.length-1-j];&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;chars[chars.length-1-j] = chars[i];&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;chars[i]= ch;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;return chars;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/1480777413522179872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/1480777413522179872' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/1480777413522179872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/1480777413522179872'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/reversing-string-practice.html' title='Reversing a String - Practice'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-6696981798651404436</id><published>2021-10-21T12:05:00.007+05:30</published><updated>2023-11-04T19:53:25.212+05:30</updated><title type='text'>Leet Code Java Solution - Verifing an Alien Dictionary</title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;order&lt;/code&gt;. The&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;order&lt;/code&gt;&amp;nbsp;of the alphabet is some permutation of lowercase letters.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Given a sequence of&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;words&lt;/code&gt;&amp;nbsp;written in the alien language, and the&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;order&lt;/code&gt;&amp;nbsp;of the alphabet, return&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;true&lt;/code&gt;&amp;nbsp;if and only if the given&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;words&lt;/code&gt;&amp;nbsp;are sorted lexicographically in this alien language.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 1:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; words = [&quot;hello&quot;,&quot;leetcode&quot;], order = &quot;hlabcdefgijkmnopqrstuvwxyz&quot;
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; true
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Explanation: &lt;/span&gt;As &#39;h&#39; comes before &#39;l&#39; in this language, then the sequence is sorted.
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 2:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; words = [&quot;word&quot;,&quot;world&quot;,&quot;row&quot;], order = &quot;worldabcefghijkmnpqstuvxyz&quot;
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; false
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Explanation: &lt;/span&gt;As &#39;d&#39; comes after &#39;l&#39; in this language, then words[0] &amp;gt; words[1], hence the sequence is unsorted.
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 3:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; words = [&quot;apple&quot;,&quot;app&quot;], order = &quot;abcdefghijklmnopqrstuvwxyz&quot;
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; false
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Explanation: &lt;/span&gt;The first three characters &quot;app&quot; match, and the second string is shorter (in size.) According to lexicographical rules &quot;apple&quot; &amp;gt; &quot;app&quot;, because &#39;l&#39; &amp;gt; &#39;∅&#39;, where &#39;∅&#39; is defined as the blank character which is less than any other character (&lt;a href=&quot;https://en.wikipedia.org/wiki/Lexicographical_order&quot; style=&quot;background-color: transparent; border-bottom: 1px solid transparent; box-sizing: border-box; color: #607d8b; cursor: pointer; outline: none; padding-bottom: 1px; pointer-events: auto; text-decoration-line: none; touch-action: manipulation; transition: border-bottom-color 0.3s ease 0s;&quot; target=&quot;_blank&quot;&gt;More info&lt;/a&gt;).
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Constraints:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= words.length &amp;lt;= 100&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= words[i].length &amp;lt;= 20&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;order.length == 26&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;All characters in&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;words[i]&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;order&lt;/code&gt;&amp;nbsp;are English lowercase letters.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;My Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;class Solution {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public boolean isAlienSorted(String[] words, String order) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int i=0;i&amp;lt;words.length-1;i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boolean allEqual= false;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int j=0;j&amp;lt;words[i].length() &amp;amp;&amp;amp; j&amp;lt;words[i+1].length();j++){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(order.indexOf(words[i].charAt(j))&amp;lt;order.indexOf(words[i+1].charAt(j))){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; allEqual = true;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(order.indexOf(words[i].charAt(j))&amp;gt;order.indexOf(words[i+1].charAt(j))){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!allEqual &amp;amp;&amp;amp; words[i+1].length()&amp;lt; words[i].length()){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return true;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/6696981798651404436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/6696981798651404436' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/6696981798651404436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/6696981798651404436'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-java-solution-verifing-alien.html' title='Leet Code Java Solution - Verifing an Alien Dictionary'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-6586562711215946132</id><published>2021-10-21T11:21:00.002+05:30</published><updated>2023-11-04T19:54:00.911+05:30</updated><title type='text'>Leet Code Java Solution - Valid Anagram</title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Given two strings&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;s&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;t&lt;/code&gt;, return&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;true&lt;/code&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;if&lt;/em&gt;&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;t&lt;/code&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;is an anagram of&lt;/em&gt;&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;s&lt;/code&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;, and&lt;/em&gt;&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;false&lt;/code&gt;&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;otherwise&lt;/em&gt;.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 1:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; s = &quot;anagram&quot;, t = &quot;nagaram&quot;
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; true
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 2:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; s = &quot;rat&quot;, t = &quot;car&quot;
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; false
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Constraints:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= s.length, t.length &amp;lt;= 5 * 10&lt;span style=&quot;box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; top: -0.5em; vertical-align: baseline;&quot;&gt;4&lt;/span&gt;&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;s&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;t&lt;/code&gt;&amp;nbsp;consist of lowercase English letters.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;class Solution {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public boolean isAnagram(String s, String t) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char c1[] = s.toCharArray();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;char c2[] = t.toCharArray();&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;Arrays.sort(c1);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;Arrays.sort(c2);&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;if(Arrays.equals(c1, c2)){&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;return true;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else{&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;return false;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;				&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/6586562711215946132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/6586562711215946132' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/6586562711215946132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/6586562711215946132'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-java-solution-valid-anagram.html' title='Leet Code Java Solution - Valid Anagram'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-9187860268080287544</id><published>2021-10-21T11:18:00.005+05:30</published><updated>2023-11-04T19:54:57.042+05:30</updated><title type='text'>Leet Code Java Solution - First Bad Version</title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Suppose you have&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;n&lt;/code&gt;&amp;nbsp;versions&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;[1, 2, ..., n]&lt;/code&gt;&amp;nbsp;and you want to find out the first bad one, which causes all the following ones to be bad.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;You are given an API&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;bool isBadVersion(version)&lt;/code&gt;&amp;nbsp;which returns whether&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;version&lt;/code&gt;&amp;nbsp;is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 1:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; n = 5, bad = 4
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 4
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Explanation:&lt;/span&gt;
call isBadVersion(3) -&amp;gt; false
call isBadVersion(5)&amp;nbsp;-&amp;gt; true
call isBadVersion(4)&amp;nbsp;-&amp;gt; true
Then 4 is the first bad version.
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 2:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; n = 1, bad = 1
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 1
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Constraints:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= bad &amp;lt;= n &amp;lt;= 2&lt;span style=&quot;box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; top: -0.5em; vertical-align: baseline;&quot;&gt;31&lt;/span&gt;&amp;nbsp;- 1&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;My Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;/* The isBadVersion API is defined in the parent class VersionControl.&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; boolean isBadVersion(int version); */&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class Solution extends VersionControl {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public int firstBadVersion(int n) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i=0, j =n, mid=0;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(i&amp;lt;=j){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mid = i + (j-i) / 2;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!isBadVersion(mid)) i = mid+1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else j = mid-1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!isBadVersion(mid)) return mid+1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return mid;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/9187860268080287544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/9187860268080287544' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/9187860268080287544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/9187860268080287544'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-java-solution-first-bad.html' title='Leet Code Java Solution - First Bad Version'/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-2272922297966249683</id><published>2021-10-21T11:13:00.001+05:30</published><updated>2023-11-04T19:55:30.724+05:30</updated><title type='text'>Leet Code Solution JAVA - Guess Number Higher or Lower </title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;We are playing the Guess Game. The game is as follows:&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;I pick a number from&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1&lt;/code&gt;&amp;nbsp;to&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;n&lt;/code&gt;. You have to guess which number I picked.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;You call a pre-defined API&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;int guess(int num)&lt;/code&gt;, which returns 3 possible results:&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;-1&lt;/code&gt;: The number I picked is lower than your guess (i.e.&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;pick &amp;lt; num&lt;/code&gt;).&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1&lt;/code&gt;: The number I picked is higher than your guess (i.e.&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;pick &amp;gt; num&lt;/code&gt;).&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;0&lt;/code&gt;: The number I picked is equal to your guess (i.e.&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;pick == num&lt;/code&gt;).&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Return&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;the number that I picked&lt;/em&gt;.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 1:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; n = 10, pick = 6
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 6
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 2:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; n = 1, pick = 1
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 1
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 3:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; n = 2, pick = 1
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 1
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 4:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; n = 2, pick = 2
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 2
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Constraints:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= n &amp;lt;= 2&lt;span style=&quot;box-sizing: border-box; font-size: 9.75px; line-height: 0; position: relative; top: -0.5em; vertical-align: baseline;&quot;&gt;31&lt;/span&gt;&amp;nbsp;- 1&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= pick &amp;lt;= n&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #546e7a; font-family: monospace;&quot;&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #546e7a; font-family: monospace;&quot;&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;My Code:&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span style=&quot;color: #546e7a; font-family: monospace;&quot;&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;&lt;div&gt;/**&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;* Forward declaration of guess API.&lt;/div&gt;&lt;div&gt;&amp;nbsp;* @param&amp;nbsp; num&amp;nbsp; &amp;nbsp;your guess&lt;/div&gt;&lt;div&gt;&amp;nbsp;* @return &lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;-1 if num is lower than the guess number&lt;/div&gt;&lt;div&gt;&amp;nbsp;*&lt;span style=&quot;white-space: pre;&quot;&gt;			&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 if num is higher than the guess number&lt;/div&gt;&lt;div&gt;&amp;nbsp;*&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;otherwise return 0&lt;/div&gt;&lt;div&gt;&amp;nbsp;* int guess(int num);&lt;/div&gt;&lt;div&gt;&amp;nbsp;*/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class Solution extends GuessGame {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public int guessNumber(int num) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i=1, j=num, mid=1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(i&amp;lt;=j){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mid = i + (j-i) / 2;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int result = guess(mid);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(result==1) i = mid+1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if (result==-1) j = mid-1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else return mid;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return mid;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/2272922297966249683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/2272922297966249683' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/2272922297966249683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/2272922297966249683'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-solution-java-guess-number.html' title='Leet Code Solution JAVA - Guess Number Higher or Lower '/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-9207007335999796757</id><published>2021-10-21T11:01:00.002+05:30</published><updated>2023-11-04T19:56:02.776+05:30</updated><title type='text'>Leet Code JAVA Solution - Angle Between Hands of a Clock </title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Given two numbers,&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;hour&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;minutes&lt;/code&gt;. Return the smaller angle (in degrees) formed between the&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;hour&lt;/code&gt;&amp;nbsp;and the&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;minute&lt;/code&gt;&amp;nbsp;hand.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 1:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://assets.leetcode.com/uploads/2019/12/26/sample_1_1673.png&quot; style=&quot;border-style: none; box-sizing: border-box; height: 225px; max-width: 100%; vertical-align: middle; width: 230px;&quot; /&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; hour = 12, minutes = 30
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 165
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 2:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://assets.leetcode.com/uploads/2019/12/26/sample_2_1673.png&quot; style=&quot;border-style: none; box-sizing: border-box; height: 225px; max-width: 100%; vertical-align: middle; width: 230px;&quot; /&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; hour = 3, minutes = 30
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 75
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 3:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://assets.leetcode.com/uploads/2019/12/26/sample_3_1673.png&quot; style=&quot;border-style: none; box-sizing: border-box; height: 225px; max-width: 100%; vertical-align: middle; width: 230px;&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; hour = 3, minutes = 15
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 7.5
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 4:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; hour = 4, minutes = 50
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 155
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Example 5:&lt;/span&gt;&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; hour = 12, minutes = 0
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; 0
&lt;/pre&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Constraints:&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;1 &amp;lt;= hour &amp;lt;= 12&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;0 &amp;lt;= minutes &amp;lt;= 59&lt;/code&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box;&quot;&gt;Answers within&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;10^-5&lt;/code&gt;&amp;nbsp;of the actual value will be accepted as correct.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;color: #263238; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #263238; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;My Code:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #263238; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #263238; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;div&gt;class Solution {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public double angleClock(int hour, int minutes) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double angle = 5.5*(minutes + (hour)*60);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (angle &amp;lt; 360 &amp;amp;&amp;amp; angle &amp;gt; 180){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return (360 -angle);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if (angle&amp;gt;360){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double n = angle%360;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(n&amp;gt;180){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return (360 - n);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return n;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(angle&amp;lt;0){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return (-angle);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #263238; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #263238; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/9207007335999796757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/9207007335999796757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/9207007335999796757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/9207007335999796757'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-solution-angle-between-hands.html' title='Leet Code JAVA Solution - Angle Between Hands of a Clock '/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8986378270648386320.post-7361579562647448908</id><published>2021-10-18T22:20:00.001+05:30</published><updated>2023-11-04T19:56:29.149+05:30</updated><title type='text'>Leet Code Solution Java - Two Sum </title><content type='html'>&lt;head&gt;&lt;script async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8786274322887052&quot;
     crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;&lt;/head&gt;
&lt;div&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Given an array of integers&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;nums&lt;/code&gt;&amp;nbsp;and an integer&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;target&lt;/code&gt;, return&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;indices of the two numbers such that they add up to&amp;nbsp;&lt;code style=&quot;background-color: #f7f9fa; border-radius: 3px; box-sizing: border-box; color: #546e7a; font-size: 13px; padding: 2px 4px;&quot;&gt;target&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;You may assume that each input would have&amp;nbsp;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;exactly&lt;/em&gt;&amp;nbsp;one solution&lt;/span&gt;, and you may not use the&amp;nbsp;&lt;em style=&quot;box-sizing: border-box;&quot;&gt;same&lt;/em&gt;&amp;nbsp;element twice.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;You can return the answer in any order.&lt;/p&gt;&lt;p style=&quot;background-color: white; box-sizing: border-box; color: #263238; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;; font-size: 14px; margin-bottom: 1em; margin-top: 0px;&quot;&gt;Example 1:&lt;/p&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; nums = [2,7,11,15], target = 9
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; [0,1]
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; Because nums[0] + nums[1] == 9, we return [0, 1].&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 2:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; nums = [3,2,4], target = 6
&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Output:&lt;/span&gt; [1,2]&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Example 3:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre style=&quot;background: rgb(247, 249, 250); border-radius: 3px; box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; line-height: 1.6; margin-bottom: 1em; margin-top: 0px; overflow: auto; padding: 10px 15px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Input:&lt;/span&gt; nums = [3,3], target = 6&amp;nbsp;&lt;/pre&gt;&lt;div&gt;&lt;span style=&quot;box-sizing: border-box; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; font-weight: bolder; white-space: pre-wrap;&quot;&gt;Output:&lt;/span&gt;&lt;span style=&quot;background-color: #f7f9fa; color: #263238; font-family: SFMono-Regular, Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; font-size: 13px; white-space: pre-wrap;&quot;&gt; [0,1]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;class Solution {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; public int[] twoSum(int[] nums, int target) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int [] arr = new int [2];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i=0; i&amp;lt;nums.length;i++){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int j=i+1;j&amp;lt;nums.length; j++){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int add = nums[i]+nums[j];&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(add==target){&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;arr[0] = i;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;arr[1] = j;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return arr;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;}&amp;nbsp;&lt;/span&gt;&lt;/div&gt;Copyright © saras ojha</content><link rel='replies' type='application/atom+xml' href='http://dialects-saras.blogspot.com/feeds/7361579562647448908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8986378270648386320/7361579562647448908' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/7361579562647448908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8986378270648386320/posts/default/7361579562647448908'/><link rel='alternate' type='text/html' href='http://dialects-saras.blogspot.com/2021/10/leet-code-solution-java-two-sum.html' title='Leet Code Solution Java - Two Sum '/><author><name>saras ojha</name><uri>http://www.blogger.com/profile/08447133165178453749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG9-2i_EmAQrrZ968kYwtEQmm-NvH7mCIyq7f1BTFjYnArVYknLwnVR4sB456kiACV6uM7rjy2THKMFoVeILC5PQ48nJFC48cGd_32SYsrjKmKf4_pXHp06sUCsY7Vw/s113/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>