<?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 Aakash D. Mehta on Medium]]></title>
        <description><![CDATA[Stories by Aakash D. Mehta on Medium]]></description>
        <link>https://medium.com/@AakashDMehta?source=rss-acea040f1f39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IHvwEaxGsJzYFJXj.jpg</url>
            <title>Stories by Aakash D. Mehta on Medium</title>
            <link>https://medium.com/@AakashDMehta?source=rss-acea040f1f39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 09:01:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@AakashDMehta/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[Subset sum problem dynamic programming]]></title>
            <link>https://medium.com/@AakashDMehta/subset-sum-problem-dynamic-programming-d7be376449dd?source=rss-acea040f1f39------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7be376449dd</guid>
            <category><![CDATA[subset-sum-problem]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <dc:creator><![CDATA[Aakash D. Mehta]]></dc:creator>
            <pubDate>Tue, 06 May 2025 04:47:28 GMT</pubDate>
            <atom:updated>2025-05-06T04:49:17.861Z</atom:updated>
            <content:encoded><![CDATA[<p>While doing interview preparation I came through interesting topic called dynamic programing and got video from <a href="https://www.youtube.com/@techdose4u">Techdose — YouTube</a> for this I will mention video link at the end of an article.</p><p>This article I am writing to showcase</p><ol><li>Visual representation and summary of how recursive and dynamic programs are showcased there.</li><li>Kotlin code for subset sum problem using dynamic programming.</li></ol><p>Let’s first look at the problem.</p><p>We are given one array of n numbers where 0 ≤ n &lt; 10⁶ and we are given sum m now our task is to find possible subset such that sum of element of subset should be equal to m.</p><p>ex: here given array is ar : [2,2,3] and sum is 5 then answer will be true because subset [2,3] is making sum 5</p><p>simillar way if ar : [1,1,1] and sum 4 is given then answer will be false.</p><p>First we will solve this problem using recursive approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*kKu5LIPjMdQn1faxIy_I3Q.png" /><figcaption>subset sum problem recursive approach</figcaption></figure><p>Here we are following recursive approach to solve the given problem. If we write psudo code for this it will be as following.</p><ol><li>iterate given array and start from first index.</li><li>take first item and check by including or excluding that item.</li><li>while including deduct item from sum and store it as resultantSum</li><li>take next item, if next item is lesser then resultantSum then perform step 3</li><li>if next item is greater then sum then perform back tracking and try excluding previous item.</li><li>if next item is equal to current sum then we found the subset which has sum of number is equal to required sum.</li></ol><p>If we try writing logic for that it will look like</p><p>isSSum(set, n, sum) = isSSum(set, n-1, sum) || isSSum(set, n-1,sum — set[n-1])</p><p>In this approach problem is complexity will be O(2^n)</p><p>Second approach will be using dynamic programming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*MhIP__TntKdRPzEbp6tDLQ.png" /><figcaption>subset sum problem using dynamic programing</figcaption></figure><p>If we write psudocode it will be <br>1. Input is ar[n] where ar is given array and n is size of array<br>2. sum = is required sum<br>3. create 2d array of result[n+1][sum+1] of type boolean<br>4. create outer loop for n <br>5. First check nth element is equal to sum then mark result[n][sum] true<br>6. check if by including or excluding nth element sum values are<br>possible to get. based on that set true or false in result array<br>7. if we are excluding item then we need to take A = result[n-1][sum]<br>8. if we are including item then we need to pop back a[n] times and go up 1 time. <br>9. in this process last item is answer.</p><p>And source code will be</p><p><a href="https://pl.kotl.in/qfICj6q5R">Kotlin Playground: Edit, Run, Share Kotlin Code Online</a></p><p>In this approach time complexity becomes O(m * n) where m is number of items and n is sum.</p><p>You can check the whole video at <a href="https://www.youtube.com/watch?v=34l1kTIQCIA&amp;t=5s">subset sum problem dynamic programming | backtracking sum of subsets</a></p><p>And Kudos to Techdose for wonderful explanation.</p><p>Thank You For Reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7be376449dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to paginate your data in Flutter]]></title>
            <link>https://medium.com/solute-labs/paginate-your-data-in-flutter-7744995febd1?source=rss-acea040f1f39------2</link>
            <guid isPermaLink="false">https://medium.com/p/7744995febd1</guid>
            <category><![CDATA[develop]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[cross-platform]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Aakash D. Mehta]]></dc:creator>
            <pubDate>Tue, 15 Jan 2019 17:22:29 GMT</pubDate>
            <atom:updated>2020-08-17T09:54:10.573Z</atom:updated>
            <content:encoded><![CDATA[<p>A simple workaround for the infinite scroll (Pagination) in Flutter ListView!</p><p>We face many requirements in our daily application development for infinite scrolling (pagination)in ListView and we are like.</p><figure><img alt="Flutter pagination request — and our reaction be like-" src="https://cdn-images-1.medium.com/max/523/1*fas0CZhelpgsmDngx6v3bQ.png" /></figure><p>We start creating ListView then create a list of widgets and set scroll listener and set error or failure scenarios and then lastly, stop the pagination when data loading is completed.</p><p>What if I tell you that you have one widget in which you just need to pass your callback with data which will be called when user reach to the end of the list.</p><figure><img alt="Flutter pagination — oh, thats nice" src="https://cdn-images-1.medium.com/max/444/1*5k2Xw6AO3PxT2aB6rfg5LA.gif" /></figure><p>So I’ll first mention how we can implement pagination with a straight forward way and then we’ll look for some better approach.</p><h3>1. Implement pagination from scratch</h3><p>So one initial note to mobile developers that in Android or iOS we were reusing one single view in the list with different data, for eg. if in one viewport there are 7 items visible then, view objects will be created for the same to be reused.</p><p>But in Flutter, architecture is designed in a manner that whenever data is updated all view components(or you can say widget) will be recreated.</p><ul><li>So first we need one ListView widget and one scroll listener to listen to the event when the user reaches at the end of the list to update the data.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b89d3a45582bfaf92e1dc8cad02b19ca/href">https://medium.com/media/b89d3a45582bfaf92e1dc8cad02b19ca/href</a></iframe><ul><li>Secondly, you need to return an appropriate widget on data retrieves. It can be a progress bar, list of widgets or error text as shown in the below code snippet. You can use the Bloc — Stream builder pattern to manage progress, data or error state.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43a15e1399d0ef13371a9d94ee2f95b1/href">https://medium.com/media/43a15e1399d0ef13371a9d94ee2f95b1/href</a></iframe><ul><li>You can display progress at the bottom by returning widget conditionally. You can return view if data retrieves or progress if data is null as shown in below snippet.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/835ea7ae73085bada856118c91523b60/href">https://medium.com/media/835ea7ae73085bada856118c91523b60/href</a></iframe><p>You can get the full source for above implementation from <a href="https://github.com/akashmehta/ExploreFlutter/tree/master/lib/hackerNewsIntegration">here</a></p><p>Now let’s head up to some smart workaround.</p><h3>2. Implement pagination using Flutter Pagination Helper</h3><p>So I figured out some common and boilerplate code and made a generalized solution and created a library for that named <a href="https://pub.dartlang.org/packages/flutter_pagination_helper#-installing-tab-">Flutter Pagination Helper</a>.</p><p>Here are the steps to implement</p><ul><li>Implement flutter pagination dependency by declaring that in pubspec.yaml</li></ul><pre>dependencies:<br>  flutter_pagination_helper: ^1.0.0+5</pre><ul><li>Import required files and initialize PaginatedListWidget as follows.</li></ul><pre><strong>class</strong> <strong>CustomProgressWidget</strong> <strong>extends</strong> <strong>StatelessWidget</strong> {<br>  <strong>@override</strong><br>  Widget <strong>build</strong>(BuildContext context) {<br>    <strong>return</strong> MaterialApp(<br>      home: Scaffold(<br>        body: PaginatedListWidget(<br>            progressWidget: Center(<br>              child: Text(&quot;Loading...&quot;),<br>            ),<br>            itemListCallback: OnScrollCallback()),<br>      ),<br>    );<br>  }<br>}</pre><p>where progressWidget is an optional parameter to assign your custom progress widget and itemListCallback is required parameter in which you need to provide the call back for data in the form of Future.</p><ul><li>Implement ItemListCallback as bellow.</li></ul><pre><strong>class</strong> <strong>OnScrollCallback</strong>&lt;<strong>T</strong> <strong>extends</strong> <strong>Widget</strong>&gt; <strong>extends</strong> <strong>ItemListCallback</strong> {<br>  <strong>@override</strong><br>  Future&lt;EventModel&lt;T&gt;&gt; getItemList() {<br>    <em>// TODO: implement getItemList</em><br>    <strong>return</strong> <strong>null</strong>;<br>  }<br>}</pre><ul><li>Here you need to return your items in the form of Future&lt;EventModel&lt;T&gt;&gt;</li></ul><p>Where EventModel is model which stores different states such as progress bar visibility, data, and error message as below.</p><pre><strong>class</strong> <strong>EventModel</strong>&lt;<strong>T</strong> <strong>extends</strong> <strong>Widget</strong>&gt; {<br>  <strong>final</strong> bool progress;<br>  <strong>final</strong> List&lt;T&gt; data;<br>  <strong>final</strong> String error;<br>  <strong>final</strong> bool stopLoading;<br><br>  EventModel({<strong>this</strong>.progress, <strong>this</strong>.data, <strong>this</strong>.error, <strong>this</strong>.stopLoading});<br>}</pre><p>And your output for the list with default progress widget will be as bellow.</p><figure><img alt="Flutter pagination listview — Default Progress Widget with error" src="https://cdn-images-1.medium.com/max/320/1*2yJapvIy7fs7mJPpBv6zIw.gif" /><figcaption>Default Progress Widget</figcaption></figure><p>And the output for a list with custom progress widget will be as bellow.</p><figure><img alt="Flutter pagination listview— Custom progress widget" src="https://cdn-images-1.medium.com/max/320/1*gd08OhXynqAR6TSeQY--2g.gif" /><figcaption>Custom progress widget</figcaption></figure><h3>Conclusion :</h3><p>For the major requirement of Flutter ListView pagination, Flutter Pagination Helper will be a more suitable option and for more specification, you can go with the first option.</p><p>You can find the full source for the library at</p><p><a href="https://pub.dartlang.org/packages/flutter_pagination_helper#-installing-tab-">flutter_pagination_helper | Flutter Package</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7744995febd1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/solute-labs/paginate-your-data-in-flutter-7744995febd1">How to paginate your data in Flutter</a> was originally published in <a href="https://medium.com/solute-labs">Our LabNotes | SoluteLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get your Alexa skill ready by Kotlin]]></title>
            <link>https://medium.com/solute-labs/head-up-your-alexa-skill-with-kotlin-8ac9775387ae?source=rss-acea040f1f39------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ac9775387ae</guid>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[alexa-skills]]></category>
            <dc:creator><![CDATA[Aakash D. Mehta]]></dc:creator>
            <pubDate>Wed, 02 Jan 2019 23:31:55 GMT</pubDate>
            <atom:updated>2019-01-27T07:41:29.848Z</atom:updated>
            <content:encoded><![CDATA[<p>Alexa, Ask myweather What is the weather here today. ⛅</p><p>Hola folks 👋, from the title you might have got an idea about what we will be discussing here. Adding more to it, here we will take a deep dive to know how we can be able to integrate simple Alexa skill using Kotlin. And for that, we will use weather API.</p><p>To create simple AWS lambda function make sure you full fill following requirements.</p><ol><li>An account in the <a href="https://developer.amazon.com/">Amazon developer console</a>.</li><li>Kotlin supported integrated development environment ( I personally like <a href="https://www.jetbrains.com/idea/">Intelij Idea</a> from Jet brains).</li><li><a href="http://console.aws.amazon.com/">AWS user account</a> with AWS lambda service access.</li></ol><p>We will divide the skill creation process into 3 parts.<br>1. Create skill in Alexa dashboard.</p><p>2. Create AWS lambda function using Kotlin.</p><p>3. Publish lambda function on AWS cloud.</p><h3>1. Create skill in Alexa dashboard.</h3><p>To create simple custom skill you simply need to follow steps provided by <a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html">Alexa documentation</a>. Alexa developer console is too much user-friendly to perform custom skill creation steps. So as a note you will need to follow these steps to build a skill.</p><ul><li><a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html#step-1-design-a-voice-user-interface">Step 1: Design a Voice User Interface</a></li><li><a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html#step-2-set-up-the-skill-in-the-developer-console">Step 2: Set Up the Skill in the Developer Console</a></li><li><a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html#step-3-use-the-voice-design-to-build-your-interaction-model">Step 3: Use the Voice Design to Build Your Interaction Model</a></li><li><a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html#step-4-write-and-test-the-code-for-your-skill">Step 4: Write and Test the Code for Your Skill</a></li><li><a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html#step-5-beta-test-your-skill-optional">Step 5: Beta Test Your Skill (Optional)</a></li><li><a href="https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html#step-6-submit-your-skill-for-certification">Step 6: Submit Your Skill For Certification</a></li></ul><p>I would highly recommend reading this <a href="https://developer.amazon.com/docs/custom-skills/certification-requirements-for-custom-skills.html">Alexa submission checklist</a> before building any skill so that you can get smooth way for skill submission. 📝</p><h3>2. Create AWS lambda function using Kotlin.</h3><p>In section 1, while creating skill we need to develop one lambda function to handle logic in Step 4.</p><blockquote>Requirements :</blockquote><ul><li>Java version &gt;= 1.7</li><li>kotlin version &gt;= 1.1.3–2</li><li><a href="https://mvnrepository.com/artifact/com.amazon.alexa/alexa-skills-kit">Alexa Skills Kit</a></li><li>Apache dependencies: <a href="https://mvnrepository.com/artifact/org.apache.commons/commons-lang3">Commons Lang</a>, <a href="https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient">HttpClient</a>, <a href="https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore">HttpCore</a></li><li>AWS lambda dependencies: <a href="https://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-core">java core</a>, <a href="https://mvnrepository.com/artifact/com.amazonaws/aws-lambda-java-log4j">log4j</a></li><li><a href="https://mvnrepository.com/artifact/tk.plogitech/darksky-forecast-api">DarkSky Forecast API</a></li></ul><blockquote>Implementation :</blockquote><p>To implement you need to follow the steps as mentioned below.</p><ul><li>Create custom SpeechletRequestHandler class and implement your skill</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/786ffe953f7228a6448d19013cd9f48e/href">https://medium.com/media/786ffe953f7228a6448d19013cd9f48e/href</a></iframe><ul><li>Create custom Speechlet class and handle voice intents over there.</li></ul><p>To create custom Speechletwe need to implement Speechlet class and it’s delegate methods. To communicate with Alexa user we have to provide our questions or answers in form of SpeechletResponse that can ask response or tell response which can be generated using SpeechletResponse.newAskResponse() and SpeechletResponse.newTellResponse() respectively, for simplicity you can use following methods to get Speechlet responses.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/310728c5c159ef7422654b70f17ed495/href">https://medium.com/media/310728c5c159ef7422654b70f17ed495/href</a></iframe><p>When the user invokes our skill then initially skill session starts by following method. Here we can initialize our global variables or other callbacks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a50430d747a78242d72c234ea9d402e/href">https://medium.com/media/0a50430d747a78242d72c234ea9d402e/href</a></iframe><p>After we need to provide some skill introduction or welcome message to the user. For that, there is a method in Alexa life cycle named onLaunchwhere we can return SpeechletResponse</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4613dfb76111cf047b2e5f9303233187/href">https://medium.com/media/4613dfb76111cf047b2e5f9303233187/href</a></iframe><p>And now the main logic of the skill will be in onIntent where we will be able to get all user inputs and related information in form of intent and slots which we defined in Alexa dashboard in Step 1.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eaa171039c727f388ad9d65b2a2b1acf/href">https://medium.com/media/eaa171039c727f388ad9d65b2a2b1acf/href</a></iframe><p>And at last but not least we need to destroy all our variables and callbacks when the session ends.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/342fe2e059d2256292ebfa43e9c3dd29/href">https://medium.com/media/342fe2e059d2256292ebfa43e9c3dd29/href</a></iframe><p>In our skill, we have used 3rd party weather API called <a href="https://mvnrepository.com/artifact/tk.plogitech/darksky-forecast-api">DarkSky Forecast API,</a> and OkHttp for network integration. You can simply ask Alexa,</p><blockquote><em>Alexa, ask my weather for weather here today</em></blockquote><p>to know current weather status at your location or you can get weather for any location. You can get the full source code at end of this blog. 👇</p><h3>3. Publish lambda function on AWS cloud.</h3><p>So now let the world know your work 📺. To publish your skill you’ll need to publish your AWS lambda function on AWS cloud.</p><p>For that, you need to create a jar file for lambda function you created in Step 2 using the following command.</p><pre>mvn assembly:assembly -DdescriptorId=jar-with-dependencies package</pre><p>and you’ll find your jar at target folder, you need to pick filename ending -jar-with-dependencies.jar.</p><p>Then you’ll need to navigate to lambda service in AWS.</p><p>On clicking Create function button at top right corner you will get the following page. Here you need to select function pattern as Author from scratch and Runtime java 8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ujXKuCo1XdoFEn8oXT82g.png" /><figcaption>Create lambda function using Author from scratch</figcaption></figure><p>After creating a function you’ll be navigated to function details page where you need to set your skill id and resource which we created in Step 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*srpmZvu7ZCXIlTY3_zdG9w.png" /></figure><p>Here choose Alexa Skills Kit as a trigger from the left side. On clicking that you will get an option to enter your skill id, which you will be able to get from Alexa developer console as described in step 1.</p><p>Then you’ll have to upload your source. Click on lambda function name (here we have used a sample as a function name), and you’ll get the following section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UMgSLhRnS45w19ePpChpqQ.png" /></figure><p>Here you’ll need to upload your .jar file and provide a fully qualified path of SpeechletRequestHandler class.</p><p>Then save your function, copy ARN from the top right corner and paste in Alexa dashboard and we are ready to go. ✈️</p><h3>Conclusion</h3><p>You can create custom Alexa skill with minimum resources. You’ll need proper voice design to match Alexa requirements and basic programming skill and TADA you can teach Alexa new skill.👨‍🏫</p><p><a href="https://github.com/solutelabs/Alexa-WeatherApp">solutelabs/Alexa-WeatherApp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ac9775387ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/solute-labs/head-up-your-alexa-skill-with-kotlin-8ac9775387ae">How to get your Alexa skill ready by Kotlin</a> was originally published in <a href="https://medium.com/solute-labs">Our LabNotes | SoluteLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>