<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="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" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7586742480288236721</atom:id><lastBuildDate>Sun, 02 Mar 2025 12:12:47 +0000</lastBuildDate><category>Competitive Coding Questions</category><category>JAVA</category><category>JAVA Programs</category><category>Basic C Program</category><category>C Program</category><category>Basic Cpp Programs</category><category>Basic JAVA Programs</category><category>C Plus Plus</category><category>Cpp Programs</category><category>LeetCode</category><category>My JAVA Project</category><category>indexed</category><category>Interview Experience</category><category>Games</category><category>Code-Vita Questions</category><category>Questions</category><title>Programming Chaska</title><description>A Programming Blog on Unique and Efficient JAVA, C, and C++ Programs and Games</description><link>https://programmingchaska.blogspot.com/</link><managingEditor>noreply@blogger.com (Taranjeet Singh Kalsi)</managingEditor><generator>Blogger</generator><openSearch:totalResults>97</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-2677336886886652207</guid><pubDate>Sun, 02 Mar 2025 11:49:00 +0000</pubDate><atom:updated>2025-03-02T17:19:41.177+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">JAVA</category><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Top K Frequent Elements- LeetCode Solution and Approach</title><description>&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM2RLuFO6MA7tFmPq-W-r2GM-f3uwPMiRShDZOuNQKdLM1wQo4R2F5yj6XGf7iOviUT2j9XNC74QCXRDcYwSc675nWJNtCem49QHpHbJ7f4WscVy57Jhyphenhyphenho9iob5GahV2ZHToiXh8x-cUDl4qf9SyuTz7eypGn_gDSjPq1__ClE69X_GZfbotHedWDE7st/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM2RLuFO6MA7tFmPq-W-r2GM-f3uwPMiRShDZOuNQKdLM1wQo4R2F5yj6XGf7iOviUT2j9XNC74QCXRDcYwSc675nWJNtCem49QHpHbJ7f4WscVy57Jhyphenhyphenho9iob5GahV2ZHToiXh8x-cUDl4qf9SyuTz7eypGn_gDSjPq1__ClE69X_GZfbotHedWDE7st/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;347. Top K Frequent Elements - LeetCode - Medium&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/top-k-frequent-elements&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [1,1,1,2,2,3], k = 2&lt;/div&gt;&lt;div&gt;Output: [1,2]&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;Input: nums = [1], k = 1&lt;/div&gt;&lt;div&gt;Output: [1]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1 &amp;lt;= nums.length &amp;lt;= 10^5&lt;/div&gt;&lt;div&gt;-10^4 &amp;lt;= nums[i] &amp;lt;= 10^4&lt;/div&gt;&lt;div&gt;k is in the range [1, the number of unique elements in the array].&lt;/div&gt;&lt;div&gt;It is guaranteed that the answer is unique.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;strong&gt;1. Frequency Counting using HashMap&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We traverse the array and maintain a frequency map using &lt;code&gt;HashMap&amp;lt;Integer, Integer&amp;gt;&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;This map stores each unique element as a key and its occurrence as the value.&lt;/li&gt;&lt;li&gt;Time Complexity: O(n) (since we iterate over &lt;code&gt;nums&lt;/code&gt; once).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;2. Using a Max-Heap (PriorityQueue) for Sorting&lt;/strong&gt;&lt;/div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We use a &lt;code&gt;PriorityQueue&lt;/code&gt; (max-heap) to sort elements based on their frequency.&lt;/li&gt;&lt;li&gt;The comparator ensures that the elements with higher frequency are at the top.&lt;/li&gt;&lt;li&gt;Time Complexity: &lt;strong&gt;O(n log n)&lt;/strong&gt; (due to sorting operations in the heap).&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;strong&gt;3. Extracting the Top K Frequent Elements&lt;/strong&gt;&lt;/div&gt;&lt;p style=&quot;text-align: left;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We poll the top &lt;code&gt;k&lt;/code&gt; elements from the heap and store them in the result array.&lt;/li&gt;&lt;li&gt;Time Complexity: &lt;strong&gt;O(k log n)&lt;/strong&gt; (polling &lt;code&gt;k&lt;/code&gt; elements from the heap).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n log n)&amp;nbsp;&lt;/span&gt;&amp;nbsp;due to heap operations.&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(n)&amp;nbsp;&lt;/span&gt;for storing the frequency map and heap.&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #dcdcaa;&quot;&gt;topKFrequent&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Map&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;HashMap&lt;/span&gt; &amp;lt; &amp;gt; ();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;) &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;put&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getOrDefault&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Queue&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Map&lt;/span&gt;.&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Entry&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt; &amp;gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;pq&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;PriorityQueue&lt;/span&gt; &amp;lt; &amp;gt; ((a, b) &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getValue&lt;/span&gt;() &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getValue&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;pq&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;addAll&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;entrySet&lt;/span&gt;());&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;res&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;--&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #9cdcfe;&quot;&gt;res&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;pq&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;poll&lt;/span&gt;().&lt;span style=&quot;color: #dcdcaa;&quot;&gt;getKey&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;res&lt;/span&gt;;&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;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; color: #212529; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2025/03/top-k-frequent-elements-leetcode.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM2RLuFO6MA7tFmPq-W-r2GM-f3uwPMiRShDZOuNQKdLM1wQo4R2F5yj6XGf7iOviUT2j9XNC74QCXRDcYwSc675nWJNtCem49QHpHbJ7f4WscVy57Jhyphenhyphenho9iob5GahV2ZHToiXh8x-cUDl4qf9SyuTz7eypGn_gDSjPq1__ClE69X_GZfbotHedWDE7st/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-669848289302653589</guid><pubDate>Thu, 30 May 2024 14:33:00 +0000</pubDate><atom:updated>2024-05-30T20:03:14.955+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Basic C Program</category><category domain="http://www.blogger.com/atom/ns#">Basic Cpp Programs</category><category domain="http://www.blogger.com/atom/ns#">Basic JAVA Programs</category><category domain="http://www.blogger.com/atom/ns#">C Plus Plus</category><category domain="http://www.blogger.com/atom/ns#">C Program</category><category domain="http://www.blogger.com/atom/ns#">Cpp Programs</category><category domain="http://www.blogger.com/atom/ns#">indexed</category><category domain="http://www.blogger.com/atom/ns#">JAVA</category><category domain="http://www.blogger.com/atom/ns#">JAVA Programs</category><title>Perfect number Program in C | C++ | JAVA</title><description>&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;color: #2b00fe; font-size: x-large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;a href=&quot;https://programmingchaska.blogspot.com/2024/04/two-sum-leetcode-solution-and-approach.html&quot; style=&quot;font-size: medium;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Start Practicing LeetCode with Programming Chaska&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&lt;span style=&quot;color: black; font-size: medium;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: medium;&quot;&gt;I have explained my approach to the problems in simple way. I have also shared the optimized code so that you can learn some new.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;color: #2b00fe; font-size: x-large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: black; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;color: #2b00fe; font-size: x-large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Perfect number Program in C | C++ | JAVA&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Perfect Number: A natural number that is equal to the sum of its all factors (excluding number as its factor itself), is called a Perfect Number.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2 style=&quot;box-sizing: border-box; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;div style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif;&quot;&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;b style=&quot;background-color: white;&quot;&gt;For Example: Number --&amp;gt; 6&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;factors of 6 are -&amp;gt; 1,2 and 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;-&amp;gt;1 + 2 + 3 = 6.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif;&quot;&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;b style=&quot;background-color: white;&quot;&gt;So, 6 is a Perfect Number.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Some of the Perfect numbers are&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif;&quot;&gt;28, 496, and 8128.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white; font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Algorithm&lt;/span&gt;&amp;nbsp;to check whether a given number is a Perfect number or not:&lt;/span&gt;&lt;/h2&gt;&lt;h2 style=&quot;box-sizing: border-box; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Step 1: Accept a number.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Step 2: Find factors of number starting from 1 to number (Do not include the number itself as a factor). If given number is divisible by number smaller than itself, then its a factor.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Step 3: Add all the factors of a number and store it in a variable.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Step 4: If the sum of all the factors of a number is equal to the number itself then Display Perfect number else Display Not a Perfect number.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family: euclid_circular_a, source sans pro, helvetica neue, helvetica, arial, sans-serif; font-size: large;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;Step 5: Stop&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;background-color: white; font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: x-large;&quot;&gt;Implementation in C:&lt;/span&gt;&lt;/p&gt;&lt;/h2&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white; font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Code 1:&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;This is the general code in C with time complexity of O(n).&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;div style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;h4 style=&quot;font-size: medium; line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;color: #d4d4d4; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4; line-height: 19px;&quot;&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter&amp;nbsp;number&amp;nbsp;here:&amp;nbsp;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&lt;/span&gt;,&amp;nbsp;&amp;amp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The&amp;nbsp;given&amp;nbsp;number&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp;is&amp;nbsp;a&amp;nbsp;Perfect&amp;nbsp;Number&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The&amp;nbsp;given&amp;nbsp;number&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;%d&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;nbsp;is&amp;nbsp;not&amp;nbsp;a&amp;nbsp;Perfect&amp;nbsp;Number&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font-size: 15.4px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; margin: 0in;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: x-large; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; margin: 0in;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: x-large; font-weight: 700;&quot;&gt;Implementation in C++:&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;box-sizing: border-box; color: #25265e; font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: 24px; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white; font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Code 2:&lt;/span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;This is the general code in C++ with time complexity of O(n).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;div style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;h4 style=&quot;font-size: medium; line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;color: #d4d4d4; line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;br /&gt;&lt;div&gt;{&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter&amp;nbsp;number&amp;nbsp;here:&amp;nbsp;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;{&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;)&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The&amp;nbsp;given&amp;nbsp;number&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;is&amp;nbsp;a&amp;nbsp;Perfect&amp;nbsp;Number&quot;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The&amp;nbsp;given&amp;nbsp;number&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&amp;nbsp;is&amp;nbsp;not&amp;nbsp;a&amp;nbsp;Perfect&amp;nbsp;Number&quot;&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; margin: 0in;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: x-large; font-weight: 700;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; margin: 0in;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: x-large; font-weight: 700;&quot;&gt;Implementation in JAVA:&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;ol&gt;&lt;/ol&gt;&lt;/h3&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white; font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Code 3:&lt;/span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;This is the general code in JAVA with time complexity of O(n).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;div style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;h4 style=&quot;font-size: medium; line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;color: #d4d4d4; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;java&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;util&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Scanner&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;PerfectNumber&lt;/span&gt; { &lt;span style=&quot;color: #6a9955;&quot;&gt;// class scope starts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;args&lt;/span&gt;) { &lt;span style=&quot;color: #6a9955;&quot;&gt;//main method starts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Scanner&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;Scanner&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #4fc1ff;&quot;&gt;in&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #4fc1ff;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;Enter your number&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;in&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;nextInt&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;in&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;close&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;) { &lt;span style=&quot;color: #6a9955;&quot;&gt;//starting for loop from 1 to number&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&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;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #4fc1ff;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The given number &quot;&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; is a Perfect number&quot;&lt;/span&gt;); &lt;span style=&quot;color: #6a9955;&quot;&gt;//printing statement&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #4fc1ff;&quot;&gt;out&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;println&lt;/span&gt;(&lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;The given number &quot;&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;number&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; is not a Perfect number&quot;&lt;/span&gt;); &lt;span style=&quot;color: #6a9955;&quot;&gt;//printing statement&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; margin: 0in;&quot;&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&lt;a href=&quot;https://programmingchaska.blogspot.com/2024/04/two-sum-leetcode-solution-and-approach.html&quot; style=&quot;font-size: medium; font-weight: 400;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Start Practicing LeetCode with Programming Chaska&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&lt;span style=&quot;color: black; font-size: medium; font-weight: 400;&quot;&gt;.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: medium; font-weight: 400;&quot;&gt;I have explained my approach to the problems in simple way. I have also shared the optimized code so that you can learn some new.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&lt;span style=&quot;color: black; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;&lt;span style=&quot;color: black; font-size: medium;&quot;&gt;&lt;span style=&quot;font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: x-large; font-weight: 700;&quot;&gt;Optimized Code in C | C++ | JAVA:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Code 4:&lt;/span&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;This is optimized code to check perfect numbers. Here we are using mathematical property for factor checking. The factors of a number starting repeating when we go beyond its square root.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Example:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Factors of 6 :&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;6 = 1 * 6&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;6 = 2 * 3&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;------------ (crossed square root of 6)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;6 = 3 * 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;6 = 6 * 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;h4&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;We can see that 2*3 is same as 3*2, so we will not go beyond square root.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;font-size: large;&quot;&gt;&lt;span&gt;&lt;span&gt;Time complexity - O(sqrt(n))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;div style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;h4 style=&quot;font-size: medium; line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;color: #d4d4d4; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;// Logic in C | C++ | JAVA&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;checkPerfectNumber&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;num&lt;/span&gt;) { &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// change return type bool to boolean for JAVA&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;num &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;= &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;num&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0; word-spacing: normal;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;if&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;num &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4; word-spacing: normal;&quot;&gt;% &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;i &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4; word-spacing: normal;&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #b5cea8; word-spacing: normal;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;sum &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4; word-spacing: normal;&quot;&gt;+= &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;i &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4; word-spacing: normal;&quot;&gt;+ (&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;num &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4; word-spacing: normal;&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;i)&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// num/i to find other factor&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;num&lt;/span&gt;; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// if sum equals num return true else false&lt;/span&gt;&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;/div&gt;&lt;div style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; margin: 0in;&quot;&gt;&lt;a href=&quot;https://programmingchaska.blogspot.com/2024/04/two-sum-leetcode-solution-and-approach.html&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Start Practicing LeetCode with Programming Chaska&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;.&amp;nbsp;&lt;span style=&quot;font-size: medium;&quot;&gt;I have explained my approach to the problems in simple way. I have also shared the optimized code so that you can learn some new.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;ol&gt;&lt;/ol&gt;&lt;/h3&gt;&lt;h2 style=&quot;box-sizing: border-box; color: #25265e; font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: 24px; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h2 style=&quot;box-sizing: border-box; font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: 24px; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div style=&quot;color: #25265e;&quot;&gt;&lt;span&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h2&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;ol&gt;&lt;/ol&gt;&lt;/h3&gt;&lt;h2 style=&quot;box-sizing: border-box; color: #25265e; font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: 24px; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h2&gt;&lt;h2 style=&quot;box-sizing: border-box; font-family: euclid_circular_a, &amp;quot;source sans pro&amp;quot;, &amp;quot;helvetica neue&amp;quot;, helvetica, arial, sans-serif; font-size: 24px; line-height: 36px; margin: 0px 0px 12px; padding: 0px;&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;div style=&quot;color: #25265e;&quot;&gt;&lt;div&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;div style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white; color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-size: large;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span face=&quot;arial, sans-serif&quot; style=&quot;font-size: medium;&quot;&gt;If you have&amp;nbsp;&lt;u&gt;any doubts/questions&lt;/u&gt;&amp;nbsp;related to the Program, if you want to give&amp;nbsp;&lt;u&gt;any suggestions&lt;/u&gt;, or&amp;nbsp;&lt;u&gt;want an explanation of the code&lt;/u&gt;,&amp;nbsp;&lt;u&gt;feel free to comment below&lt;/u&gt;. I hope that my code is understandable, if not then you can tell me in the comments so that I will try to make it easier to understand.&lt;/span&gt;&lt;span style=&quot;color: #25265e;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;arial, helvetica, sans-serif&quot; style=&quot;background-color: white;&quot;&gt;&lt;span face=&quot;arial, sans-serif&quot; style=&quot;font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/h2&gt;</description><link>https://programmingchaska.blogspot.com/2024/05/perfect-number-program-in-c-cpp-java.html.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-595624534129753692</guid><pubDate>Mon, 22 Apr 2024 19:12:00 +0000</pubDate><atom:updated>2024-05-30T22:28:46.950+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Group Anagrams - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;49. Group Anagrams - LeetCode - Medium&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/group-anagrams&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;&lt;div&gt;Given an array of strings strs, group the anagrams together. You can return the answer in any order.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: strs = [&quot;eat&quot;,&quot;tea&quot;,&quot;tan&quot;,&quot;ate&quot;,&quot;nat&quot;,&quot;bat&quot;]&lt;/div&gt;&lt;div&gt;Output: [[&quot;bat&quot;],[&quot;nat&quot;,&quot;tan&quot;],[&quot;ate&quot;,&quot;eat&quot;,&quot;tea&quot;]]&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;Input: strs = [&quot;&quot;]&lt;/div&gt;&lt;div&gt;Output: [[&quot;&quot;]]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 3:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: strs = [&quot;a&quot;]&lt;/div&gt;&lt;div&gt;Output: [[&quot;a&quot;]]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1 &amp;lt;= strs.length &amp;lt;= 104&lt;/div&gt;&lt;div&gt;0 &amp;lt;= strs[i].length &amp;lt;= 100&lt;/div&gt;&lt;div&gt;strs[i] consists of lowercase English letters.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We need to place same anagrams in groups.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can sort the elements in array and easily check for similar anagrams. But we will use another approach that is slightly more efficient.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Rather than sorting each string, we can calculate frequency of each character and store in variable say freq. We can now easily form a string of freq and hence it will be same for same frequency of characters. We can now make groups based on string frequency.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;We will iterate through given string array.&lt;/li&gt;&lt;li&gt;We will count the character frequency of current string and store in variable say freq.&lt;/li&gt;&lt;li&gt;We will convert value of freq variable to String to act as key. This key will be same when a string has same number of characters.&lt;/li&gt;&lt;li&gt;We will add the current string in the group based on key. And keep on iterating.&lt;/li&gt;&lt;li&gt;After iterating, we will get the groups of anagrams in values of Map.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(nk), &lt;i&gt;where n is number of strings, and k is length of each string&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt; &amp;gt;&amp;gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;groupAnagrams&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;strs&lt;/span&gt;) {&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;strs&lt;/span&gt;.&lt;span style=&quot;color: #4fc1ff;&quot;&gt;length&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;strs&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ArrayList&lt;/span&gt; &amp;lt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Map&lt;/span&gt; &amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;HashMap&lt;/span&gt; &amp;lt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;strs&lt;/span&gt;) {&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;char&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;char&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;26&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;ch&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;str&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;toCharArray&lt;/span&gt;()) &lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;ch&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;a&#39;&lt;/span&gt;]&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// calculating frequency&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;key&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;valueOf&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt;); &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// converting freq to string to act as key&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color: #cccccc; word-spacing: normal;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa; word-spacing: normal;&quot;&gt;computeIfAbsent&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;key&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cccccc; word-spacing: normal;&quot;&gt;, k&lt;/span&gt;&lt;span style=&quot;color: #569cd6; word-spacing: normal;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #c586c0; word-spacing: normal;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #cccccc; word-spacing: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4ec9b0; word-spacing: normal;&quot;&gt;ArrayList&lt;/span&gt;&lt;span style=&quot;color: #cccccc; word-spacing: normal;&quot;&gt;&amp;lt;&amp;gt;()).&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa; word-spacing: normal;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: #cccccc; word-spacing: normal;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;color: #cccccc; word-spacing: normal;&quot;&gt;); &lt;/span&gt;&lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// adding string to its group based on key&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ArrayList&lt;/span&gt;&amp;lt;&amp;gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;values&lt;/span&gt;());&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; color: #212529; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/group-anagrams-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-2137667970426981497</guid><pubDate>Mon, 15 Apr 2024 20:27:00 +0000</pubDate><atom:updated>2024-05-30T22:28:35.852+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Remove Duplicates from Sorted Array - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;26. Remove Duplicates from Sorted Array - LeetCode - Easy&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/remove-duplicates-from-sorted-array&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Consider the number of unique elements of nums to be k, to get accepted, you need to do the following things:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Change the array nums such that the first k elements of nums contain the unique elements in the order they were present in nums initially. The remaining elements of nums are not important as well as the size of nums.&lt;/li&gt;&lt;li&gt;Return k.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Custom Judge:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The judge will test your solution with the following code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int[] nums = [...]; // Input array&lt;/div&gt;&lt;div&gt;int[] expectedNums = [...]; // The expected answer with correct length&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;int k = removeDuplicates(nums); // Calls your implementation&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;assert k == expectedNums.length;&lt;/div&gt;&lt;div&gt;for (int i = 0; i &amp;lt; k; i++) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; assert nums[i] == expectedNums[i];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;If all assertions pass, then your solution will be accepted.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [1,1,2]&lt;/div&gt;&lt;div&gt;Output: 2, nums = [1,2,_]&lt;/div&gt;&lt;div&gt;Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively.&lt;/div&gt;&lt;div&gt;It does not matter what you leave beyond the returned k (hence they are underscores).&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;Input: nums = [0,0,1,1,1,2,2,3,3,4]&lt;/div&gt;&lt;div&gt;Output: 5, nums = [0,1,2,3,4,_,_,_,_,_]&lt;/div&gt;&lt;div&gt;Explanation: Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively.&lt;/div&gt;&lt;div&gt;It does not matter what you leave beyond the returned k (hence they are underscores).&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1 &amp;lt;= nums.length &amp;lt;= 3 * 10^4&lt;/div&gt;&lt;div&gt;-100 &amp;lt;= nums[i] &amp;lt;= 100&lt;/div&gt;&lt;div&gt;nums is sorted in non-decreasing order.&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this problem we have to remove the duplicates in-place. The elements are in sorted order, so the duplicates will be in sequence. Now the problem is reduced to finding next unique element, which is quiet simpler.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We will store the first unique element in a variable say prevUnique.&lt;/li&gt;&lt;li&gt;We will iterate through given array and check if number is not same as previous unique element stored in prevUnique. Now we have found new unique element. We will store the element at index say p which is equal to number of unique elements.&lt;/li&gt;&lt;li&gt;At last we will update the previous unique element with new unique and will continue iterating.&lt;/li&gt;&lt;li&gt;After iterating, we will get the number of unique elements stored in index p.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(1)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;removeDuplicates&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prevUnique&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;], &lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prevUnique&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prevUnique&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;p&lt;/span&gt;;&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;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; color: #212529; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/remove-duplicates-from-sorted-array-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-2993692619197093992</guid><pubDate>Mon, 15 Apr 2024 20:06:00 +0000</pubDate><atom:updated>2024-05-30T22:28:25.591+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Longest Consecutive Sequence - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;128. Longest Consecutive Sequence - LeetCode - Medium&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/longest-consecutive-sequence&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;&lt;div&gt;Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You must write an algorithm that runs in O(n) time.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [100,4,200,1,3,2]&lt;/div&gt;&lt;div&gt;Output: 4&lt;/div&gt;&lt;div&gt;Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.&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;Input: nums = [0,3,7,2,5,8,4,6,0,1]&lt;/div&gt;&lt;div&gt;Output: 9&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;0 &amp;lt;= nums.length &amp;lt;= 10^5&lt;/div&gt;&lt;div&gt;-10^9 &amp;lt;= nums[i] &amp;lt;= 10^9&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In this problem we have to find length of the longest consecutive elements sequence. In simple words, we need to find the largest range of numbers. We can use Set to store numbers, as we can use contains method in approx O(1) time. Set will also remove duplicates numbers.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We will find the starting point of the range and will iterate through the end of range to find its length. Once we get the length of range, we will find the maximum length among other lengths.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;If given array contains no element or only 1 element, the longest consecutive sequence will be 0 or 1 respectively. So need to check further.&lt;/li&gt;&lt;li&gt;&amp;nbsp;We will store the array numbers in Set and will iterate through set.&lt;/li&gt;&lt;li&gt;During iterating, we will check if set doesn&#39;t contain previous number (n-1). It means its starting of a range.&lt;/li&gt;&lt;li&gt;Now we found the starting of range. We will iterate through the range and count number of elements. After iterating we will take the highest count and store in variable say maxK.&lt;/li&gt;&lt;li&gt;We will continue iterating set elements. After iterating we will get the result in maxK.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;longestConsecutive&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;) {&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;.&lt;span style=&quot;color: #4fc1ff;&quot;&gt;length&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;) &lt;span style=&quot;color: #c586c0; word-spacing: normal;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;nums&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #4fc1ff; word-spacing: normal;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;maxK&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Set&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;HashSet&lt;/span&gt;&amp;lt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;) &lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa; word-spacing: normal;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;set&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;contains&lt;/span&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;)) { &lt;/span&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;// if number is starting of value of range&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nextValue&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;set&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;contains&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;nextValue&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;)) &lt;span style=&quot;color: #9cdcfe; word-spacing: normal;&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4; word-spacing: normal;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;word-spacing: normal;&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// counting next values&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;maxK&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;max&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;maxK&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;); &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// storing maximum count&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;span style=&quot;color: #cccccc;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;maxK&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;color: #cccccc;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; color: #212529; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/longest-consecutive-sequence-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-7066765070840251098</guid><pubDate>Sat, 13 Apr 2024 20:25:00 +0000</pubDate><atom:updated>2024-05-30T22:28:12.459+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Valid Anagram - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;242. Valid Anagram - LeetCode - Easy&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/valid-anagram&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;&lt;div&gt;Given two strings s and t, return true if t is an anagram of s, and false otherwise.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: s = &quot;anagram&quot;, t = &quot;nagaram&quot;&lt;/div&gt;&lt;div&gt;Output: true&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;Input: s = &quot;rat&quot;, t = &quot;car&quot;&lt;/div&gt;&lt;div&gt;Output: false&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1 &amp;lt;= s.length, t.length &amp;lt;= 5 * 10^4&lt;/div&gt;&lt;div&gt;s and t consist of lowercase English letters.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Two words are Anagram if frequency of each character is same in both words. So we can check if both words have the same character&#39;s frequency. We can use Map but for more optimization we will use array as input will only consist of lowercase English Letters (26).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;We will initialize Array of 26 int. The default value of each int element is 0.&lt;/li&gt;&lt;li&gt;We will iterate through first word and increase value of array by 1 on character&#39;s index. And keep on iterating.&lt;/li&gt;&lt;li&gt;After iterating first word, we will iterate through second word and instead of increasing, we will decrease value of array by 1 on character&#39;s index because we want to balance out positive with negative(we will get 0 if frequency of characters in both words is same). And keep on iterating.&lt;/li&gt;&lt;li&gt;After iterating both words, we will iterate through Array of 26 int and return false if any element doesn&#39;t equals 0. After iterating if all elements are 0, then return true.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(1)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;isAnagram&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;26&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;toCharArray&lt;/span&gt;())&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;a&#39;&lt;/span&gt;]&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;toCharArray&lt;/span&gt;())&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;a&#39;&lt;/span&gt;]&lt;span style=&quot;color: #d4d4d4;&quot;&gt;--&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;freq&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&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;/div&gt;&lt;/div&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;/div&gt;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/valid-anagram-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-2126260329245834627</guid><pubDate>Sat, 13 Apr 2024 19:34:00 +0000</pubDate><atom:updated>2024-05-30T22:28:01.340+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Contains Duplicate - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;217. Contains Duplicate - LeetCode - Easy&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/contains-duplicate&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;&lt;div&gt;Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [1,2,3,1]&lt;/div&gt;&lt;div&gt;Output: true&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;Input: nums = [1,2,3,4]&lt;/div&gt;&lt;div&gt;Output: false&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 3:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [1,1,1,3,3,4,3,2,4,2]&lt;/div&gt;&lt;div&gt;Output: true&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1 &amp;lt;= nums.length &amp;lt;= 10^5&lt;/div&gt;&lt;div&gt;-10^9 &amp;lt;= nums[i] &amp;lt;= 10^9&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The problem becomes easy if you use Set Data Structure. Set has inbuilt methods for checking if set already contains given value or not. In JAVA we have contains method which returns true if given number is present in Set. We also have the add method to add given number to Set. The add method returns true if given number is added, and false if given number is already present in Set.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We will initialize a Set. We will iterate through given array and add current number to the Set. If Set already contains given number, the add method returns false, so we will return true. And we will keep iterating.&lt;/li&gt;&lt;li&gt;If we completed iterating all the numbers, means the set doesn&#39;t contains duplicates, so we will return false.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;boolean&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;containsDuplicate&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Set&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;HashSet&lt;/span&gt;&amp;lt;&amp;gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;:&lt;/span&gt;nums)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #d4d4d4;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;set&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;add&lt;/span&gt;(n)) &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&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;/div&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;/div&gt;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/contains-duplicate-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-148349586465280618</guid><pubDate>Sat, 13 Apr 2024 15:05:00 +0000</pubDate><atom:updated>2024-05-30T22:27:48.683+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Longest Substring Without Repeating Characters - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;3. Longest Substring Without Repeating Characters - LeetCode - Medium&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/longest-substring-without-repeating-characters&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;&lt;div&gt;Given a string s, find the length of the longest substring without repeating characters.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: s = &quot;abcabcbb&quot;&lt;/div&gt;&lt;div&gt;Output: 3&lt;/div&gt;&lt;div&gt;Explanation: The answer is &quot;abc&quot;, with the length of 3.&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;Input: s = &quot;bbbbb&quot;&lt;/div&gt;&lt;div&gt;Output: 1&lt;/div&gt;&lt;div&gt;Explanation: The answer is &quot;b&quot;, with the length of 1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 3:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: s = &quot;pwwkew&quot;&lt;/div&gt;&lt;div&gt;Output: 3&lt;/div&gt;&lt;div&gt;Explanation: The answer is &quot;wke&quot;, with the length of 3.&lt;/div&gt;&lt;div&gt;Notice that the answer must be a substring, &quot;pwke&quot; is a subsequence and not a substring.&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;0 &amp;lt;= s.length &amp;lt;= 5 * 10^4&lt;/div&gt;&lt;div&gt;s consists of English letters, digits, symbols and spaces.&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;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The problem is to find maximum length of substring without duplicate characters. So, in other words, we need to find the maximum length of sliding window without duplicate characters.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;We can use Map to keep track of duplicates Characters but I will take int array to store indexes of characters.&lt;/li&gt;&lt;li&gt;We will iterate through the characters of string and if we found a duplicate character, we will set the starting pointer (i) of sliding window to index of duplicate character (that is stored in array) or keep i if i is at greater index.&lt;/li&gt;&lt;li&gt;We will update the index of the current character and store it in array.&lt;/li&gt;&lt;li&gt;We will calculate the length of the sliding window&amp;nbsp; and store the maximum length in a variable say maxL.&lt;/li&gt;&lt;li&gt;We will increase the right pointer by 1 and keep iterating.&lt;/li&gt;&lt;li&gt;We will get the answer in maxL.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(1)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;lengthOfLongestSubstring&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;String&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, j &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, l &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;length&lt;/span&gt;(), maxL &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;chars&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[&lt;span style=&quot;color: #b5cea8;&quot;&gt;128&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (j &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; l) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (chars[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;charAt&lt;/span&gt;(j)] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// if we find duplicate character &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;max&lt;/span&gt;(i, chars[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;charAt&lt;/span&gt;(j)]); &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// then set starting pointer (i) as index of duplicate character, or keep i if i is greater &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chars[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;charAt&lt;/span&gt;(j)] &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; j &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// update index of current character&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; maxL &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;Math&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;max&lt;/span&gt;(maxL, j &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; i &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;); &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// set maxL to size of sliding-window or keep maxL if &lt;/span&gt;&lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;maxL is &lt;/span&gt;&lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;greater&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;;&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; maxL;&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;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;font-family: arial;&quot;&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/longest-substring-without-repeating-characters-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-8626822198313315978</guid><pubDate>Sat, 13 Apr 2024 12:23:00 +0000</pubDate><atom:updated>2024-05-30T22:27:27.234+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Add Two Numbers - LeetCode Solution and Approach</title><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;2. Add Two Numbers&amp;nbsp; - LeetCode - Medium&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/add-two-numbers&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;span&gt;&lt;div&gt;&lt;div&gt;You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You may assume the two numbers do not contain any leading zero, except the number 0 itself.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;342&quot; data-original-width=&quot;483&quot; height=&quot;342&quot; src=&quot;https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg&quot; width=&quot;483&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&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;Input: l1 = [2,4,3], l2 = [5,6,4]&lt;/div&gt;&lt;div&gt;Output: [7,0,8]&lt;/div&gt;&lt;div&gt;Explanation: 342 + 465 = 807.&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;Input: l1 = [0], l2 = [0]&lt;/div&gt;&lt;div&gt;Output: [0]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 3:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]&lt;/div&gt;&lt;div&gt;Output: [8,9,9,9,0,0,0,1]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The number of nodes in each linked list is in the range [1, 100].&lt;/div&gt;&lt;div&gt;0 &amp;lt;= Node.val &amp;lt;= 9&lt;/div&gt;&lt;div&gt;It is guaranteed that the list represents a number that does not have leading zeros.&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;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As digits are stored in reverse order in Linked List. We will iterate through the both at same time and get the current Digits. We can now easily add the digits and store the carry if any. We will add the sum of current Digits to answer and keep iterating.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* Definition for singly-linked list.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* public class ListNode {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; int val;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; ListNode next;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; ListNode() {}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; ListNode(int val) { this.val = val; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* &amp;nbsp; &amp;nbsp; ListNode(int val, ListNode next) { this.val = val; this.next = next; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;* }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ListNode&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;addTwoNumbers&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;ListNode&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ListNode&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ListNode&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ListNode&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;ListNode&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;header&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; sum; &lt;span style=&quot;color: #6a9955;&quot;&gt;//storing Header&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;carry&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;||&lt;/span&gt; carry &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #6a9955;&quot;&gt;// calculating sum of current Digits and storing in t&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; carry;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; carry; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// not taking l1 if null&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;val&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;+&lt;/span&gt; carry; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// not taking l2 if null&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; carry; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// not taking l1 and l2 if null&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; carry &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;; &lt;span style=&quot;color: #6a9955;&quot;&gt;// calculating carry from t&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) l1 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l1&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;next&lt;/span&gt;; &lt;span style=&quot;color: #6a9955;&quot;&gt;// iterating through linkedlist 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;) l2 &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;l2&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;next&lt;/span&gt;; &lt;span style=&quot;color: #6a9955;&quot;&gt;// iterating through linkedlist 2&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;next&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ListNode&lt;/span&gt;(t &lt;span style=&quot;color: #d4d4d4;&quot;&gt;%&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;10&lt;/span&gt;); &lt;span style=&quot;color: #6a9955;&quot;&gt;// storing last digit of sum of current digits to LinkedList&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;sum&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;next&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;header&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;next&lt;/span&gt;;&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;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;font-family: arial;&quot;&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/add-two-numbers-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-636710384899617912</guid><pubDate>Sat, 13 Apr 2024 11:31:00 +0000</pubDate><atom:updated>2024-05-30T22:22:52.424+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">LeetCode</category><title>Two Sum - LeetCode Solution and Approach</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s1080/DSA%20RODMAP%20(1)-min.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;1080&quot; data-original-width=&quot;1080&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s320/DSA%20RODMAP%20(1)-min.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: #598cff; text-align: left;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span&gt;&amp;nbsp;1. Two Sum - LeetCode - Easy&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://leetcode.com/problems/two-sum&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Solve this problem in LeetCode&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span&gt;&lt;div&gt;Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You may assume that each input would have exactly one solution, and you may not use the same element twice.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can return the answer in any order.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 1:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [2,7,11,15], target = 9&lt;/div&gt;&lt;div&gt;Output: [0,1]&lt;/div&gt;&lt;div&gt;Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].&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;Input: nums = [3,2,4], target = 6&lt;/div&gt;&lt;div&gt;Output: [1,2]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example 3:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Input: nums = [3,3], target = 6&lt;/div&gt;&lt;div&gt;Output: [0,1]&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Constraints:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2 &amp;lt;= nums.length &amp;lt;= 10^4&lt;/div&gt;&lt;div&gt;-10^9 &amp;lt;= nums[i] &amp;lt;= 10^9&lt;/div&gt;&lt;div&gt;-10^9 &amp;lt;= target &amp;lt;= 10^9&lt;/div&gt;&lt;div&gt;Only one valid answer exists.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Approach:&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;If we try to find sum of each 2 integers in array, we will have to iterate through array in nested way and ends up getting time complexity of 0(n^2).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Instead we can store the value of target-currentValue in Map.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As, anyUpcomingValue + currentValue = Target, so anyUpcomingValue&amp;nbsp;= Target - currentValue&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So if we found anyUpcomingValue&amp;nbsp;equals to previously stored target-currentValue, we will get the pair. But we want indexes of those pairs, so we will store the index as value in Map.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;JAVA:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Time Complexity : 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif; font-size: medium;&quot;&gt;Space Complexity: 0(n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: 26.6667px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;background-color: #1f1f1f; color: #cccccc; line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Solution&lt;/span&gt; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #dcdcaa;&quot;&gt;twoSum&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;target&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Map&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;Integer&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;HashMap&lt;/span&gt;();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &lt;span style=&quot;color: #d4d4d4;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; i &lt;span style=&quot;color: #d4d4d4;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nums&lt;/span&gt;.&lt;span style=&quot;color: #9cdcfe;&quot;&gt;length&lt;/span&gt;; i&lt;span style=&quot;color: #d4d4d4;&quot;&gt;++&lt;/span&gt;) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;containsKey&lt;/span&gt;(nums[i])) &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// if such pair found&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] {&lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;get&lt;/span&gt;(nums[i]), i}; &lt;span style=&quot;color: #6a9955; word-spacing: normal;&quot;&gt;// then return pair&#39;s indexes&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;map&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;put&lt;/span&gt;(target &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt; nums[i], i); &lt;span style=&quot;color: #6a9955;&quot;&gt;// storing key as target-currentValue and value as currentIndex &lt;/span&gt;&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;int&lt;/span&gt;[] {&lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #d4d4d4;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;}; &lt;span style=&quot;color: #6a9955;&quot;&gt;// return [-1,-1] if no such pair found&lt;/span&gt;&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;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;b style=&quot;font-family: arial;&quot;&gt;Keep Learning and Practicing with Programming Chaska !!!&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2024/04/two-sum-leetcode-solution-and-approach.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0i9nuAQEkOFSXzOZh3mDRoJQDfqIX6LwtfjjD_C5aDsZD3XGp9bgDG6Dd0c77fiz-NrUkHuYGbRE1Gz9zcR512EUkfwRHENnckyocaur0rA0VjzJgCRIVOZgA4ot9TaJIkCx-AJbCVfsm259iC_ZtbwrO2I-9I3fdnbRDUctOA-Qh715Z7jr-PAAHpCMf/s72-c/DSA%20RODMAP%20(1)-min.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-7091374508677641504</guid><pubDate>Mon, 04 Sep 2023 20:42:00 +0000</pubDate><atom:updated>2024-06-01T15:19:39.848+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Experience</category><title>Accenture Interview Experience | Coding Questions</title><description>&lt;h2 style=&quot;text-align: left;&quot;&gt;&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #598cff; font-size: 30px;&quot;&gt;Accenture Interview Experience&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;In this post, I am sharing my personal Accenture interview experience which I got through an off-campus Accenture drive for ASE in July 2023. ASE stands for Associate Software Engineer, which offers a 4.5 LPA salary in 2023. Let&#39;s take a look at the eligibility criteria, Selection Process, and my experience.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;&lt;b&gt;Eligibility Criteria :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;div style=&quot;box-sizing: border-box; flex-shrink: 0; margin-top: var(--bs-gutter-y); max-width: 100%; padding-left: calc(var(--bs-gutter-x) * 0.5); padding-right: calc(var(--bs-gutter-x) * 0.5); width: 1082.67px;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;All streams/branches of B.E/B.Tech/M.E/M.Tech, MCA, and M.Sc. (CSE, IT only) from 2022 &amp;amp; 2023 years of pass outs with full-time education only (Part-time and distance educations are not considered)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;MsoListParagraph&quot; style=&quot;box-sizing: border-box; line-height: 1.8; margin-bottom: 30px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;Note: MBA /PGDBM candidates are not eligible to apply for this role&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;No active backlogs during application and/or during onboarding.&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;You should have completed your relevant degree (eligible for this job role), in the stipulated duration of the degree. Hence, there should be no gaps during the course of your degree.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;MsoListParagraph&quot; style=&quot;box-sizing: border-box; line-height: 1.8; margin-bottom: 30px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;Eg: You must complete your B.Tech in 4 years or M.Tech/MSc in 2 years&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;Your highest educational qualification only will be considered&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;Candidate should not have appeared for the Accenture Recruitment assessment/interview process in the last three months.&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;Candidate should not have more than 11 months of experience.&lt;/span&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot; type=&quot;disc&quot;&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;Candidates must be eligible to work in India either by citizenship/ have relevant work permit documents.&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;Please note that Bhutan and Nepal nationals can work in India without the need to obtain a work visa. All other foreign nationals require a work visa or an Overseas Citizenship of India (OCI) or Person of Indian Origin (PIO) card to work in India&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;You are willing to work in any Business Unit/Service line within the company&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;You are willing to join /relocate to any Accenture office across India&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; flex-shrink: 0; margin-top: var(--bs-gutter-y); max-width: 100%; padding-left: calc(var(--bs-gutter-x) * 0.5); padding-right: calc(var(--bs-gutter-x) * 0.5); width: 1082.67px;&quot;&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; color: #020b2a; font-family: GraphikRegular; font-size: 16px; margin: 0px 0px 30px; padding: 0px;&quot; type=&quot;disc&quot;&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;border-end pe-0 pe-md-2&quot; style=&quot;background-color: #f9f9f9; border-right: 1px solid rgb(222, 226, 230); box-sizing: border-box; color: #020b2a; font-family: GraphikRegular; font-size: 16px; padding-right: 0.5rem;&quot;&gt;&lt;b&gt;Job Type:&lt;/b&gt; Full Time&lt;/div&gt;&lt;div style=&quot;background-color: #f9f9f9; box-sizing: border-box; color: #020b2a; font-family: GraphikRegular; font-size: 16px;&quot;&gt;&lt;b&gt;Location:&lt;/b&gt; Bangalore, Hyderabad, Pune, Mumbai, Chennai, Gurgaon, Kolkata, Indore, Jaipur, Coimbatore&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;&lt;b&gt;Selection Process :&lt;/b&gt;&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s400/Interview%20Experience.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Interview Experience&quot; border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/w320-h208/Interview%20Experience.jpg&quot; title=&quot;Interview Experience&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;h4&gt;&lt;div style=&quot;background-color: white; box-sizing: border-box; flex-shrink: 0; margin-top: var(--bs-gutter-y); max-width: 100%; padding-left: calc(var(--bs-gutter-x) * 0.5); padding-right: calc(var(--bs-gutter-x) * 0.5); width: 1082.67px;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;You will get an email invitation to take part in online tests if you are qualified.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;The assessment has two phases that must be completed within the allotted time.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;span style=&quot;font-weight: bolder;&quot;&gt;Mock Assessment&lt;/span&gt;&lt;/span&gt;&lt;/ul&gt;&lt;/h4&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; font-weight: 400;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot;&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/ul&gt;&lt;h4&gt;&lt;/h4&gt;&lt;h4&gt;&lt;/h4&gt;&lt;h4&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/h4&gt;&lt;h4&gt;&lt;/h4&gt;&lt;h4&gt;&lt;/h4&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;span style=&quot;font-weight: 400;&quot;&gt;You have to give a 20-minute mock test.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;It is required that you take a mock exam, which will check that your computer, software, and internet are up to par.&lt;/li&gt;&lt;/ul&gt;&lt;h4&gt;&lt;/h4&gt;&lt;h4&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;span style=&quot;font-weight: bolder;&quot;&gt;Assessment #1: Cognitive and Technical Assessment&lt;/span&gt;&lt;/span&gt;&lt;/ul&gt;&lt;/h4&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular; font-weight: normal;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot;&gt;You have 90 minutes to finish this assessment. There will be 90 questions. You can switch between questions easily. The level of questions was easy.&amp;nbsp;&lt;/ul&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot;&gt;50 questions are included in the cognitive and technical assessment on:&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;/span&gt;&lt;li&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;English ability&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;Critical thinking and Problem-solving&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;Abstract Reasoning&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;40 questions are included in the tech&lt;/span&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;nical assessment on the following topics:&lt;/span&gt;&lt;div&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular; font-weight: normal;&quot;&gt;&lt;li&gt;Common Application and MS Office&lt;/li&gt;&lt;li&gt;Pseudocode&amp;nbsp;&lt;/li&gt;&lt;li&gt;Fundamentals of Networking, Security, and Cloud&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;Results of the cognitive and technical assessments will be communicated to you within 5 to 10 minutes of completion. You are urged to keep sitting and wait for the outcome. Coding evaluation will start right away after the result notification. For consideration in subsequent stages, you must meet the section and subsection cutoff in our assessment.&lt;/span&gt;&lt;br /&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular; font-weight: normal;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot;&gt;After passing the cognitive and technical assessments, candidates are required to take the mandatory coding assessment. The process will come to an end for candidates who do not pass the cognitive and technical examinations or do not take part in them.&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;color: #020b2a; font-family: GraphikRegular;&quot;&gt;&lt;ul style=&quot;box-sizing: border-box; margin: 0px 0px 30px; padding: 0px; text-align: left;&quot;&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/ul&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; color: #020b2a; font-family: GraphikRegular; font-size: 16px;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;h4 style=&quot;box-sizing: border-box; font-weight: 400; text-align: left;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Assessment #2: Coding assessment&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;box-sizing: border-box; font-weight: 400;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;This test will take 45 minutes to complete 2 Coding Questions. One question was easy and another was of medium difficulty level.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;You will be given two questions to answer in your choice of the following languages.&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;C++, Dot Net, Java, and Python.&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;h4 style=&quot;box-sizing: border-box; font-weight: 400; text-align: left;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Assessment #3: Communication assessment&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;div style=&quot;box-sizing: border-box; font-weight: 400;&quot;&gt;The assessment takes about 30 minutes to complete.&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; font-weight: 400;&quot;&gt;To take part in this evaluation, you will receive a separate email containing deadlines and login information.&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box; font-weight: 400;&quot;&gt;You will be evaluated on the following criteria as part of the communication assessment.&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;ul style=&quot;background-color: white; box-sizing: border-box; margin: 0px 0px 30px; padding: 0px;&quot;&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&lt;b&gt;Sentence Mastery -&lt;/b&gt; You will be given jumbled sentences and you have to place them in the correct order.&lt;/span&gt;&lt;br style=&quot;box-sizing: border-box;&quot; /&gt;&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;Vocabulary -&amp;nbsp;&lt;/span&gt;We have to read the sentence which is currently showing on the screen. This is to test your non-verbal skills like pronunciation.&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;Fluency -&amp;nbsp;&lt;/span&gt;You will be given 2 questions like &quot;Are Arts and Music important in education? Why?&quot;, &quot;Should it be necessary to play sports in school? Why?&quot;, etc. You will have 30 seconds to frame your story in mind and after that, the recording starts.&lt;/li&gt;&lt;li style=&quot;box-sizing: border-box; margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;box-sizing: border-box;&quot;&gt;&lt;b&gt;Pronunciation -&amp;nbsp;&lt;/b&gt;&lt;/span&gt;You will be given only 1 chance to listen to a sentence and have to repeat it exactly. Be sure to pronounce the words exactly as you have listened.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;box-sizing: border-box;&quot;&gt;&lt;h4 style=&quot;box-sizing: border-box; font-weight: 400; text-align: left;&quot;&gt;&lt;span style=&quot;box-sizing: border-box; font-weight: bolder;&quot;&gt;Interview&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;There was only 1 interview in the ASE role which lasted 20-25 minutes. It was &lt;b&gt;not a technical interview&lt;/b&gt; (Not even a single question asked from OOPs, DBMS, DSA, etc.). It was a typical managerial round. You should prepare the managerial questions like what would you do in a particular situation. The panelist was very friendly and nice and made me comfortable like I was talking to my friend. This was my easiest interview so far.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The panelist started with my introduction followed by the project I worked on in my college. Also asked if I have worked or led a team, how do you handle disputes in a team?, Who is your mentor, and tell how he/she helped you in any challenge? , Describe a project you are proud of. There were several questions and ultimately the panelist asked if I had any questions.&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;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;My interview was on 1 August and I got the interview result after 1 month.&amp;nbsp;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So that&#39;s my Accenture Interview Experience. I will be sharing more interview experiences in the future. So keep an eye out and don&#39;t forget to share this and help your friends. I love to hear from your side if this post helps you in any way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2023/09/accenture-interview-experience.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s72-w320-h208-c/Interview%20Experience.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-6098366820799468670</guid><pubDate>Mon, 17 Jul 2023 16:14:00 +0000</pubDate><atom:updated>2024-06-01T15:19:52.562+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Experience</category><title>Hexaware Interview Experience | Coding Questions</title><description>&lt;h2 style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #598cff; font-size: 30px;&quot;&gt;Hexaware Interview Experience&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;In this post, I am sharing my personal Hexaware interview experience which I got through PGET Program in 2022. PGET stands for Premier Graduate Engineer Trainee, which offers 6 LPA salary in 2022. There is another GET program which stands for Graduate Engineer Trainee that offers 4 LPA. My college was eligible for PGET Program. Let&#39;s take a look at the eligibility criteria, Selection Process, and my experience.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;&lt;b&gt;Eligibility Criteria :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;1.&amp;nbsp; 60 % throughout (10th to highest Degree).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2.&amp;nbsp; Branches eligible:&amp;nbsp; CS, IT, EC, EE &amp;amp; EX&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;h3&gt;&lt;b&gt;Selection Process :&lt;/b&gt;&lt;/h3&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s400/Interview%20Experience.jpg&quot; style=&quot;font-weight: 400; margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Interview Experience&quot; border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/w320-h208/Interview%20Experience.jpg&quot; title=&quot;Interview Experience&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;h4&gt;&lt;/h4&gt;&lt;h4&gt;&lt;b&gt;Round 1- A&lt;/b&gt;ptitude Test&lt;b&gt;:&amp;nbsp;&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;This is the first elimination round which contains the Aptitude, Reasoning, and Verbal section. Each section contains 20 questions. So a total of 60 questions are to be solved in 60 minutes. The level of questions is more difficult than I expected, and so, &lt;b&gt;I got eliminated from this round&lt;/b&gt;. Almost half of my friends are able to get through this round. The second round of Coding unlocks only for those who passed the first round.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This round was conducted on 19th July 2023. Later in September, I got a notice from my college that Hexaware cut down the cutoff of the Aptitude round and&amp;nbsp;&lt;b&gt;I am now qualified for the next round.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;h4&gt;&lt;b&gt;Round 2- Coding Test:&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;This is the second elimination round which contains 2 Coding questions that are to be solved within 40 minutes. The level of questions is medium, (not too tough like graph, tree). I got a problem based on set union and intersection property and another was based on framing formula to solve the question which requires an easy level of understanding of basic Mathematics.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Both of my codes passed all the test cases. I was the only one from my college to successfully clear the coding round and got forwarded to the next round of Communication. I personally experienced that the 40 minutes time limit is less, so you should keep an eye on the timer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;Round 3- Communication Round:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This is the third elimination round which contains 4 sections, to be answered in 45 minutes:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Reading- &lt;/b&gt;This section is to test your pronunciation. A sentence is displayed on the screen and we got a few seconds to prepare it in mind and start recording. We have to read the sentence which is currently showing on the screen. This is to test your non-verbal skills like pronunciation, pitch, tone, and volume.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Repeating-&amp;nbsp;&lt;/b&gt;This section is to test your listening skills and short-term memory. You will be given only 1 chance to listen to a sentence and you have to start recording and repeat it exactly. Be sure to pronounce the words exactly as you have listened. The next sentences will keep getting longer, so make sure to listen properly.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Understanding-&amp;nbsp;&lt;/b&gt;This section is to test your understanding and listening skills. You will be given only 1 chance to listen to the story question. You have to understand and remember the story and the questions will be based on the story.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Speaking-&amp;nbsp;&lt;/b&gt;This section is to test your fluency and storytelling. You will be given questions like &quot;Describe your best friend&quot;, &quot;What have you learned from college?&quot;, etc. You will have 30 seconds to frame your story in mind and after that, the recording starts.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;I suggest you be silent for 2 seconds in&amp;nbsp;starting and ending of the recording.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;Technical Interview:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This round lasted 50 minutes. The panelist was an experienced guy. The interview started with my introduction and the interviewer asked me to explain my project. He got deep into the project and I had to explain in detail and answer some questions related to the project like &quot;Why do you use Relational DBMS instead of a traditional Database such as file?&quot;, &quot;Where do you store your data?&quot;, &quot;How&#39;s your project useful?&quot;, &quot;How it is different from the already existing system?&quot; and more.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After answering project-related questions, he moved on to the DSA, OOPs, DBMS, and Networking and asked many basic questions. The questions were so basic that it becomes difficult to answer without using technical terms. For example, He asked me &quot;What is a Data-Structure?&quot; to which I replied that it is the type of structure in the memory to store data and I gave many examples. He was not convinced after several tries. So, I confidently pitched him to give me any DSA-related coding question to which he gave me an easy-level question. I easily solved and explained it and he was convinced.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I successfully cleared the round and got forwarded to the second interview.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h4&gt;Executive Committee Interview&lt;b&gt;:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This round lasted 30 minutes. The panelist was a member of the Executive committee in Hexaware. He was very friendly. We started with the introduction and my project. W had a normal conversation. At last, he asked a few questions related to the project and was impressed. It was my best interview experience so far.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;HR Round:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This round lasted 10 minutes. The HR asked me to introduce myself. He asked a few typical HR questions like &quot;Why do you want to join Hexaware?&quot; &quot;What do you know about Hexaware?&quot;. After, He explained the job role, training details, and salary details.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I got selected for the PGET program. The interviews level were easy compared to the Aptitude, Coding, and Communication round.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So that&#39;s my Hexaware Interview Experience. I will be sharing more interview experiences in the future. So keep an eye out and don&#39;t forget to share this and help your friends. I love to hear from your side if this post helps you in any way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2023/07/hexaware-interview-experience.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s72-w320-h208-c/Interview%20Experience.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-6171263775219973097</guid><pubDate>Mon, 26 Jun 2023 18:29:00 +0000</pubDate><atom:updated>2024-06-01T15:20:37.529+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Experience</category><title>Cisco Ideathon Interview Experience | Coding Questions</title><description>&lt;h2 style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #598cff; font-size: 30px;&quot;&gt;Cisco Interview Experience&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;In this post, I am sharing my personal Cisco interview experience which I got through Cisco Ideathon 2022. The program is a great opportunity for students with potential and creativity to be a part of Cisco’s technological innovation. The qualifiers of the Cisco Ideathon are awarded an internship opportunity followed by full-time placement within Cisco. Let&#39;s take a look at the eligibility criteria, Selection Process, and my experience.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;&lt;b&gt;Eligibility Criteria :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;div&gt;1.&amp;nbsp; 7.0 CGPA in B.Tech. till the current semester. No criteria for 10th and 12th&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2.&amp;nbsp; Students must have completed any One Certification from CISCO as mentioned below :&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;(a) CCNA Module 1 or Networking Essentials&amp;nbsp;&lt;/div&gt;&lt;div&gt;(b) DevNet or Python&lt;/div&gt;&lt;div&gt;(c) CyberOps Associate or Cybersecurity Essentials + Introduction to Cyber Security.&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 class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s400/Interview%20Experience.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Interview Experience&quot; border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/w320-h208/Interview%20Experience.jpg&quot; title=&quot;Interview Experience&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;&lt;b&gt;Selection Process :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNogQzGTJ1NwZgazreb-OnJa5737Ilba6PwVox-Ms6ecYmg8_pCifPUalLfMxqKPJlRemgV7_mLrfz20goluDVAChjENilaMFDEJmVSzt5odjmycmoMCKRW0JQAB1IoLVkTc1oMV-jD01q-5aXc8HaQ-L9hi8CXVtgOovSAwruF3tLOTbOoovMQgsZ5Nmx/s2458/Cisco%20Ideathon%202022%20Dates.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;875&quot; data-original-width=&quot;2458&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNogQzGTJ1NwZgazreb-OnJa5737Ilba6PwVox-Ms6ecYmg8_pCifPUalLfMxqKPJlRemgV7_mLrfz20goluDVAChjENilaMFDEJmVSzt5odjmycmoMCKRW0JQAB1IoLVkTc1oMV-jD01q-5aXc8HaQ-L9hi8CXVtgOovSAwruF3tLOTbOoovMQgsZ5Nmx/s16000/Cisco%20Ideathon%202022%20Dates.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;h4&gt;&lt;b&gt;Registration:&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;There are 2 options to select for Online Assessment -&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Advanced Networking&lt;/li&gt;&lt;li&gt;Advanced Software&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;You can select any in which you feel you are good enough. I had chosen advanced software. I got 90 minutes for the online assessment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4&gt;&lt;b&gt;Round 1 (Online Assessment):&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;This is the first screening round. It contains 4 sections:&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Aptitude section - This section consists of aptitude, reasoning, and verbal questions. It contains 10 questions with 15 minutes time limit.&lt;/li&gt;&lt;li&gt;Networking section - This section consists of 10 questions based on&amp;nbsp;basic networking. You should have a strong understanding of networking concepts to answer the questions.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Coding section - It contains only 1 programming question which is of medium difficulty.&lt;/li&gt;&lt;li&gt;Advanced Networking or Advanced Software - As I selected advanced software, I got 1 extra coding question of medium difficulty level but more difficult than the question in the Coding section. If you select Advance Networking, you will get Networking MCQs.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;I successfully cleared the online assessment round and got forwarded to the next round of idea submission.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;Idea Submission:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;I got a mail which contains 2 problem statements. We have to choose only one problem statement and make a PPT of our idea/solution to solve the problem. One question is based on a Networking problem that any user might face. And another problem is based on a real-life problem. I chose a real-life problem and proposed a solution in PPT. You have to present the PPT in the Technical rounds, so make sure to prepare your presentation and prepare answers to questions that can be asked by the interviewer.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;TR-1 Round (Technical Interview-1):&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This round lasted 1 hour. The panelist was a friendly guy and made me comfortable. In TR-1, the panelist&amp;nbsp;asked me to introduce myself. After the introduction, he asked me to present and explain the PPT. He asked several questions and pointed out the problems with my idea. I was prepared for that and was able to satisfy him.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After the presentation, he asked many basic questions about Networking and also asked me how all layers of TCP/IP protocol work, in detail and step by step. After the networking question, he asked basic questions on DSA, OOPS, DBMS, and Operating Systems. The panelist tries to get deep into all questions means the next questions are related to the previous questions that I answered. In DSA, there were also questions from Graph and Tree but were basic like ways to traverse a Tree.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I successfully cleared the round and got forwarded to the second interview.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;TR+MR -2 Round (Technical and Manager Interview -2):&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This round lasted 45 minutes. In the second round, the panelist asked Technical and Managerial questions. Also, he asked me to present the PPT. He asked several networking questions similar to the previous round.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After Technical questions, he asked me several situation-based questions (Managerial questions). You should prepare for such Managerial&amp;nbsp;questions in advance. And finally, he asked about my hobbies and discussed them. I was able to satisfy him and got forwarded to the HR round.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;HR Round:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;This round lasted 15 minutes. The HR asked me to quickly introduce myself. He asked several typical HR questions like where do you see yourself in 5 years? , What are your plans for future study? , What do you know about Cisco and its competitors? , Why do you want to join Cisco? Explain your job role in Cisco? and Will you work overtime?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Lastly, HR asked told me about the internship and stipend and asked me if I have any questions. I asked what type of projects I will work on in the internship which he didn&#39;t disclose.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Note: All interviews are on the same day and I got the final results on 3rd August. I was not selected for the internship.&lt;/b&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;So that&#39;s my Cisco Interview Experience. I will be sharing more interview experiences in the future. So keep an eye out and don&#39;t forget to share this and help your friends. I love to hear from your side if this post helps you in any way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2023/06/cisco-ideathon-interview-experience.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s72-w320-h208-c/Interview%20Experience.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-2936252847964879458</guid><pubDate>Thu, 08 Dec 2022 12:46:00 +0000</pubDate><atom:updated>2024-06-01T15:21:00.888+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Experience</category><title>Persistent Interview and Internship Experience | Coding Questions</title><description>&lt;h2 style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #598cff; font-size: 30px;&quot;&gt;Persistent Interview Experience&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;In this post, I am sharing my personal persistent interview and 6 Months of internship experience. There is a Martian program by Persistent that provide 5 weeks of training followed by an opportunity for an internship. In my college, Persistent hired me through the Martian program. Let&#39;s take a look at the eligibility criteria, Selection Process, and my experience.&lt;/p&gt;&lt;h3&gt;&lt;b&gt;Eligibility Criteria :&lt;/b&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Minimum 60% in 10th, 12th/Diploma, B.E/BTech (current aggregate)&lt;/li&gt;&lt;li&gt;Branches - CS, IT&lt;/li&gt;&lt;li&gt;No active backlogs&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;&lt;b&gt;Selection Process :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Martian Entry Round (Assessment Test-1):&lt;/b&gt;&lt;/h4&gt;&lt;div&gt;This is the first screening round. It contains aptitude, reasoning, verbal, and technical MCQs, and 2 programming questions of easy and medium levels. The aptitude and reasoning questions are of moderate level. After clearing this round I got selected for 5 weeks Martian Internship in which I learned Computer Networks, DBMS, Data Structure and Algorithms, Operating Systems, and Programming Languages (JAVA/C++/Python) through Persistent courses. After completion of the 5 weeks of Martian Training, we have to clear the final Martian assessment to get the internship certificate and further qualify for interviews.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;Martian Assessment (&lt;/b&gt;&lt;b&gt;Assessment Test-2&lt;/b&gt;&lt;b&gt;):&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;The final Martian assessment test consists of MCQs based on Computer Networks, DBMS, Data Structure and Algorithms, Operating Systems, and Programming Languages (JAVA or C++, or Python).&lt;/div&gt;&lt;div&gt;Again there are 2 Coding Questions of Easy and Medium Difficulty. I cleared this test and got forwarded for the next rounds. We get the internship certificate after passing the final Martian assessment.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;TR-1 Round (Technical Interview):&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s400/Interview%20Experience.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Interview Experience&quot; border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/w320-h208/Interview%20Experience.jpg&quot; title=&quot;Interview Experience&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In TR-1, the panelist asked basic questions on OOPs, Computer Networks, Operating Systems, DBMS, DSA, and JAVA (the language I choose among C++, Python, and JAVA). He&amp;nbsp;tries to get deep into questions means the next question will be related to the previously answered questions. He asked questions on multi-threading, inheritance, polymorphism, and more basic concepts. I had explained overloading vs overriding in detail with code and he was convinced. I cleared this interview and got forwarded to the next interview.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;TR-2 Round (Coding Interview):&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;In TR-2, the interviewer just gave me a coding question and asked me to solve it within 30 minutes. The question complexity is medium. The question is based on Hashmaps and Priority queues or Sorting the Hashmaps. I successfully passed all the test cases and explained my code to the interviewer and cleared this round.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h4&gt;&lt;b&gt;HR Round:&lt;/b&gt;&lt;/h4&gt;&lt;/div&gt;&lt;div&gt;In this round, I gave my introduction to HR. Then there are common HR questions like &quot;Where do you see yourself in 5 years?&quot;, &quot;What do you know about our company?&quot;. Lastly, HR gave me feedback. I cleared this round and got selected for 6 months internship at Persistent Systems.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;&lt;b&gt;My Tips for the Interview:&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Study the basics of all core subjects such as OS, DBMS, Computer Networks, DSA, and Software Engineering.&lt;/li&gt;&lt;li&gt;Prepare for the aptitude and reasoning test as it is the first elimination test and also the opportunity for higher packages was given to those who topped the test.&lt;/li&gt;&lt;li&gt;Prepare and practice the medium-level coding questions based on Arrays, Strings, Hash-Maps, Sorting, Priority Queues, and more.&lt;/li&gt;&lt;li&gt;Be confident in the interview.&lt;/li&gt;&lt;li&gt;Don&#39;t give wrong answers if you don&#39;t know about it. Be honest in a smart way.&lt;/li&gt;&lt;li&gt;Don&#39;t try to be quick, take your time and answer the questions with patience with the use of hand gestures.&lt;/li&gt;&lt;li&gt;Write your introduction and answers to the basic HR Questions and prepare them well. And Also Study the background of the company.&lt;/li&gt;&lt;li&gt;Give a clear, concise, and complete introduction of yourself, and try to include the main skills you have or learned during college and a little bit about the projects and internships that you have done.&lt;/li&gt;&lt;li&gt;The most important thing is don&#39;t be stressed if you&#39;re not selected. There might be many more way better opportunities waiting for you. So be confident, give your best, and grab the right opportunity.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Persistent 6 Months Internship Experience&lt;/span&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;/div&gt;&lt;div&gt;After clearing so many rounds I finally got selected for the 6 Months Internship (called GEMS training) from January to June. The Training has majorly 3 sections:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Foundational Concepts Training: This training&amp;nbsp;is common for all. The training duration is 1 Month. It contains courses such as OOPs, SQL, SDLC, and GIT. After Foundational training, we have to pass its Assessment with a minimum of 70%.&lt;/li&gt;&lt;li&gt;Communication and Power Skills Training: This training is common for all. The course is based on enhancing communication skills and social skills. The Training duration is 2 Months( February and March). After Communication&amp;nbsp;training, we have to pass its assessment named Power Skills Objective with a minimum of 70%.&lt;/li&gt;&lt;li&gt;Core Track Training: After foundational training, we got allocated to different training tracks such as JAVA, Salesforce, Dotnet, UI, and more. I got the JAVA track which contains courses such as Core JAVA, Maven, Spring Boot, HTML &amp;amp; CSS, and JavaScript. After Core Track&amp;nbsp;training,&amp;nbsp;you have to pass a final Core Track assessment which contains objective and subjective questions. My exam was in June and I successfully cleared it and got an internship certificate.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Note- We got 3 attempts in all exams in the GEMS training and the minimum passing percentage is 70%.&lt;/b&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;So that&#39;s my Persistent Interview and Internship Experience. I will be sharing more interview experiences in the future. So keep an eye out and don&#39;t forget to share this and help your friends. I love to hear from your side if this post helps you in any way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/12/persistent-interview-experience.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s72-w320-h208-c/Interview%20Experience.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-7013032829841987557</guid><pubDate>Mon, 13 Jun 2022 08:23:00 +0000</pubDate><atom:updated>2022-06-13T13:53:44.825+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Expected move with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Expected move&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;You are given a
fair coin and two integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;You repeatedly flip
the coin and perform the following operation based on the result:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;If it lands on heads, then&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;will&amp;nbsp;&lt;b&gt;increase&lt;/b&gt;&amp;nbsp;by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;. However, if&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;then&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;will&amp;nbsp;&lt;b&gt;not&lt;/b&gt;&amp;nbsp;change.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;If it lands on tails,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;will&amp;nbsp;&lt;b&gt;decrease&lt;/b&gt;&amp;nbsp;by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;You stop as soon as
the value of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;becomes&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Find the expected
number of coin flips.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;











&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Note that it is
guaranteed that under the given constraints, the answer is an integer and does
not exceed&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2⋅10^18&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first line contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;— the number
of test cases. Then the test cases follow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;

&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first and only line of each test case contains two space-separated
integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;For each testcase,
output the expected number of coin flips.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^5&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;

&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^9&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;12 12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;568
57800&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #333333; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;132&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;





&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;65223144&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;In the first test
case,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;is already&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;. So, the expected
number of the coin flips, in this case, is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;In the second test
case, if the coin lands on the head, X will not change because X is equal to N&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.
Whenever the coin lands on the tail,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;will decrease
by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and the game ends as&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;becomes&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;. The expected
number of coin flips to get the first tail is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;. So, the answer
for the case is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;moves&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;moves&lt;/span&gt; = (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;) * (&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;moves&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&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;/div&gt;&lt;/div&gt;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/expected-move-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-4146600359833163587</guid><pubDate>Mon, 13 Jun 2022 07:56:00 +0000</pubDate><atom:updated>2022-06-13T13:26:52.440+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Reduce to zero with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Reduce to zero&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef has two
integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;. Chef wants to
perform some operations to make both&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;zero
simultaneously. In one operation, Chef can either:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;set&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;:=2⋅&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;or set&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;:=2⋅&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;or set&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;:=&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;:=&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef is a little
busy preparing for the contest. Help him find the minimum number of operations
required to make both&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;equal
to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;simultaneously. If it is
impossible to do so after any number of operations, print&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first line contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;— the number
of test cases. Then the test cases follow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;

&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first and only line of each test case contains two space-separated
integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;For each test case,
print the minimum number of operations required to make&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;zero
simultaneously. If it is impossible to do so after any number of operations,
print&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;instead.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤3⋅10^5&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;

&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;0≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^18&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;99999999999999999
99999999999999999&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;99999999999999999&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Let&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;denote the
values of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;Y&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;respectively.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 1:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;Three operations
are required:&amp;nbsp;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt; (1,2)→ X:=X&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;, serif; padding: 0cm;&quot;&gt;⋅&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: Helvetica, sans-serif; padding: 0cm;&quot;&gt;2→ (2,2) → Y:=Y−1, X:=X−1→ (1,1)→ Y:=Y−1, X:=X−1→ (0,0)&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;It can be proven
that it is impossible in fewer operations.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;)&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; || &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;-1&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nOf2mul&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;)&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;span style=&quot;color: #9cdcfe;&quot;&gt;nOf2mul&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;abs&lt;/span&gt;(&lt;span style=&quot;color: #dcdcaa;&quot;&gt;log2&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;) - &lt;span style=&quot;color: #dcdcaa;&quot;&gt;log2&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;));&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt; += &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nOf2mul&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; * &lt;span style=&quot;color: #dcdcaa;&quot;&gt;pow&lt;/span&gt;(&lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;nOf2mul&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;)&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;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt;--;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; /= &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;;&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;span style=&quot;color: #569cd6;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prev&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; - (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; -= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prev&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt; -= &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prev&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt; += &lt;span style=&quot;color: #9cdcfe;&quot;&gt;prev&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt;++;&lt;span style=&quot;color: #6a9955;&quot;&gt; // operation for 2x&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt; += &lt;span style=&quot;color: #9cdcfe;&quot;&gt;y&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;operations&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&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;/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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/reduce-to-zero-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-733958090175549115</guid><pubDate>Mon, 13 Jun 2022 07:26:00 +0000</pubDate><atom:updated>2022-06-13T12:56:14.459+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Possible GCD with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Possible GCD&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef has two&amp;nbsp;&lt;b&gt;distinct&lt;/b&gt;&amp;nbsp;positive
integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef wonders how many
distinct values are possible for the expression&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd(&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;, where&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;can take any
non-negative integer value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Help Chef find this
value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;





&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Here,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;stands
for&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Greatest_common_divisor&quot;&gt;&lt;span style=&quot;color: #3b5998; font-family: Helvetica, sans-serif;&quot;&gt;Greatest Common
Divisor&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first line contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;— the number
of test cases. Then the test cases follow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;

&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first and only line of each test case contains two distinct space-separated integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;For each testcase,
output the number of distinct values of the expression&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd(&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;, where&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;can take any
non-negative integer value.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤1000&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^9&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;



&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≠&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;12 8&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 1:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;Here&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd(1+&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,2+&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)=1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;no matter
what value of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;you choose.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 2:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;If we take&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=0&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd(12,8)=4&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;If we take&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd(13,9)=1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;If we take&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=2&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd(14,10)=2&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;









&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;It can be shown
that no other value of&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;gcd&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;is possible.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;long&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gcdCount&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; = &lt;span style=&quot;color: #dcdcaa;&quot;&gt;abs&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt;= &lt;span style=&quot;color: #dcdcaa;&quot;&gt;sqrt&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt;); &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; % &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&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;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;d&lt;/span&gt; / &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;)&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gcdCount&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gcdCount&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;;&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;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;gcdCount&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&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;/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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/possible-gcd-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-9086175506419477781</guid><pubDate>Mon, 13 Jun 2022 07:07:00 +0000</pubDate><atom:updated>2022-06-13T12:56:45.824+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Divisible by i with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Divisible by i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;You are given an
integer&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Construct a
permutation&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;of length&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;such that&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;For all&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(1≤&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−1)&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;divides&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs(Pi+1−Pi)&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Recall that a
permutation of length&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;is an array
where every integer from&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;to&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;occurs
exactly once.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;It can be proven
that for the given constraints at least one such&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;always
exists.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The first line of input contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;, denoting the
number of test cases. The description of&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&amp;nbsp;test cases
follows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;

&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The only line of each test case contains an integer&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;- the length
of the array to be constructed.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;For each test case,
output a single line containing&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;space-separated
integers&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;,…,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt; denoting the
elements of the array&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;P&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;If there exist
multiple such arrays, print any.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤5⋅10^4&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2≤&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^5&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;



&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;The sum of&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;over all test cases does not
exceed&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;10^5&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2 1 3&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Test case 1:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;A possible
array satisfying all the conditions is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;[1,2]&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;For&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)=&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(2−1)=1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;is divisible
by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Test case 2:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;A possible
array satisfying all the conditions is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;[2,1,3]&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;For&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)=&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(1−2)=1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;is divisible
by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l1 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;For&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;=2&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;−&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)=&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;abs&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(3−1)=2&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;is divisible
by&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2.&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; - &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; -= &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;)&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;--;&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt; % &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt; += &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;)&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;j&lt;/span&gt;] = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;--;&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;[&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;] &amp;lt;&amp;lt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&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;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/divisible-by-i-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-5871418048535562972</guid><pubDate>Mon, 13 Jun 2022 06:58:00 +0000</pubDate><atom:updated>2022-06-13T12:57:29.317+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Equal Strings  with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Equal Strings&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Given a
string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;of length&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;consisting of
lowercase English alphabet letters.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;You are allowed to
perform the following operation on the string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;any number of
times:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Select a&amp;nbsp;&lt;b&gt;non-empty&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Subsequence&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #3b5998;&quot;&gt;subsequence&lt;/span&gt;&lt;/a&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;of the
array&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;[1, 2, 3,…,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;]&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;and any
lowercase English alphabet&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;α&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;α&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Change&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;to&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;α&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;α&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;for all&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;∈&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Find the minimum
number of operations required to convert&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;into a given
string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;of length&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;consisting of
lowercase English alphabet letters.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The first line of input contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;, denoting the
number of test cases. The description of&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&amp;nbsp;test cases
follows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The first line of each test case contains an integer&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&amp;nbsp;- the length
of the string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The second line of each test case contains the string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;





&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The third line of each test case contains the string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;For each test case,
output the&amp;nbsp;&lt;b&gt;minimum&lt;/b&gt;&amp;nbsp;number of operations required to convert
string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;into string&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^4&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10^5&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;



&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Sum of&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;over all test cases does not
exceed&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;10^5&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;ab&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;cd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;aaa&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;bab&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;abcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;

















&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;aaab&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Test case 1:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;In the first operation, we can choose&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;={1}&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt; and&amp;nbsp;&lt;span style=&quot;border: 1pt none windowtext; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;α=&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;c&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;. After this operation,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;will
become&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;cb&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l1 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;In the second operation, we can choose&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;={2}&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;border: 1pt none windowtext; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;α=&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;d&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;. After this operation,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;will become&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;cd&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Test case 2:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l2 level1 lfo2; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;In the first operation, we can choose&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;={1,3}&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;border: 1pt none windowtext; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;α=&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;b&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;. After this operation,&amp;nbsp;&lt;span style=&quot;border: 1pt none windowtext; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A&lt;/span&gt;&amp;nbsp;will become&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;bab&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;Test case 3:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;In the first operation, we can choose&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;={2,3}&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;border: 1pt none windowtext; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;α=&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;a&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;. After this operation,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;will
become&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;aaad&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;













&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;In the second operation, we can choose&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;={4}&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;border: 1pt none windowtext; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;α=&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;b&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;. After this operation,&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;&amp;nbsp;will
become&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;aaab&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot; style=&quot;color: #4a4a4a;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;bits/stdc++.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;uniqueChars&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;, &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;u&lt;/span&gt; = &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // finding unique characters in b&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #dcdcaa;&quot;&gt;uniqueChars&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;))&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;span style=&quot;color: #9cdcfe;&quot;&gt;u&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;+=&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&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;&lt;span style=&quot;color: #6a9955;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // checking if any unique character need to be replaced&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;u&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;length&lt;/span&gt;(); &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;flag&lt;/span&gt; = &lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &amp;amp;&amp;amp; !(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;))&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;flag&lt;/span&gt; = &lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;;&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;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;flag&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;u&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;length&lt;/span&gt;() - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;k&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&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;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/equal-strings-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-9201950142531103785</guid><pubDate>Sun, 12 Jun 2022 16:21:00 +0000</pubDate><atom:updated>2022-06-12T21:51:31.935+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Alternate Additions with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Alternate Additions&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef has&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;numbers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef will perform
some operations on&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;In the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;th&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;operation:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef will add&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;if&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;is odd.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef will add&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: Helvetica, sans-serif; padding: 0cm;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;if&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;is even.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;border: none; padding: 0cm;&quot;&gt;









&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Chef can stop at
any instant. Can Chef make&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;equal
to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first line contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;— the number
of test cases. Then the test cases follow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0cm 54.75pt; text-indent: -18pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;The first and only line of each test case contains two space separated
integers&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;For each test case,
output&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;if Chef can make&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;equal,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;NO&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;otherwise.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Note that the
checker is case-insensitive. So,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;Yes&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;yEs&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;are all
considered same.&lt;/span&gt;&lt;span style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤1000&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;≤10&lt;sup&gt;9&lt;/sup&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 11.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;1 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;3 6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;4 9&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;10
20&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;YES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;YES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;NO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;





&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15.0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;YES&lt;/span&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 1:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;Chef may
perform one operation to make&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;equal
to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;1−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;→2&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 2:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;3−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;→4−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;+2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;→6&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 3:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;It can be
shown that it is impossible to make&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Math-italic, serif; padding: 0cm;&quot;&gt;B&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;equal.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;





&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;Test case 4:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; padding: 0cm;&quot;&gt;10−&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→11−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→13−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→14−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→16−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→17−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+2&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→19−&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: MathJax_Main, serif; font-size: x-large; padding: 0cm;&quot;&gt;→20&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;diff&lt;/span&gt; = &lt;span style=&quot;color: #9cdcfe;&quot;&gt;b&lt;/span&gt; - &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;diff&lt;/span&gt; % &lt;span style=&quot;color: #b5cea8;&quot;&gt;3&lt;/span&gt; == &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;NO&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;YES&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&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;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/alternate-additions-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-8351975569413024546</guid><pubDate>Sun, 12 Jun 2022 16:04:00 +0000</pubDate><atom:updated>2022-06-12T21:34:57.296+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Subscriptions with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Subscriptions&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p style=&quot;border: none; padding: 0cm; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;A new TV streaming service was recently started in Chefland called the Chef-TV.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;A group of N friends in Chefland want to buy Chef-TV subscriptions. We know that 6 people can share one Chef-TV subscription. Also, the cost of one Chef-TV subscription is X rupees. Determine the minimum total cost that the group of NN friends will incur so that everyone in the group is able to use Chef-TV.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0cm 54.75pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The first line contains a single integer&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&amp;nbsp;— the number
of test cases. Then the test cases follow.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0cm 0cm 0cm 54.75pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;The first and only line of each test case contains two integers&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span face=&quot;MathJax_Math-italic, serif&quot; style=&quot;border: 1pt none windowtext; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;— the size of
the group of friends and the cost of one subscription.&lt;/span&gt;&lt;b style=&quot;font-size: 11.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;For each test case,
output the minimum total cost that the group will incur so that everyone in the
group is able to use Chef-TV.&lt;/span&gt;&lt;o:p style=&quot;font-size: 11.5pt;&quot;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.5pt; mso-fareast-font-family: Symbol; mso-fareast-language: EN-IN;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span face=&quot;&amp;quot;MathJax_Math-italic&amp;quot;,serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;≤1000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.5pt; mso-fareast-font-family: Symbol; mso-fareast-language: EN-IN;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span face=&quot;&amp;quot;MathJax_Math-italic&amp;quot;,serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;≤100&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.5pt; mso-fareast-font-family: Symbol; mso-fareast-language: EN-IN;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;1≤&lt;/span&gt;&lt;span face=&quot;&amp;quot;MathJax_Math-italic&amp;quot;,serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;≤1000&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;1
100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;12
250&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;





&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-language: AR-SA; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;16 135&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 15pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;500&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;



&lt;span style=&quot;border: 1pt none windowtext; color: #333333; font-family: Consolas; font-size: large; line-height: 107%; mso-ansi-language: EN-IN; mso-bidi-font-family: &amp;quot;Courier New&amp;quot;; mso-bidi-language: AR-SA; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;405&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.5pt; mso-fareast-font-family: Symbol; mso-fareast-language: EN-IN;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Test case 1:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;There is only one person in the
group. Therefore he will have to buy&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;subscription.
Therefore the total cost incurred is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;100&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.5pt; mso-fareast-font-family: Symbol; mso-fareast-language: EN-IN;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Test case 2:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;There are&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;12&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;people in the
group. Therefore they will have to buy&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;subscriptions.
Therefore the total cost incurred is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;500&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.5pt; mso-fareast-font-family: Symbol; mso-fareast-language: EN-IN;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Test case 3:&lt;/span&gt;&lt;/b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;There are&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;16&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;people in the
group. Therefore they will have to buy&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;3&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&amp;nbsp;subscriptions.
Therefore the total cost incurred is&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-family: &amp;quot;MathJax_Main&amp;quot;,serif; mso-bidi-font-family: Helvetica; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;405&lt;/span&gt;&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;o:p style=&quot;font-size: 11.5pt;&quot;&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;ceil&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt; / &lt;span style=&quot;color: #b5cea8;&quot;&gt;6.0&lt;/span&gt;) * &lt;span style=&quot;color: #9cdcfe;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;br /&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/subscriptions-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-466883999772201462</guid><pubDate>Fri, 10 Jun 2022 18:10:00 +0000</pubDate><atom:updated>2024-06-01T15:21:18.763+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Interview Experience</category><title>Jio Interview Experience | Coding Questions</title><description>&lt;h2&gt;&lt;span style=&quot;color: #598cff; font-size: 30px;&quot;&gt;JIO Interview Experience&lt;/span&gt;&lt;span style=&quot;color: #598cff; font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;In this post, I am sharing my personal JIO interview experience. Jio came to my college for an on-campus hiring drive. Let&#39;s take a look at the eligibility criteria, Job Description, Selection Process, and my experience.&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Eligibility Criteria :&lt;/b&gt;&lt;/h3&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Minimum 60% in 10th, 12th/Diploma, B.E/BTech (current aggregate)&lt;/li&gt;&lt;li&gt;No year drops during the engineering&lt;/li&gt;&lt;li&gt;No active backlogs&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Job Description :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;Based on the skills of candidates and the requirements of the organization, selected candidates from all three levels will be assigned to different Business Units. You will work in fields like Software development, Testing, Automation Testing, Operations, DevOps, UI/UX, Project Management, Product Management, and Data Analytics. You will get a chance to learn the latest technologies like AI/ML/Data Science etc.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Selection Process :&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;The selection process consists of an online exam followed by two TR+HR interviews. If a candidate fails to pass the online exam then the candidate still has a chance to qualify for the interviews through the GD round. If a candidate fails in GD or any one of the TR+HR rounds, the candidate will be out of the selection process. If the candidate passes the online test, the candidate is directly qualified for the TR+HR interviews.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Online Exam&lt;/b&gt;: It is the first round of the selection process. It consists of MCQ Questions based on Logical Reasoning, Verbal Ability, Domain Knowledge, and Programming. There are two Coding Questions of easy and medium complexity.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;My Experience:&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s400/Interview%20Experience.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img alt=&quot;Interview Experience&quot; border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/w320-h208/Interview%20Experience.jpg&quot; title=&quot;Interview Experience&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In Online Test there are several graph-based statistics questions, Verbal Ability Questions, and Domain Knowledge questions from SQL, OS, and OOP concepts. Both Coding questions are easy. One is based on performing Array Operations and the other is based on guessing numbers(formula-based). I cleared the online test and qualified for the first TR+HR interview.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the First TR+HR interview, the interviewer asked a few HR questions like &quot;What are your Hobbies?&quot;, &quot;Where do you see yourself in 5 years?&quot; and more. The interviewer asked various basic Technical questions&amp;nbsp;about Cloud Computing and its disadvantages, IoT, C vs C++, C++ vs JAVA, Virtual Functions, Interface in JAVA, Multiple Inheritance in JAVA, Constructors, Pointers, and more. My interview lasted about 10 minutes and it was a good experience.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;I was only able to answer about 70-80% of the questions but somehow I qualified for the final TR+HR interview. The Final interview is easier than the previous interview. The interviewers asked very basic questions&amp;nbsp;&lt;b&gt;based on my Resume&amp;nbsp;&lt;/b&gt;on OS, DBMS, Networking, and Data Structures. And after that they asked HR questions like &quot;Why do we hire you?&quot;, &quot;Why do you want to join our company?&quot; and more. I answered all the questions correctly and I got selected.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;My Tips for the Interview:&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Study the basics of all core subjects such as OS, DBMS, Computer Networks, DSA, and Software Engineering.&lt;/li&gt;&lt;li&gt;Prepare and practice the basic coding questions like Fibonacci, Palindrome, and more.&lt;/li&gt;&lt;li&gt;Be confident in the interview.&lt;/li&gt;&lt;li&gt;Don&#39;t give wrong answers if you don&#39;t know about it. Be honest in a smart way.&lt;/li&gt;&lt;li&gt;Don&#39;t try to be quick, take your time and answer the questions with patience with the use of hand gestures.&lt;/li&gt;&lt;li&gt;Write your answers to the basic HR Questions and prepare them well. And Also Study the background of the company.&lt;/li&gt;&lt;li&gt;Give a clear, concise, and complete introduction of yourself, and try to include the main skills you have or learned during college and a little bit about your projects.&lt;/li&gt;&lt;li&gt;The most important thing is don&#39;t be stressed if you&#39;re not selected. There might be many more way better opportunities waiting for you. So be confident, give your best, and grab the right opportunity.&amp;nbsp;&lt;/li&gt;&lt;/ul&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;So that&#39;s my experience in JIO Drive. I will be sharing more interview experiences in the future. So keep an eye out and don&#39;t forget to share this and help your friends. I love to hear from your side if this post helps you in any way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/06/jio-interview-experience.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0t7LZKeryWkjGTK_DIlRdVeNUezOv8UGT5o4_1wHUvyYX9ohrnu4Go9Ctpap_PfjSPXhCWAGyUqPEHRlIRQTXnweIE2XJHcbAA7WygS2nw-mI1FCNJZKp2IN-P1trm-_luswL-zXiisQErCjg5_XNyj5Vnr_EgsK1XQQticTnW3cbRCmlj0NTkpvdww/s72-w320-h208-c/Interview%20Experience.jpg" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India</georss:featurename><georss:point>20.593684 78.96288</georss:point><georss:box>-7.7165498361788458 43.80663 48.903917836178849 114.11913</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-4136284154483788467</guid><pubDate>Tue, 15 Mar 2022 15:31:00 +0000</pubDate><atom:updated>2022-03-15T21:01:10.306+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Wordle with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Wordle&lt;/span&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;Chef invented a modified wordle.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;There is a hidden word S and a guess word T, both of length 5.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;Chef defines a string M to determine the correctness of the guess word. For the ith index:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;If the guess at the ith index is correct, the ith character of M is G.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;If the guess at the ith index is wrong, the ith character of M is B.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px; font-weight: 400;&quot;&gt;Given the hidden word S and guess T, determine string M.&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;font-size: 18px; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;ul&gt;&lt;li&gt;First line will contain T, number of test cases. Then the test cases follow.&lt;/li&gt;&lt;li&gt;Each test case contains of two lines of input.&lt;/li&gt;&lt;li&gt;First line contains the string S - the hidden word.&lt;/li&gt;&lt;li&gt;Second line contains the string T - the guess word.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;For each test case, print the value of string M.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;You may print each character of the string in uppercase or lowercase (for example, the strings BgBgB, BGBGB, bgbGB, and bgbgb will all be treated as identical).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;1≤T≤1000&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;|S|=|T|=5&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;S, T contain uppercase english alphabets only.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;ABCDE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;EDCBA&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;ROUND&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;RINGS&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;START&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;STUNT&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;BBGBB&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;GBBBB&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;GGBBG&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;&lt;b&gt;Test Case 1:&lt;/b&gt; Given string S=ABCDE and T=EDCBA. The string M is:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the first indices, A≠E, thus, M[1]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the second indices, B≠D, thus, M[2]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the third indices, C=C, thus, M[3]=G.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the fourth indices, D≠B, thus, M[4]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the fifth indices, E≠A, thus, M[5]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Thus, M=BBGBB.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;&lt;b&gt;Test Case 2:&lt;/b&gt; Given string S=ROUND and T=RINGS. The string M is:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the first indices, R=R, thus, M[1]=G.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the second indices, O≠I, thus, M[2]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the third indices, U≠N, thus, M[3]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the fourth indices, N≠G, thus, M[4]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Comparing the fifth indices, D≠S, thus, M[5]=B.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 21.3333px;&quot;&gt;Thus, M=GBBBB.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; line-height: 22.8267px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;g&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;g&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;length&lt;/span&gt;(); &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #9cdcfe;&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;G&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;B&quot;&lt;/span&gt;;&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/03/wordle-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-6529016057172709170</guid><pubDate>Sun, 13 Feb 2022 16:55:00 +0000</pubDate><atom:updated>2022-02-13T22:25:43.778+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Xor Palindrome with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Xor Palindrome&lt;/span&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;div&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;

&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; font-weight: normal; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;&quot;&gt;A
(1-indexed) binary string S of length N is called a xor palindrome if the value
of Si&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16pt; font-weight: normal; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;&quot;&gt;⊕&lt;/span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; font-weight: normal; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;&quot;&gt;S(N+1−i) is the same for all 1≤i≤N.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; font-weight: normal; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;&quot;&gt;For
example, 0, 1111 and 0101 are xor palindromes, while 1110 and 110101 are not.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 16pt; font-weight: normal; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;&quot;&gt;You
are given a binary string S of length N. Determine if it is possible to
rearrange it to form a xor palindrome or not.&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;border: none; mso-border-top-alt: solid windowtext .75pt; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b style=&quot;text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;The
first line of input contains a single integer&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;/span&gt;&amp;nbsp;— the number of test
cases. The description of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;/span&gt;&amp;nbsp;test cases follows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;The
first line of each test case contains an integer&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&amp;nbsp;— the length of the
binary string&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;The
second line of each test case contains the binary string&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;/span&gt;&amp;nbsp;containing&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;s and&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;s only.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;For each test case, output&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;YES&lt;/span&gt;&lt;/span&gt;&amp;nbsp;if it is possible to
rearrange&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;S&lt;/span&gt;&lt;/span&gt;&amp;nbsp;to convert
it into a xor palindrome. Otherwise output&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;NO&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 15pt;&quot;&gt;

&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;You may print each character of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;YES&lt;/span&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;NO&lt;/span&gt;&lt;/span&gt;&amp;nbsp;in uppercase or
lowercase (for example,&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;yes&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;yEs&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Yes&lt;/span&gt;&lt;/span&gt;&amp;nbsp;will be considered identical).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;•&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;1≤T≤1000&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;•&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;1≤N≤105&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;•&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;S is a binary string, i.e, contains only the characters 0 and 1&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;•&lt;span style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;It is guaranteed that the sum of N over all test cases does not exceed 2⋅105.&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;text-indent: -24px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;00&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;0011&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;001&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;0001&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Yes&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Yes&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Yes&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 15pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;No&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;:&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;00&lt;/span&gt;&lt;/span&gt;&amp;nbsp;is
already a xor palindrome. [The value of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Si&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;⊕&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;S(N+1−i)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;is&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&amp;nbsp;for all&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤i≤N&lt;/span&gt;&lt;/span&gt;.]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;:&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;0011&lt;/span&gt;&lt;/span&gt;&amp;nbsp;is
already a xor palindrome. [The value of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Si&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;⊕&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;S(N+1−i)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;is&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&amp;nbsp;for all&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤i≤N&lt;/span&gt;&lt;/span&gt;.]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;:&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;001&lt;/span&gt;&lt;/span&gt;&amp;nbsp;can be
rearranged to form&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;010&lt;/span&gt;&lt;/span&gt;&amp;nbsp;which
is a xor palindrome. [The value of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Si&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;⊕&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;S(N+1−i)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;is&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&amp;nbsp;for all&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤i≤N&lt;/span&gt;&lt;/span&gt;.]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;





&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;4&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;: It can be proved that&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;0001&lt;/span&gt;&lt;/span&gt;&amp;nbsp;can not be rearranged to form a xor
palindrome.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;string&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count0&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count1&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;0&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count0&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == &lt;span style=&quot;color: #ce9178;&quot;&gt;&#39;1&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count1&lt;/span&gt;++;&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;count0&lt;/span&gt; % &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; != &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count1&lt;/span&gt; % &lt;span style=&quot;color: #b5cea8;&quot;&gt;2&lt;/span&gt; != &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count0&lt;/span&gt; != &lt;span style=&quot;color: #9cdcfe;&quot;&gt;count1&lt;/span&gt;)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;NO&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;YES&quot;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&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;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</description><link>https://programmingchaska.blogspot.com/2022/02/xor-palindrome-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7586742480288236721.post-3858148710743732721</guid><pubDate>Sat, 12 Feb 2022 07:11:00 +0000</pubDate><atom:updated>2022-02-12T12:41:22.141+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Competitive Coding Questions</category><title>Avoid Fixed Points with Solution</title><description>&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s400/Untitled+design.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;260&quot; data-original-width=&quot;400&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s320/Untitled+design.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;span style=&quot;font-size: 30px;&quot;&gt;Avoid Fixed Points&lt;/span&gt;&lt;span style=&quot;font-size: 22.5pt;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Problem Description:&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;color: black; font-size: medium; font-weight: 400;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Chef has a sequence of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&amp;nbsp;integers&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A=[A1, A2,…, AN]&lt;/span&gt;&lt;/span&gt;. He can perform
the following operation any number of times (possibly, zero):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;Choose&amp;nbsp;&lt;strong&gt;any&lt;/strong&gt;&amp;nbsp;positive
integer&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;K&lt;/span&gt;&lt;/span&gt;&amp;nbsp;and insert
it at any position of the sequence (possibly the beginning or end of the
sequence, or in between any two elements).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;For example, if&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A=[5,3,4]&lt;/span&gt;&lt;/span&gt;&amp;nbsp;and Chef
selects&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;K=2&lt;/span&gt;&lt;/span&gt;, then after
the operation he can obtain one of the sequences&amp;nbsp;[2,5,3,4],[5,2,3,4],[5,3,2,4]
, or [5,3,4,2].&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Chef wants this sequence to satisfy the
following condition: for each&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤i≤&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;,&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Ai≠i&lt;/span&gt;&lt;/span&gt;. Here,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; line-height: 107%; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;denotes the length of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;







&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Help Chef to
find the&amp;nbsp;&lt;strong&gt;minimum&lt;/strong&gt;&amp;nbsp;number
of operations that he has to perform to achieve this goal. It can be proved
that under the constraints of the problem, it&#39;s always possible to achieve this
goal in a finite number of operations.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Input:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;color: black; font-size: medium; font-weight: 400; line-height: normal; margin: 0cm 0cm 0cm 54.75pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;The
first line of input contains an integer&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;/span&gt;, denoting the number of test cases. The
description of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;T&lt;/span&gt;&lt;/span&gt;&amp;nbsp;test cases
follows.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;color: black; font-size: medium; font-weight: 400; line-height: normal; margin: 0cm 0cm 0cm 54.75pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;The
first line of each test case contains an integer&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;color: black; font-size: medium; font-weight: 400; line-height: normal; margin-bottom: 0cm;&quot;&gt;



&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;color: black; font-size: medium; font-weight: 400; line-height: normal; margin: 0cm 0cm 0cm 54.75pt; text-indent: -18pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;The
second line contains&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&amp;nbsp;space-separated integers&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A1, A2,…, AN&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;color: black; font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; color: black; font-size: medium; font-weight: 400; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Output:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;color: black; font-size: medium; font-weight: 400; margin-bottom: 15pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;For each test
case, print a single line containing one integer — the&amp;nbsp;&lt;strong&gt;minimum&lt;/strong&gt;&amp;nbsp;number
of operations that Chef has to perform to achieve the given condition.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; color: black; font-size: medium; font-weight: 400; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Constraints&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤T≤10&lt;sup&gt;4&lt;/sup&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤N≤10&lt;sup&gt;5&lt;/sup&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1≤Ai≤10&lt;sup&gt;9&lt;/sup&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10pt; text-indent: -18pt;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif; font-size: 16pt; text-indent: -18pt;&quot;&gt;Sum
of&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;N&lt;/span&gt;&lt;/span&gt;&amp;nbsp;over all
test cases does not exceed&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot; style=&quot;text-indent: -18pt;&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Cambria Math&amp;quot;,serif; font-size: 16.0pt; mso-bidi-font-family: &amp;quot;Cambria Math&amp;quot;; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;⋅&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot; style=&quot;text-indent: -18pt;&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;10&lt;sup&gt;5&lt;/sup&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif; font-size: 16pt; text-indent: -18pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;nobr aria-hidden=&quot;true&quot; style=&quot;border-width: 0px; box-sizing: border-box; line-height: normal; margin: 0px; max-height: none; max-width: none; min-height: 0px; min-width: 0px; padding: 0px; transition: none 0s ease 0s; vertical-align: 0px;&quot;&gt;

&lt;/nobr&gt;&lt;nobr aria-hidden=&quot;true&quot; style=&quot;border-width: 0px; box-sizing: border-box; line-height: normal; margin: 0px; max-height: none; max-width: none; min-height: 0px; min-width: 0px; padding: 0px; transition: none 0s ease 0s; vertical-align: 0px;&quot;&gt;

&lt;/nobr&gt;&lt;nobr aria-hidden=&quot;true&quot; style=&quot;border-width: 0px; box-sizing: border-box; line-height: normal; margin: 0px; max-height: none; max-width: none; min-height: 0px; min-width: 0px; padding: 0px; transition: none 0s ease 0s; vertical-align: 0px;&quot;&gt;&lt;/nobr&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Input 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;div style=&quot;border: none; line-height: normal; padding: 0cm; text-align: left;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;3&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;3&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;2 4 5&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;3&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;4 1 3&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;4&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px; font-weight: 400;&quot;&gt;3 2 4 2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-size: medium; font-weight: 400;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;border: none; font-weight: 400; line-height: normal; padding: 0cm;&quot;&gt;&lt;p style=&quot;color: black; font-size: medium; margin-bottom: 15pt;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;Sample Output 1:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div style=&quot;margin-bottom: 15pt; text-align: left;&quot;&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;0&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;1&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a;&quot;&gt;&lt;span style=&quot;font-size: 18px;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: black; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-top: solid windowtext 1.0pt; border: none; color: black; font-size: medium; font-weight: 400; mso-border-top-alt: solid windowtext .75pt; mso-element: para-border-div; padding: 8pt 0cm 0cm;&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;border: none; line-height: normal; mso-border-top-alt: solid windowtext .75pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3; mso-padding-alt: 8.0pt 0cm 0cm 0cm; padding: 0cm;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;color: #4a4a4a; font-size: 13.5pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;EXPLANATION:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Helvetica, sans-serif; font-size: 16pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;The given sequence does
not contain any index&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&amp;nbsp;such that&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Ai=i&lt;/span&gt;&lt;/span&gt;. Hence Chef does not have
to perform any operation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;In the given
sequence,&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A3=3&lt;/span&gt;&lt;/span&gt;. Chef can
choose&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;K=2&lt;/span&gt;&lt;/span&gt;&amp;nbsp;and
insert it before the first element, making the sequence&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A=[2,4,1,3]&lt;/span&gt;&lt;/span&gt;, which does not
contain any index&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;for which&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Ai=i&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;Test case&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&amp;nbsp;In the given
sequence,&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A2=2&lt;/span&gt;&lt;/span&gt;. Chef can
perform the following sequence of operations:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;Choose&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;K=5&lt;/span&gt;&lt;/span&gt;&amp;nbsp;and insert it before
the first element. The sequence becomes&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A=[5,3,2,4,2]&lt;/span&gt;&lt;/span&gt;, and now&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A4=4&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt;&quot;&gt;&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 16.0pt; mso-fareast-font-family: Symbol;&quot;&gt;·&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;Choose&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;K=3&lt;/span&gt;&lt;/span&gt;&amp;nbsp;and insert it between
the third and fourth element. The sequence becomes&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;A=[5,3,2,3,4,2]&lt;/span&gt;&lt;/span&gt;, which does not
contain any index&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt;&quot;&gt;&amp;nbsp;for
which&amp;nbsp;&lt;span class=&quot;mjxassistivemathml&quot;&gt;&lt;span style=&quot;border: none windowtext 1.0pt; mso-border-alt: none windowtext 0cm; padding: 0cm;&quot;&gt;Ai=i&lt;/span&gt;&lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: medium;&quot;&gt;









&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;It can be
verified that there is no way to satisfy the given condition in less than two
operations.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 15.0pt;&quot;&gt;&lt;span style=&quot;color: #4a4a4a; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 16.0pt; line-height: 107%;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h2&gt;&lt;span style=&quot;color: #38761d; font-size: x-large;&quot;&gt;Solution:&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div style=&quot;color: black; font-size: medium; font-weight: 400; text-align: left;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0cm; margin-left: 54.75pt; margin-right: 0cm; margin-top: 0cm; margin: 0cm 0cm 0cm 54.75pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt; text-indent: -18pt;&quot;&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;border: 1pt none windowtext; color: #4a4a4a; font-size: 11.5pt; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; padding: 0cm;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #ffa400; font-family: &amp;quot;Times New Roman&amp;quot;,serif; font-size: 20pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN;&quot;&gt;C++:&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div class=&quot;code-toolbar&quot; style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; position: relative;&quot;&gt;&lt;pre class=&quot;language-java&quot; style=&quot;background: rgb(33, 33, 33); border-radius: 0.3em; box-sizing: border-box; color: #f8f8f2; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 6pt; hyphens: none; line-height: 1.5; margin-bottom: 0.5em; margin-top: 0.5em; max-height: 614px; overflow-wrap: normal; overflow: auto; padding: 1em; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;code class=&quot;language-java&quot; style=&quot;background: none; box-sizing: border-box; font-family: Consolas, Monaco, &amp;quot;Andale Mono&amp;quot;, &amp;quot;Ubuntu Mono&amp;quot;, monospace; font-size: 16px; hyphens: none; line-height: 1.5; max-height: 614px; overflow-wrap: normal; tab-size: 4; text-shadow: rgba(0, 0, 0, 0.3) 0px 1px; word-break: normal; word-spacing: normal;&quot;&gt;&lt;div style=&quot;background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14px; line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 15.4px; line-height: 20px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;font-size: 14px; line-height: 19px;&quot;&gt;&lt;div&gt;&lt;div style=&quot;line-height: 19px;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;#include&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #c586c0;&quot;&gt;using&lt;/span&gt; &lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;main&lt;/span&gt;()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;t&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; &lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;minOperations&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;input&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #4ec9b0;&quot;&gt;vector&lt;/span&gt;&amp;lt;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++)&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; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cin&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;input&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;.&lt;span style=&quot;color: #dcdcaa;&quot;&gt;push_back&lt;/span&gt;(&lt;span style=&quot;color: #9cdcfe;&quot;&gt;input&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tempi&lt;/span&gt; = &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;n&lt;/span&gt;; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;++, &lt;span style=&quot;color: #9cdcfe;&quot;&gt;tempi&lt;/span&gt;++)&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; &lt;span style=&quot;color: #c586c0;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #9cdcfe;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: #dcdcaa;&quot;&gt;]&lt;/span&gt; == (&lt;span style=&quot;color: #9cdcfe;&quot;&gt;tempi&lt;/span&gt; + &lt;span style=&quot;color: #b5cea8;&quot;&gt;1&lt;/span&gt;))&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;span style=&quot;color: #9cdcfe;&quot;&gt;tempi&lt;/span&gt;++;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;minOperations&lt;/span&gt;++;&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;br /&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;minOperations&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #dcdcaa;&quot;&gt;endl&lt;/span&gt;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #c586c0;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;;&lt;/div&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;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;toolbar&quot; style=&quot;box-sizing: border-box; opacity: 0; position: absolute; right: 0.2em; top: 0.3em; transition: opacity 0.3s ease-in-out 0s;&quot;&gt;&lt;div class=&quot;toolbar-item&quot; style=&quot;box-sizing: border-box; display: inline-block;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;background-color: #f8f9fa; box-sizing: border-box; color: #212529; font-family: helvetica; font-size: 18.6667px; font-weight: 400; margin-bottom: 1rem; margin-top: 0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/h4&gt;&lt;h4 style=&quot;line-height: normal;&quot;&gt;&lt;div style=&quot;font-weight: 400;&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;font face=&quot;arial&quot;&gt;&lt;b&gt;Don&#39;t forget to share this post.&lt;/b&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/h4&gt;&lt;h1&gt;&lt;span style=&quot;color: #598cff;&quot;&gt;&lt;b&gt;&lt;span face=&quot;&amp;quot;Helvetica&amp;quot;,sans-serif&quot; style=&quot;font-size: 22.5pt; line-height: 32.1px; mso-ansi-language: EN-IN; mso-bidi-language: AR-SA; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;; mso-fareast-language: EN-IN; mso-font-kerning: 18.0pt;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div style=&quot;color: black; font-size: medium; font-weight: 400; text-align: left;&quot;&gt;&lt;span face=&quot;Helvetica, sans-serif&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;color: black; font-size: medium; font-weight: 400; text-align: left;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/h1&gt;</description><link>https://programmingchaska.blogspot.com/2022/02/avoid-fixed-points-with-solution.html</link><author>noreply@blogger.com (Taranjeet Singh Kalsi)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqqFVZ7B1nD-LVrBaMynStZYaf4i8mRkTbMIWBz-KgjcINv4ZH2oGAOFN3iFhpMgcS_UnHS7cnFkCT4sQf0rKrC_gnIhZXf-ZneKVTEJQdIlsXEWqXUOI0qccMMC9AhIC35W9uQOKQIIsr/s72-c/Untitled+design.png" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>