<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Pavitha Pari</title>
    <description>The latest articles on Forem by Pavitha Pari (@pavi30).</description>
    <link>https://forem.com/pavi30</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3269583%2Fb6333aa5-8385-4d30-adf2-55eeb926cef7.png</url>
      <title>Forem: Pavitha Pari</title>
      <link>https://forem.com/pavi30</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pavi30"/>
    <language>en</language>
    <item>
      <title>Find the next number containg all odd digits</title>
      <dc:creator>Pavitha Pari</dc:creator>
      <pubDate>Wed, 08 Apr 2026 02:55:39 +0000</pubDate>
      <link>https://forem.com/pavi30/find-the-next-number-containg-all-odd-digits-kab</link>
      <guid>https://forem.com/pavi30/find-the-next-number-containg-all-odd-digits-kab</guid>
      <description>&lt;p&gt;Just a simple problem:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input:&lt;/strong&gt; &lt;code&gt;1233&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt; &lt;code&gt;1311&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; This is the next smallest integer containing all odd digits.&lt;/p&gt;




&lt;h3&gt;
  
  
  Approach 01 (Brute-force)
&lt;/h3&gt;

&lt;p&gt;Check each number incrementally to see if all digits are odd. Works, but very inefficient for large numbers.&lt;/p&gt;




&lt;h3&gt;
  
  
  Approach 02 (Digit-wise)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Store the digits of &lt;code&gt;n+1&lt;/code&gt; as a list.
&lt;/li&gt;
&lt;li&gt;Scan digits left to right.

&lt;ul&gt;
&lt;li&gt;If a digit is even → change it to the next odd.
&lt;/li&gt;
&lt;li&gt;Replace all digits &lt;strong&gt;after it with 1&lt;/strong&gt; to get the smallest valid number.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
python
n = int(input())
lis = []
temp = n + 1

# Convert number to list of digits
while temp != 0:
    lis.append(temp % 10)
    temp //= 10
lis = lis[::-1]

# Process digits
for i in range(len(lis)):
    if lis[i] % 2 == 0:
        lis[i] += 1  # Change first even digit to next odd
        # Replace all following digits with 1
        for j in range(i+1, len(lis)):
            lis[j] = 1
        break  # Only need to fix the first even digit

# Convert list back to integer
result = int(''.join(map(str, lis)))
print(result)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>coding</category>
      <category>shortnsweet</category>
    </item>
  </channel>
</rss>
