Showing Posts From

Code

Vibe coded my blogging app

Vibe coded my blogging app

Just another late-nighter and the power of AI. I was looking for a VPS to host my blog, basically my admin page, so that I can access it anywhere and start writing my blogs wherever I can, mainly from my mobile. Then, an idea struck my head: why not get an app? Basically, I have the Git token, so I thought of getting an app that can access my GitHub and get this exact repo cloned on my system. And, like I always write blogs on my laptop, I can just use the same technologies to write blogs on my mobile. Then, I sat on my laptop, discussed things with Codex, and we came up with a plan to write an app that can connect to my GitHub, understand my blogging codebase, and create an app around that, matching my workflow. I can see my old posts, update, add, create whatever I want, and just write my blogs from mobile. The GitHub connector page This is where you just create a GitHub app and connect it to your app. Once connected, you will never need to do it again.The old blog posts View/edit your old blog posts and keep things updated.The writer page Write new articles/blogs just from the app and push it to GitHub. Once pushed the same CICD pipeline will make it go live. Easy Peasy.

Just started neetcode blind 150

Just started neetcode blind 150

Just started Neetcode blind 150. This time I'm using java as my tool. Navigating through same challenges and learning more. To be honest, coding on job and coding on coding platform are very different. On job, you use HashMaps and you are mostly done. And there are exceptions when you use DP or Trees. My case, I think I have used mostly all the general data structures and some advanced ones too. But anyways, back to coding and building hand memory again.

Make String a Subsequence Using Cyclic Increments

This is the LeetCode problem number 2825. Cyclic increment This is when you increase an entity by an amount and when you reach the end you circle back to start and continue the count. If a is increased cyclicly by 1, we will get b. If a is increased cyclicly by 2, we will get c. But if z is increased cyclicly by 1, we get a. By 2 we will get b. String increaseCyclic (String str, int index) { char ch = str.charAt(index); char newch = (char) ((ch - 'a' + 1) % 26 + 'a'); return str.substring(0, index) + newChar + str.substring(index + 1); }Subsequence String str1 is said to contain the subsequence of str2 if we can delete some characters from str1 to get str2. During this deletion we are not allowed to disturb the relative order of chars in the str1. A code to check if str1 contains subsequence str2. We can iterate over all the characters of str1 sequencely and check if all the letters are there as in str2. boolean isSubsequence(String str1, String str2) { int p1 = 0; int p2 = 0; while (p1 < str1.length() && p2 < str2.length()) { if (str1.charAt(p1) == str2.charAt(p2)) { p2++; } p1++; } return p2 == str2.length(); }Solution The problem asks us that we are allowed to cyclic increase any number of chars in str1. And check whether we are able to say str1 will contain a subsequence of str2. We can solve this problem by just merging both the problems. Instead of checking just the characters equality, we can add an additional check on character of str1 after increasig it cyclicly. public boolean canMakeSubsequence(String str1, String str2) { int p1 = 0; int p2 = 0; while (p1 < str1.length() && p2 < str2.length()) { char cyclicCh = (char) ((str1.charAt(p1) - 'a' + 1) % 26 + 'a'); if (str1.charAt(p1) == str2.charAt(p2) || cyclicCh == str2.charAt(p2)) { p2++; } p1++; } return p2 == str2.length(); }