<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Safal Ali Khan on Medium]]></title>
        <description><![CDATA[Stories by Safal Ali Khan on Medium]]></description>
        <link>https://medium.com/@safal.ali?source=rss-4068b95e5c53------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*t9P4f9eoeRnkbh3m</url>
            <title>Stories by Safal Ali Khan on Medium</title>
            <link>https://medium.com/@safal.ali?source=rss-4068b95e5c53------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:42:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@safal.ali/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tackling TLE in Java]]></title>
            <link>https://medium.com/@safal.ali/tackling-tle-in-java-7d1f668f0a72?source=rss-4068b95e5c53------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d1f668f0a72</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[string-builder]]></category>
            <category><![CDATA[masai-school]]></category>
            <category><![CDATA[bufferedreader]]></category>
            <dc:creator><![CDATA[Safal Ali Khan]]></dc:creator>
            <pubDate>Thu, 23 Feb 2023 15:07:05 GMT</pubDate>
            <atom:updated>2023-02-23T15:11:15.639Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Students,<br>One of the common issues that we face with <strong>solving DSA problems in Java</strong> is the constant <strong>TLE or Runtime Error</strong> that we get while submitting a problem. This might happen <strong>even when our entire logic is correct.</strong></p><p>We will be going through some of the <strong>solutions</strong> we can use for the above mentioned scenario :</p><p>1) Using <strong><em>FastReader Class</em></strong> to take Input :<br>Instead of using Scanner Class to take different inputs, we can use the FastReader class and its methods to take inputs.<br>Advantages :<br>- Faster than Scanner Class<br>- Same method names as Scanner Class<br>- Easy to use for different types of inputs<br><strong>How to Use</strong> :<br>- Copy and Paste the FastReader Class definition in your program.<br>- Import <strong>java.io</strong> and <strong>java.util</strong> packages.<br>- Declare a FastReader class variable using no argument constructor.<br>- Use the variable to take input using methods like <strong>.next(), .nextLine(), .nextInt(), .nextDouble(),</strong> etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYSlk21KppuXU2vzomzakQ.png" /><figcaption><strong>Link : </strong><a href="https://www.notion.so/Java-64a7c93e16d34a97b09be103abdc2d2b"><strong>Java FastReader</strong></a></figcaption></figure><p><strong>2)</strong> Using <strong>StringBuilder Class</strong> to print Output :</p><p>In case we have to print an answer in different iterations of a loop or different testcases, instead of using System.out.print() for each case, we can using a <strong>String or StringBuilder </strong>class variable to append the answers in different iterations and print it at the end. <br>This will reduce the time because appending answers to a StringBuilder variable takes less time than creating a connection with console each time using System.out .<br>Advantages :<br>- Takes lesser time than printing the output in each iteration<br>- The code looks clean<br><strong>How to Use</strong> :<br>- Create a Stringuilder class variable initially.<br>- Instead of printing, append the relevant answer to the variable.<br>- At the end, print the answer using System.out.println() .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6JpkZeA2P1dJzNX8PDTaQ.png" /><figcaption>Using StrinBuilder to append different answers</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d1f668f0a72" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>