LeetCode # 2 -Add Two Numbers

My submission for LeetCode Add Two Numbers problem:


public class Solution {
   public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
      ListNode retVal = new ListNode(0);
      ListNode head = retVal;
      int carry = 0;
      while(l1 != null || l2 != null){
         int temp = carry;
         if(l1 == null){
            temp += l2.val;
            l2 = l2.next;
         } else if (l2 == null){
            temp += l1.val;
            l1 = l1.next;
         } else {
            temp += l1.val + l2.val;
            l1 = l1.next;
            l2 = l2.next;
         } 

         if(temp >= 9){
            carry = 1;
            temp = temp - 10;
         } else {
            carry = 0;
         }

         retVal.val = temp;
         if(l1 != null || l2 != null){
            retVal.next = new ListNode(0);
            retVal = retVal.next;
         } else if(carry == 1){
            retVal.next = new ListNode(1);
            retVal = retVal.next;
         }
      }
   return head;
   }
}

Advertisements

LeetCode #1 – Two Sum

This is my submission for LeetCode Two Sum Problem:

public class Solution {
   public int[] twoSum(int[] nums, int target) {
      int i;
      int j;
      for(i = 0; i <= nums.length; i++){
         for(j = i+1; j <= nums.length; j++){
            if(nums[i]+nums[j] == target){
               int[] data = {i,j};
               return data;
            }
         }
      }
      return null;
}
}

Play Framework

Choosing the right technology for your product will play a big part on your product success. Nowadays there are tons of framework for you to mix and match to build an awesome technology stack. Nevertheless, more options means more headache to the development team as these framework come with it’s own strength and weakness.

There are no “The Best Framework”. There isn’t one. Heck, it will never exist. The key here, is to choose the right one.¬†Know your product, identify the must-have and nice-to-have, focus on the earlier and start filtering all the framework features so that you can focus your search. Once you did this, now look at yourself and your team, try to draw a line between the product requirement, your team skill, and the technology. There is no point of choosing “fancy and cool” tech if non of your team member have the capability to use it.

On my latest project, I stumbled on Play¬†framework technology. It’s a web apps framework written (beautifully) with Java and Scala. I use Java back in Uni and have a basic knowledge of website development, so I think this framework will do okay for me. In the end, this framework exceed my expectation for me. The learning curve is very steep due to lack of tutorial and so on but once you get the hang of it, there are no turning back (lol). It is very rich yet simple and always deliver. There are tons of built in library and plugin that you can use and very easy to maintain. If you know java, and want to create a simple web apps, I think Play is a must try.

I’m a total newbie on Product Development, but I try to get better each day so one day I could share my knowledge to the others. Let’s hope that those days are not too far from now. Cheers!