Skip to main content

Posts

Showing posts with the label problem solving

Daily Coding Problem: Balanced parenthesis

My solution to a “Daily Coding Problem” that I received in my mail today. You’re given a string consisting solely of  ( ,  ) , and  * .  *  can represent either a  ( ,  ) , or an empty string. Determine whether the parentheses are balanced. For example,  (()*  and  (*)  are balanced.  )*(  is not balanced. Here’s my solution in Typescript, oneFortyTwo(str: string): boolean { if(str == undefined || str == null) { return false; } //not sure if this is right? if(str.length == 1){ return false; } let balanced: boolean = false; let parenStack = new Stack<string>(); for(let i=0; i < str.length; i++) { let char = str.charAt(i); let topChar = parenStack.peek(); if(topChar == null) { parenStack.push(char); } else { if(topChar == "*") { ...

Daily Coding Problem: Largest no to index i

My solution to a “Daily Coding Problem” that I received in my mail today. Given an array of numbers and an index  i , return the index of the nearest larger number of the number at index  i , where distance is measured in array indices. For example, given  [4, 1, 3, 5, 6]  and index  0 , you should return  3 . If two distances to larger numbers are the equal, then return any one of them. If the array at  i  doesn’t have a nearest larger integer, then return null. Here’s my solution in, oneFortyFour(arr: number[], i: number): number | null { if(arr == null || arr == undefined) { return null; } if(i >= arr.length) { return null; } let distance: number | null = null; let noAtIdxI = arr[i]; for(let iter=0;iter < arr.length; iter++) { if(iter == i) continue; let valAtIter = arr[iter]; if(valAtIter >= noAtIdxI) { if(distance == null) { di...

App store downloads, the next app and a preview of the next blog post

My time was occupied by resolving a few personal matters this last month and a half and therefore it's been some time since I had the opportunity to write a new blog post. A few things have been happening on my end and in this post I will provide some brief info on what some of those things are, namely  A recent spike in downloads for My Day To-Do Lite My next app that I am working on The topic of my next technical blog post or what problem do I solve in it App Store Downloads I always knew about the power of ASO  and localised app name but only recently did I experience the power of ASO first hand. I released My Day To-Do Lite towards the end of December 2015 and it wasn't until September 2016 that I saw a spike in the number of downloads for it. To put this into perspective, the number of downloads I have had for the Lite version in September, October and the first half of Nov, 2016 were more than those combined of all the previous months since it's release. H...