Posts on Marc Lester Tan
http://marctan.com/post/
Recent content in Posts on Marc Lester TanHugo -- gohugo.ioen-usThu, 02 Jul 2020 22:28:10 -0700Binary Tree Level Order Traversal II
http://marctan.com/blog/2020/07/02/binary-tree-level-order-traversal-ii/
Thu, 02 Jul 2020 22:28:10 -0700http://marctan.com/blog/2020/07/02/binary-tree-level-order-traversal-ii/<p>Today, we’re going to solve a variation of the Binary Tree Level Order Traversal.</p>Arranging Coins
http://marctan.com/blog/2020/07/01/arranging-coins/
Wed, 01 Jul 2020 23:12:48 -0700http://marctan.com/blog/2020/07/01/arranging-coins/<p>For the month of July, I decided to get back onto "Leetcoding" after almost 2 weeks of hiatus from solving algorithmic problems.</p>
<p>Every month since April this year, Leetcode organizes this 30-day challenge where each day, you have to solve 1 problem. For today, we are going to solve a problem called <a href="https://leetcode.com/problems/arranging-coins/">"Arranging Coins"</a>.</p>Making Safe Functions
http://marctan.com/blog/2020/06/26/making-safe-functions/
Fri, 26 Jun 2020 21:41:09 -0700http://marctan.com/blog/2020/06/26/making-safe-functions/<p>When we write Kotlin functions, it’s important that we make sure that our code is stable and behave correctly. It’s also important to be clear as to what the function expects in order to behave correctly.</p>Good News
http://marctan.com/blog/2020/06/26/good-news/
Fri, 26 Jun 2020 00:48:19 -0700http://marctan.com/blog/2020/06/26/good-news/It’s been more than a week since I got the result of a 1-year long preparation and I can still feel the excitement, disbelief and nirvana all throughout my body :). I will share more details about it in the upcoming days.Range Sum Query 2D
http://marctan.com/blog/2020/02/27/range-sum-query-2d/
Thu, 27 Feb 2020 17:23:44 -0800http://marctan.com/blog/2020/02/27/range-sum-query-2d/<p>Here’s a hard LC <a href="https://leetcode.com/problems/range-sum-query-2d-mutable/">problem</a> which is actually just a variation of the Range Sum Query problem but instead, you have to work on a 2D data.</p>Filling Bookcase Shelves
http://marctan.com/blog/2020/02/16/filling-bookcase-shelves/
Sun, 16 Feb 2020 00:33:36 -0800http://marctan.com/blog/2020/02/16/filling-bookcase-shelves/<p>Another <a href="https://leetcode.com/problems/filling-bookcase-shelves/">medium</a> LC problem in which we are asked to arrange the books in a bookshelf with certain width and try to minimize the total height of the books after the arrangement.</p>Largest Values From Labels
http://marctan.com/blog/2020/02/16/largest-values-from-labels/
Sun, 16 Feb 2020 00:14:59 -0800http://marctan.com/blog/2020/02/16/largest-values-from-labels/<p>For this <a href="https://leetcode.com/problems/largest-values-from-labels/">medium</a> LC problem, I’m presenting two variations of my solution: Using array and another using PriorityQueue.</p>Shortest Distance to Target Color
http://marctan.com/blog/2020/02/13/shortest-distance-to-target-color/
Thu, 13 Feb 2020 22:12:38 -0800http://marctan.com/blog/2020/02/13/shortest-distance-to-target-color/<p>The solution here for this <a href="https://leetcode.com/problems/shortest-distance-to-target-color/">medium</a> LC problem might not be the fastest but I think it’s really clean and concise and easy to understand.</p>Alphabet Board Path
http://marctan.com/blog/2020/02/13/alphabet-board-path/
Thu, 13 Feb 2020 22:07:41 -0800http://marctan.com/blog/2020/02/13/alphabet-board-path/<p>It took me about 20 minutes to think about the solution for this <a href="https://leetcode.com/problems/alphabet-board-path/">medium</a> LC problem and just few minutes to actually implement the code.</p>Brace Expansion II
http://marctan.com/blog/2020/02/13/brace-expansion-ii/
Thu, 13 Feb 2020 00:49:14 -0800http://marctan.com/blog/2020/02/13/brace-expansion-ii/<p><a href="https://leetcode.com/problems/brace-expansion-ii/">This</a> is a follow-up question for the Brace Expansion problem earlier and the only difference is that now, the braces can be nested multiple times.</p>Brace Expansion
http://marctan.com/blog/2020/02/13/brace-expansion/
Thu, 13 Feb 2020 00:07:34 -0800http://marctan.com/blog/2020/02/13/brace-expansion/<p>This <a href="https://leetcode.com/problems/brace-expansion/">medium</a> LC problem asks us to return all the words formed by expanding the characters inside the braces and appending it to all the other characters present in the string.</p>Contain All Alphabet
http://marctan.com/blog/2020/02/12/contain-all-alphabet/
Wed, 12 Feb 2020 23:13:52 -0800http://marctan.com/blog/2020/02/12/contain-all-alphabet/<p>Recently, somebody posted a problem that was asked in his Google Phone Interview. The first problem was easy and could be solved with an O(n) algorithm.</p>
<pre><code>1. Find out if a string contains all alphabet characters in their respective order.
</code></pre>Redundant Connection
http://marctan.com/blog/2020/02/09/redundant-connection/
Sun, 09 Feb 2020 22:56:19 -0800http://marctan.com/blog/2020/02/09/redundant-connection/<p>This <a href="https://leetcode.com/problems/redundant-connection/">medium</a> LC problem is about finding the edge which causes the tree to have a cycle.</p>Connecting Cities With Minimum Cost
http://marctan.com/blog/2020/02/09/connecting-cities-with-minimum-cost/
Sun, 09 Feb 2020 01:35:23 -0800http://marctan.com/blog/2020/02/09/connecting-cities-with-minimum-cost/<p>This <a href="https://leetcode.com/problems/connecting-cities-with-minimum-cost/">medium</a> LC problem is basically a minimum spanning tree problem therefore we can use Kruskal’s algorithm to solve it.</p>Network Delay Time
http://marctan.com/blog/2020/02/09/network-delay-time/
Sun, 09 Feb 2020 00:56:29 -0800http://marctan.com/blog/2020/02/09/network-delay-time/This medium LC question can be solved by using Djikstra algorithm. The goal is to find the individual distances of nodes from a given node. Then, the maximum distance will be the total network delay time.
The time complexity for this algorithm is O(NlogN + E), N = number of nodes and E = number of edges.Most Stones Removed With Same Row or Column
http://marctan.com/blog/2019/11/20/most-stones-removed-with-same-row-or-column/
Wed, 20 Nov 2019 23:50:47 -0800http://marctan.com/blog/2019/11/20/most-stones-removed-with-same-row-or-column/<p>This <a href="https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/">medium</a> LC question is really difficult to solve if you don’t have any background about Disjoint Sets.</p>Campus Bikes II
http://marctan.com/blog/2019/10/26/campus-bikes-ii/
Sat, 26 Oct 2019 10:40:13 -0700http://marctan.com/blog/2019/10/26/campus-bikes-ii/<p>Here’s a medium (problem)[https://leetcode.com/problems/campus-bikes-ii/] which can be solved by using backtracking. Since the problem mentioned about minimizing the sum of distances for a possible combination of workers and bikes, we can use backtracking to go through all possible combinations of bikes and workers. We also keep track of the minimum sum and use that as the final answer.</p>Range Sum Query Immutable
http://marctan.com/blog/2019/10/23/range-sum-query-immutable/
Wed, 23 Oct 2019 23:06:59 -0700http://marctan.com/blog/2019/10/23/range-sum-query-immutable/<p>An <a href="https://leetcode.com/problems/range-sum-query-immutable/">easy</a> level question with an interesting solution.</p>Character Mapping
http://marctan.com/blog/2019/10/05/character-mapping/
Sat, 05 Oct 2019 23:32:46 -0700http://marctan.com/blog/2019/10/05/character-mapping/<p>This isn’t a solution to a problem but this could be really handy when solving some problems on LC particularly when you need to create a histogram of characters in a particular string. For example, the word “leetcode” will have a histogram of:</p>Set Mismatch
http://marctan.com/blog/2019/10/04/set-mismatch/
Fri, 04 Oct 2019 20:47:08 -0700http://marctan.com/blog/2019/10/04/set-mismatch/<p>To solve this <a href="https://leetcode.com/problems/set-mismatch/">problem</a>, you need to know the arithmetic progression formula.</p>Invalid Transactions
http://marctan.com/blog/2019/10/01/invalid-transactions/
Tue, 01 Oct 2019 21:06:57 -0700http://marctan.com/blog/2019/10/01/invalid-transactions/<p>Starting today, I will try to solve mostly medium level LC questions as I’ve solved about 75% of easy questions. This <a href="https://leetcode.com/problems/invalid-transactions/">one</a> seems to be quite easy as it only involves straightforward logic.</p>Word Pattern
http://marctan.com/blog/2019/09/30/word-pattern/
Mon, 30 Sep 2019 21:32:44 -0700http://marctan.com/blog/2019/09/30/word-pattern/<p>The solution to this <a href="https://leetcode.com/problems/word-pattern/">problem</a> is very easy but I struggled a little bit because I was focusing more on finding a regex to represent the pattern.</p>1-Bit and 2-Bit Characters
http://marctan.com/blog/2019/09/29/1-bit-and-2-bit-characters/
Sun, 29 Sep 2019 22:25:11 -0700http://marctan.com/blog/2019/09/29/1-bit-and-2-bit-characters/<p>The idea to solve this <a href="https://leetcode.com/problems/1-bit-and-2-bit-characters/">problem</a> is to first, get the total number of bits then iterate through each bit and if the previous bit is 1, then deduct 2 from the total number of bits. If it’s a 0, then deduct only 1. In the end, if the total number of bits is equal to 1, then last character must be a 1-bit character.</p>Search in a Sorted Array of Unknown Size
http://marctan.com/blog/2019/09/29/search-in-a-sorted-array-of-unknown-size/
Sun, 29 Sep 2019 20:40:26 -0700http://marctan.com/blog/2019/09/29/search-in-a-sorted-array-of-unknown-size/<p>Honestly, <a href="https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size/">this</a> should be an easy-level problem as it only involves binary search.</p>Binary Watch
http://marctan.com/blog/2019/09/29/binary-watch/
Sun, 29 Sep 2019 17:12:40 -0700http://marctan.com/blog/2019/09/29/binary-watch/<p>As I’ve mentioned before, I really enjoy solving problems involving bit manipulation and this is <a href="https://leetcode.com/problems/binary-watch/">one</a> of the many problems that are fun to solve with.</p>Valid Word Square
http://marctan.com/blog/2019/09/29/valid-word-square/
Sun, 29 Sep 2019 16:30:19 -0700http://marctan.com/blog/2019/09/29/valid-word-square/<p>This is a fun <a href="https://leetcode.com/problems/valid-word-square/">problem</a> to solve and also relatively very easy. I was able to solve this with just one try.</p>Binary Tree Level Order Traversal II
http://marctan.com/blog/2019/09/29/binary-tree-level-order-traversal-ii/
Sun, 29 Sep 2019 16:17:59 -0700http://marctan.com/blog/2019/09/29/binary-tree-level-order-traversal-ii/<p>The solution for this problem is the same as the other similarly named problem. Except at the end, we just have to reverse the list before returning it.</p>Minimum Depth of Binary Tree
http://marctan.com/blog/2019/09/29/minimum-depth-of-binary-tree/
Sun, 29 Sep 2019 12:14:16 -0700http://marctan.com/blog/2019/09/29/minimum-depth-of-binary-tree/<p>Here’s another shot at a tree traversal <a href="https://leetcode.com/problems/minimum-depth-of-binary-tree/">problem</a>. This solution uses Depth-First Traversal.</p>Valid Mountain Array
http://marctan.com/blog/2019/09/29/valid-mountain-array/
Sun, 29 Sep 2019 07:44:40 -0700http://marctan.com/blog/2019/09/29/valid-mountain-array/<p>The idea for this <a href="https://leetcode.com/problems/valid-mountain-array/">problem</a> is to first find the index of the peak. Peak is defined as A[i-1] < A[i] > A[i+1].</p>Get Equal Substrings Within Budget
http://marctan.com/blog/2019/09/29/get-equal-substrings-within-budget/
Sun, 29 Sep 2019 07:11:54 -0700http://marctan.com/blog/2019/09/29/get-equal-substrings-within-budget/<p>The approach for this <a href="https://leetcode.com/problems/get-equal-substrings-within-budget/submissions/">problem</a> is to use sliding window technique after getting an array of all the costs involved per character.</p>Reverse Bits
http://marctan.com/blog/2019/09/28/reverse-bits/
Sat, 28 Sep 2019 22:42:00 -0700http://marctan.com/blog/2019/09/28/reverse-bits/<p>This <a href="https://leetcode.com/problems/reverse-bits/">problem</a> does not support Kotlin yet so I have to do it in Java.</p>Minimum Index Sum of Two Lists
http://marctan.com/blog/2019/09/28/minimum-index-sum-of-two-lists/
Sat, 28 Sep 2019 22:10:24 -0700http://marctan.com/blog/2019/09/28/minimum-index-sum-of-two-lists/<p>The solution for this <a href="https://leetcode.com/problems/minimum-index-sum-of-two-lists/">problem</a> is to loop through any of the list and each time a word exists in both lists, then get the sum of their indexes and use that as the key to store the word in a hashmap. Also, keep track of the lowest key of the map so that later on, you can use that to return the answer.</p>First Unique Character in a String
http://marctan.com/blog/2019/09/27/first-unique-character-in-a-string/
Fri, 27 Sep 2019 22:21:15 -0700http://marctan.com/blog/2019/09/27/first-unique-character-in-a-string/<p>Most problems like this <a href="https://leetcode.com/problems/first-unique-character-in-a-string/">one</a> can be solved by using the character count map. This approach is very effective as it can give you O(n) time complexity.</p>Majority Element
http://marctan.com/blog/2019/09/27/majority-element/
Fri, 27 Sep 2019 21:59:01 -0700http://marctan.com/blog/2019/09/27/majority-element/<p>Writing code in Kotlin brings so much fun particularly when solving Leetcode problems such as this <a href="https://leetcode.com/problems/majority-element/">one</a>.</p>Rotated Digits
http://marctan.com/blog/2019/09/27/rotated-digits/
Fri, 27 Sep 2019 17:03:11 -0700http://marctan.com/blog/2019/09/27/rotated-digits/<p>For this <a href="https://leetcode.com/problems/rotated-digits/">problem</a>, the idea is to swap each digit with their corresponding 180-degree values and use Integer.parseInt to verify if it’s still a valid number. If yes, check also if it’s not equal to the original number as this may also affect the validity of the number.</p>Occurrences After Bigram
http://marctan.com/blog/2019/09/27/occurrences-after-bigram/
Fri, 27 Sep 2019 16:16:06 -0700http://marctan.com/blog/2019/09/27/occurrences-after-bigram/<p>Another easy <a href="https://leetcode.com/problems/occurrences-after-bigram/">one</a> with a straightforward answer.</p>Merge Intervals
http://marctan.com/blog/2019/09/26/merge-intervals/
Thu, 26 Sep 2019 22:50:57 -0700http://marctan.com/blog/2019/09/26/merge-intervals/<p>This is <a href="https://leetcode.com/problems/merge-intervals/">one</a> of the commonly asked questions in LC as there were about 22 companies who’ve used this question in their interviews.</p>Minimum Absolute Difference
http://marctan.com/blog/2019/09/26/minimum-absolute-difference/
Thu, 26 Sep 2019 21:38:14 -0700http://marctan.com/blog/2019/09/26/minimum-absolute-difference/<p>The idea to solve this <a href="https://leetcode.com/problems/minimum-absolute-difference/">problem</a> is to sort the input array and then use a sliding window approach to find the minimum absolute difference between two consecutive elements. If we find a new low, then clear the result and add the current elements. Add more elements if the current diff is equal to the lowest diff so far.</p>How Many Apples Can You Put Into the Basket
http://marctan.com/blog/2019/09/26/how-many-apples-can-you-put-into-the-basket/
Thu, 26 Sep 2019 20:53:38 -0700http://marctan.com/blog/2019/09/26/how-many-apples-can-you-put-into-the-basket/<p>Straightforward solution for this easy <a href="https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket/">problem</a></p>Prime Palindrome
http://marctan.com/blog/2019/09/26/prime-palindrome/
Thu, 26 Sep 2019 17:17:50 -0700http://marctan.com/blog/2019/09/26/prime-palindrome/<p>This is one tough medium problem and I had to look at the official solution to solve this. I can solve for smaller numbers but once it gets to 7+ digits then I always get the Time Limit Exceeded result.</p>Excel Sheet Column Number
http://marctan.com/blog/2019/09/25/excel-sheet-column-number/
Wed, 25 Sep 2019 23:06:06 -0700http://marctan.com/blog/2019/09/25/excel-sheet-column-number/<p>One of the <a href="https://leetcode.com/problems/excel-sheet-column-number/">favorite</a> problems in LC because the problem looks simple but the solution involves quite a bit of analysis.</p>Detect Capital
http://marctan.com/blog/2019/09/25/detect-capital/
Wed, 25 Sep 2019 22:06:45 -0700http://marctan.com/blog/2019/09/25/detect-capital/<p>The easiest way to solve this problem is to count the number of uppercase character. We can easily do that by using map and Character.isUpperCase functions.</p>Meeting Rooms
http://marctan.com/blog/2019/09/25/meeting-rooms/
Wed, 25 Sep 2019 17:49:54 -0700http://marctan.com/blog/2019/09/25/meeting-rooms/<p>I never expect that the solution for this <a href="https://leetcode.com/problems/meeting-rooms/">problem</a> would be this easy so here it goes.</p>Roman to Integer
http://marctan.com/blog/2019/09/25/roman-to-integer/
Wed, 25 Sep 2019 01:31:23 -0700http://marctan.com/blog/2019/09/25/roman-to-integer/<p>I solved <a href="https://leetcode.com/problems/roman-to-integer/">this</a> using Java before so this is just a re-implementation in Kotlin language.</p>Two Sum IV - Input Is a BST
http://marctan.com/blog/2019/09/25/two-sum-iv-input-is-a-bst/
Wed, 25 Sep 2019 01:18:41 -0700http://marctan.com/blog/2019/09/25/two-sum-iv-input-is-a-bst/<p>This is a fun <a href="https://leetcode.com/problems/two-sum-iv-input-is-a-bst/">problem</a> as it really makes you think of how to improve your solution. There are multiple ways of solving this such as iterating through the tree and collecting all the values in a hash set. Then loop through the hash set and find if there are any entry equals to k - current element.</p>Contains-DuplicateII
http://marctan.com/blog/2019/09/24/contains-duplicateii/
Tue, 24 Sep 2019 22:09:28 -0700http://marctan.com/blog/2019/09/24/contains-duplicateii/<p>This is a <a href="https://leetcode.com/problems/contains-duplicate-ii/">variation</a> of the previous problem. Again, this is best solved using hashmap.</p>Contains-Duplicate
http://marctan.com/blog/2019/09/24/contains-duplicate/
Tue, 24 Sep 2019 22:06:16 -0700http://marctan.com/blog/2019/09/24/contains-duplicate/<p>There are multiple ways to solve this <a href="https://leetcode.com/problems/contains-duplicate/">problem</a>. One could sort the arrays and check element by element if two consecutive items are equal.</p>Find the Difference
http://marctan.com/blog/2019/09/23/find-the-difference/
Mon, 23 Sep 2019 23:54:05 -0700http://marctan.com/blog/2019/09/23/find-the-difference/<p>Just another easy <a href="https://leetcode.com/problems/find-the-difference/">problem</a>.</p>Single Element in a Sorted Array
http://marctan.com/blog/2019/09/23/single-element-in-a-sorted-array/
Mon, 23 Sep 2019 23:29:23 -0700http://marctan.com/blog/2019/09/23/single-element-in-a-sorted-array/<p>This medium <a href="https://leetcode.com/problems/single-element-in-a-sorted-array/">problem</a> can be solved easily by few lines of code with O(n) time complexity.</p>Game of Life
http://marctan.com/blog/2019/09/23/game-of-life/
Mon, 23 Sep 2019 22:28:47 -0700http://marctan.com/blog/2019/09/23/game-of-life/<p>Here’s a medium <a href="https://leetcode.com/problems/game-of-life/">problem</a> of which I found out a weird behavior, probably a bug in LeetCode.</p>Shortest Completing Word
http://marctan.com/blog/2019/09/19/shortest-completing-word/
Thu, 19 Sep 2019 22:21:08 -0700http://marctan.com/blog/2019/09/19/shortest-completing-word/The idea to solve this problem is to first create a histogram of characters for the license plate. Then, for each word, and for each character of the word, check if it exists in our histogram and if it is, then reduce the count. If the total sum of the histogram is zero then that means the word completes our license plate and is a candidate for the answer.Max Consecutive Ones
http://marctan.com/blog/2019/09/19/max-consecutive-ones/
Thu, 19 Sep 2019 21:55:15 -0700http://marctan.com/blog/2019/09/19/max-consecutive-ones/<p>I’m starting to enjoy binary related problems particularly bit manipulation. But this <a href="https://leetcode.com/problems/max-consecutive-ones/">time</a>, it’s just plain loop that monitors max count of consecutive ones. Easy peasy.</p>Design HashSet
http://marctan.com/blog/2019/09/19/design-hashset/
Thu, 19 Sep 2019 21:47:49 -0700http://marctan.com/blog/2019/09/19/design-hashset/<p>Another simple <a href="https://leetcode.com/problems/design-hashset/">problem</a> with simple solution :)</p>Verifying an Alien Dictionary
http://marctan.com/blog/2019/09/19/verifying-an-alien-dictionary/
Thu, 19 Sep 2019 21:06:31 -0700http://marctan.com/blog/2019/09/19/verifying-an-alien-dictionary/<p>My answer to this <a href="https://leetcode.com/problems/verifying-an-alien-dictionary/">problem</a> is very verbose and I didn’t like it but it works so ¯_(ツ)_/¯.</p>Partition Array Into Three Parts With Equal Sum
http://marctan.com/blog/2019/09/19/partition-array-into-three-parts-with-equal-sum/
Thu, 19 Sep 2019 20:40:19 -0700http://marctan.com/blog/2019/09/19/partition-array-into-three-parts-with-equal-sum/<p>Easy <a href="https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/">problem</a> with easy solution.</p>Number of Days in a Month
http://marctan.com/blog/2019/09/19/number-of-days-in-a-month/
Thu, 19 Sep 2019 07:10:01 -0700http://marctan.com/blog/2019/09/19/number-of-days-in-a-month/<p><a href="https://leetcode.com/problems/number-of-days-in-a-month/">This</a> is rather easier if you can have access to a calendar to check if a certain year is a leap year, otherwise, you need to memorize this criteria to check if a year is a leap year:</p>Distance Between Bus Stops
http://marctan.com/blog/2019/09/18/distance-between-bus-stops/
Wed, 18 Sep 2019 08:07:42 -0700http://marctan.com/blog/2019/09/18/distance-between-bus-stops/<p>Ok, I cheated on this <a href="https://leetcode.com/problems/distance-between-bus-stops/">one</a> by looking at other people’s solution. I initially tried hard to compute the clockwise and counterclockwise sum without realizing that I can actually just compute the clockwise and subtract it from the total sum. Duh! But I reimplemented the idea using Kotlin’s way so give me credit even just for a bit :D</p>Reverse Linked List
http://marctan.com/blog/2019/09/17/reverse-linked-list/
Tue, 17 Sep 2019 21:42:49 -0700http://marctan.com/blog/2019/09/17/reverse-linked-list/<p>This could be <a href="https://leetcode.com/problems/reverse-linked-list/">one</a> of the most commonly asked questions in LC. This question has been asked in interviews for the following companies: Amazon, Microsoft, Google, Mathworks, Apple, Oracle, Uber etc.</p>Index Pairs of a String
http://marctan.com/blog/2019/09/16/index-pairs-of-a-string/
Mon, 16 Sep 2019 23:14:45 -0700http://marctan.com/blog/2019/09/16/index-pairs-of-a-string/<p>I’ve used Brute-force to solve this <a href="https://leetcode.com/problems/index-pairs-of-a-string/">problem</a>. Other people used Trie to solve but I’m not yet familiar with it.</p>Binary Number With Alternating Bits
http://marctan.com/blog/2019/09/16/binary-number-with-alternating-bits/
Mon, 16 Sep 2019 22:37:25 -0700http://marctan.com/blog/2019/09/16/binary-number-with-alternating-bits/<p>I’m starting to get comfortable with bit manipulation and here’s another <a href="https://leetcode.com/problems/binary-number-with-alternating-bits/">problem</a> that I’ve solved in just a few amount of time.</p>Goat Latin
http://marctan.com/blog/2019/09/16/goat-latin/
Mon, 16 Sep 2019 21:40:52 -0700http://marctan.com/blog/2019/09/16/goat-latin/<p>Easy <a href="https://leetcode.com/problems/goat-latin/">problem</a> with a short solution.</p>Complement of Base 10 Integer
http://marctan.com/blog/2019/09/16/complement-of-base-10-integer/
Mon, 16 Sep 2019 13:58:58 -0700http://marctan.com/blog/2019/09/16/complement-of-base-10-integer/<p>This is an interesting easy <a href="https://leetcode.com/problems/complement-of-base-10-integer/">problem</a>.</p>Flip-Game
http://marctan.com/blog/2019/09/11/flip-game/
Wed, 11 Sep 2019 23:21:36 -0700http://marctan.com/blog/2019/09/11/flip-game/<p>This is another easy LC problem with easy solution.</p>Invert Binary Tree
http://marctan.com/blog/2019/09/11/invert-binary-tree/
Wed, 11 Sep 2019 23:00:10 -0700http://marctan.com/blog/2019/09/11/invert-binary-tree/<p>I initially tried to solve <a href="https://leetcode.com/problems/invert-binary-tree/">this</a> iteratively but I couldn’t figure out the solution. Recursive approach seems to be the best and easiest way.</p>Average of Levels in Binary Tree
http://marctan.com/blog/2019/09/11/average-of-levels-in-binary-tree/
Wed, 11 Sep 2019 21:40:27 -0700http://marctan.com/blog/2019/09/11/average-of-levels-in-binary-tree/<p>Another problem that can be solved easily using recursion and with the help of Kotlin’s operator, everything becomes easy-peasy.</p>Binary Gap
http://marctan.com/blog/2019/09/11/binary-gap/
Wed, 11 Sep 2019 21:27:43 -0700http://marctan.com/blog/2019/09/11/binary-gap/<p>This is a bit manipulation <a href="https://leetcode.com/problems/binary-gap/">problem</a> and the solution, although a bit verbose is really efficient beating 100% of all submission for Kotlin.</p>Sum of Root to Leaf Binary Numbers
http://marctan.com/blog/2019/09/11/sum-of-root-to-leaf-binary-numbers/
Wed, 11 Sep 2019 15:24:01 -0700http://marctan.com/blog/2019/09/11/sum-of-root-to-leaf-binary-numbers/<p>I solved this <a href="https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/">problem</a> initially using Java but here’s a similar implementation using Kotlin.</p>Fizz Buzz
http://marctan.com/blog/2019/09/11/fizz-buzz/
Wed, 11 Sep 2019 13:42:44 -0700http://marctan.com/blog/2019/09/11/fizz-buzz/<p>Another elegant solution for easy LC <a href="https://leetcode.com/problems/fizz-buzz/">problem</a>.</p>Prime Number of Set Bits in Binary Representation
http://marctan.com/blog/2019/09/11/prime-number-of-set-bits-in-binary-representation/
Wed, 11 Sep 2019 11:06:56 -0700http://marctan.com/blog/2019/09/11/prime-number-of-set-bits-in-binary-representation/<p>This solution for easy LC <a href="https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/submissions/">problem</a> is very concise the easy to understand don’t you think?</p>Next Greater Element I
http://marctan.com/blog/2019/09/10/next-greater-element-i/
Tue, 10 Sep 2019 21:14:13 -0700http://marctan.com/blog/2019/09/10/next-greater-element-i/<p>Another easy to understand solution for an easy-level LC problem.</p>Palindrome Permutation
http://marctan.com/blog/2019/09/10/palindrome-permutation/
Tue, 10 Sep 2019 07:38:27 -0700http://marctan.com/blog/2019/09/10/palindrome-permutation/<p>I cheated on this <a href="https://leetcode.com/problems/palindrome-permutation/">easy</a> problem a little bit by looking at the suggested hints.</p>Uncommon Words From Two Sentences
http://marctan.com/blog/2019/09/06/uncommon-words-from-two-sentences/
Fri, 06 Sep 2019 16:26:52 -0700http://marctan.com/blog/2019/09/06/uncommon-words-from-two-sentences/<p>I really don’t like my solution for this one but it’s enough for now. Maybe one way to optimize this is not to use the map and filter operators and just use pure for-loops.</p>Single Number
http://marctan.com/blog/2019/09/05/single-number/
Thu, 05 Sep 2019 22:58:50 -0700http://marctan.com/blog/2019/09/05/single-number/<p>This is an <a href="https://leetcode.com/problems/single-number/">easy</a> but very tricky problem specially if you aren’t too familiar with logical operations.</p>Baseball Game
http://marctan.com/blog/2019/09/05/baseball-game/
Thu, 05 Sep 2019 22:13:36 -0700http://marctan.com/blog/2019/09/05/baseball-game/<p>Another <a href="https://leetcode.com/problems/baseball-game/">problem</a> with a very straighforward answer.</p>Island-Perimeter
http://marctan.com/blog/2019/09/05/island-perimeter/
Thu, 05 Sep 2019 20:59:30 -0700http://marctan.com/blog/2019/09/05/island-perimeter/<p><a href="https://leetcode.com/problems/island-perimeter/">This</a> is definitely an easy one because all you have to do is to that if a block is filled up, check the four conditions:</p>Binary Tree Right Side View
http://marctan.com/blog/2019/09/04/binary-tree-right-side-view/
Wed, 04 Sep 2019 21:12:17 -0700http://marctan.com/blog/2019/09/04/binary-tree-right-side-view/<p>Here’s <a href="https://leetcode.com/problems/binary-tree-right-side-view/">one</a> of my favorite questions in LC. I like this because it looks complicated as it may seem but the approach to the solution is very simple.</p>Valid Palindrome
http://marctan.com/blog/2019/09/04/valid-palindrome/
Wed, 04 Sep 2019 20:47:44 -0700http://marctan.com/blog/2019/09/04/valid-palindrome/<p>Another easy <a href="https://leetcode.com/problems/valid-palindrome/">problem</a> and probably one of the most commonly asked questions in interviews.</p>Last Stone Weight
http://marctan.com/blog/2019/09/04/last-stone-weight/
Wed, 04 Sep 2019 08:30:41 -0700http://marctan.com/blog/2019/09/04/last-stone-weight/<p>Is there any other way to solve this without using PriorityQueue? One could use a list and sort it always everytime a new non-zero value is created from smashing the rocks together but that won’t be that much different than using PriorityQueue which sorts the elements in every <code>offer</code></p>Toeplitz Matrix
http://marctan.com/blog/2019/09/03/toeplitz-matrix/
Tue, 03 Sep 2019 20:48:40 -0700http://marctan.com/blog/2019/09/03/toeplitz-matrix/<p>Not the cleanest solution but so far this is the only solution I can think of for this easy LC <a href="https://leetcode.com/problems/toeplitz-matrix/">problem</a>.</p>Sum of Even Numbers After Queries
http://marctan.com/blog/2019/09/02/sum-of-even-numbers-after-queries/
Mon, 02 Sep 2019 22:17:33 -0700http://marctan.com/blog/2019/09/02/sum-of-even-numbers-after-queries/<p>My first solution to this easy <a href="https://leetcode.com/problems/sum-of-even-numbers-after-queries/">problem</a> passed but only faster than 6% of submissions which means we still have some room for improvements.</p>Compare Strings by Frequency of the Smallest Character
http://marctan.com/blog/2019/09/02/compare-strings-by-frequency-of-the-smallest-character/
Mon, 02 Sep 2019 21:22:41 -0700http://marctan.com/blog/2019/09/02/compare-strings-by-frequency-of-the-smallest-character/<p>This easy problem looks intimidating at first because the description looks complicated but when you analyze it further, the solution is actually straightforward.</p>Number Complement
http://marctan.com/blog/2019/09/02/number-complement/
Mon, 02 Sep 2019 18:20:43 -0700http://marctan.com/blog/2019/09/02/number-complement/<p>Here’s another easy <a href="https://leetcode.com/problems/number-complement/">problem</a> which can be solved by applying logical operators.</p>Keyboard Row
http://marctan.com/blog/2019/09/02/keyboard-row/
Mon, 02 Sep 2019 17:54:40 -0700http://marctan.com/blog/2019/09/02/keyboard-row/<p>This is another <a href="https://leetcode.com/problems/keyboard-row/">one</a> of those problems that I was able to solve in less than 5 minutes.</p>Power of Two
http://marctan.com/blog/2019/09/02/power-of-two/
Mon, 02 Sep 2019 17:20:39 -0700http://marctan.com/blog/2019/09/02/power-of-two/<p>Another beautiful solution to an easy LC <a href="https://leetcode.com/problems/power-of-two/">problem</a>.</p>Find Words That Can Be Formed by Characters
http://marctan.com/blog/2019/08/31/find-words-that-can-be-formed-by-characters/
Sat, 31 Aug 2019 17:19:20 -0700http://marctan.com/blog/2019/08/31/find-words-that-can-be-formed-by-characters/<p>For this easy LC <a href="https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/">problem</a>, the solution is to first, create a map of all the characters in <code>chars</code> and their corresponding count or occurences. We will use occurences later on to count the available characters that can still be used.</p>Happy Number
http://marctan.com/blog/2019/08/30/happy-number/
Fri, 30 Aug 2019 05:50:06 -0700http://marctan.com/blog/2019/08/30/happy-number/<p>This easy problem looks simple at first but it gets very tricky specially when finding out if your loop already started in an endless loop. I did try a couple of ideas without using a list to keep track of previous sums but all didn’t work. Eventually I ended up using a <code>mutableList</code> to maintain a list of previous sums so I can look up and see if the new sum has been solved before. If it is, then it means we entered into an endless loop already.</p>Jewels and Stones
http://marctan.com/blog/2019/08/30/jewels-and-stones/
Fri, 30 Aug 2019 05:16:32 -0700http://marctan.com/blog/2019/08/30/jewels-and-stones/<p>This probably is one the shortest solutions I’ve ever written to a <a href="https://leetcode.com/problems/jewels-and-stones/">problem</a> in LC.</p>Reverse Integer
http://marctan.com/blog/2019/08/30/reverse-integer/
Fri, 30 Aug 2019 05:11:12 -0700http://marctan.com/blog/2019/08/30/reverse-integer/<p>Another super easy <a href="https://leetcode.com/problems/reverse-integer/">problem</a> using math operations. The problem asks us to reverse the digits of an integer. For example, 123 should return 321. You should also maintain the original sign of the number whether it’s positive or negative. This problem took me about 3 minutes to solve.</p>Best Time to Buy and Sell Stock
http://marctan.com/blog/2019/08/29/best-time-to-buy-and-sell-stock/
Thu, 29 Aug 2019 22:45:48 -0700http://marctan.com/blog/2019/08/29/best-time-to-buy-and-sell-stock/<p>This easy LC <a href="https://leetcode.com/problems/best-time-to-buy-and-sell-stock/">problem</a> is just a reword or a variation of a problem that finds a pair with the maximum difference. This can be solved in O(n) because we can calculate the mininum number and maximum difference at the same time as we go through each of the array elements.</p>Subsets
http://marctan.com/blog/2019/08/29/subsets/
Thu, 29 Aug 2019 22:03:22 -0700http://marctan.com/blog/2019/08/29/subsets/<p>The idea to the solution for this medium LC <a href="https://leetcode.com/problems/subsets/">problem</a> is to use bit manipulation to iterate through all possible combination of bits and use this bits to generate the list of subsets. For example, a given array is [1,2,3], you could represent a subset of {1,2,3} as 111, {1,2} as 110, {1} as 100 and so on and so forth.</p>Maximum Subarray
http://marctan.com/blog/2019/08/29/maximum-subarray/
Thu, 29 Aug 2019 16:03:00 -0700http://marctan.com/blog/2019/08/29/maximum-subarray/<p>Another easy LC <a href="https://leetcode.com/problems/maximum-subarray/">problem</a>. Most solutions will probably have O(n^2) or worst but here’s an another solution which has an O(n) time complexity.</p>Two Sum
http://marctan.com/blog/2019/08/29/two-sum/
Thu, 29 Aug 2019 11:03:48 -0700http://marctan.com/blog/2019/08/29/two-sum/<p>This is one of the easiest problem on LC as this has the highest acceptance rate as of now.</p>Maximum Binary Tree
http://marctan.com/blog/2019/08/28/maximum-binary-tree/
Wed, 28 Aug 2019 16:31:35 -0700http://marctan.com/blog/2019/08/28/maximum-binary-tree/<p>We can solve this medium LC <a href="https://leetcode.com/problems/maximum-binary-tree/">problem</a> by recursively finding the index of the highest value (let’s call it as maxIndex) then splitting the array into two subarrays starting from 0 to maxIndex - 1 and maxIndex + 1 to array’s size - 1.</p>
<p>We construct the tree everytime we encounter the max value.</p>Binary Search Tree to Greater Sum Tree
http://marctan.com/blog/2019/08/26/binary-search-tree-to-greater-sum-tree/
Mon, 26 Aug 2019 22:01:59 -0700http://marctan.com/blog/2019/08/26/binary-search-tree-to-greater-sum-tree/<p>The solution to this medium LC problem involves traversing the tree using inorder traversal. In-order traversal means the left node gets the priority, followed by the root node then right node.</p>Transpose Matrix
http://marctan.com/blog/2019/08/26/transpose-matrix/
Mon, 26 Aug 2019 21:15:04 -0700http://marctan.com/blog/2019/08/26/transpose-matrix/<p>Another short solution for this easy LC <a href="https://leetcode.com/problems/transpose-matrix/">problem</a>.</p>Single-Row Keyboard
http://marctan.com/blog/2019/08/25/single-row-keyboard/
Sun, 25 Aug 2019 21:45:10 -0700http://marctan.com/blog/2019/08/25/single-row-keyboard/<p>I solved this easy LC <a href="https://leetcode.com/problems/single-row-keyboard/">problem</a> in less than 5 minutes. Solution is very easy and straightforward. I provided two solutions: One that uses the map operator and another using the good ‘ole for loop.</p>K Closest Points to Origin
http://marctan.com/blog/2019/08/24/k-closest-points-to-origin/
Sat, 24 Aug 2019 21:43:58 -0700http://marctan.com/blog/2019/08/24/k-closest-points-to-origin/<p>To solve this medium LC <a href="https://leetcode.com/problems/k-closest-points-to-origin/">problem</a>, you must first define a function to calculate the Euclidian distance of two points. In this case, we have to find the distance between a point and the origin (0, 0).</p>Number of Lines to Write String
http://marctan.com/blog/2019/08/24/number-of-lines-to-write-string/
Sat, 24 Aug 2019 18:12:14 -0700http://marctan.com/blog/2019/08/24/number-of-lines-to-write-string/<p>The solution to this easy LC <a href="https://leetcode.com/problems/number-of-lines-to-write-string/submissions/">problem</a> is quite simple and I think the code is also self-explanatory so I won’t say that much about this solution.</p>Remove All Adjacent Duplicates in String
http://marctan.com/blog/2019/08/24/remove-all-adjacent-duplicates-in-string/
Sat, 24 Aug 2019 10:44:08 -0700http://marctan.com/blog/2019/08/24/remove-all-adjacent-duplicates-in-string/<p>Not the fastest solution for this easy LC <a href="https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/">problem</a> but it’s readable and easy to understand so I’m fine with this.</p>Shortest Distance to a Character
http://marctan.com/blog/2019/08/23/shortest-distance-to-a-character/
Fri, 23 Aug 2019 23:42:34 -0700http://marctan.com/blog/2019/08/23/shortest-distance-to-a-character/<p>Here’s another tricky easy LC <a href="https://leetcode.com/problems/shortest-distance-to-a-character/submissions/">problem</a>.</p>Matrix Cells in Distance Order
http://marctan.com/blog/2019/08/23/matrix-cells-in-distance-order/
Fri, 23 Aug 2019 21:28:47 -0700http://marctan.com/blog/2019/08/23/matrix-cells-in-distance-order/<p>To solve this easy LC <a href="https://leetcode.com/problems/matrix-cells-in-distance-order/submissions/">problem</a>, my initial idea was to use a TreeMap<Int, Pair<Int, Int>> to store the distance and its corresponding coordinate. TreeMap automatically sorts the keys during insertion so that will save us some time instead of sorting the keys ourselves.</p>Leaf Similar Trees
http://marctan.com/blog/2019/08/22/leaf-similar-trees/
Thu, 22 Aug 2019 23:15:50 -0700http://marctan.com/blog/2019/08/22/leaf-similar-trees/<p>This <a href="https://leetcode.com/problems/leaf-similar-trees/submissions/">problem</a> can be easily solved using recursive way.</p>First Bad Version
http://marctan.com/blog/2019/08/20/first-bad-version/
Tue, 20 Aug 2019 21:44:58 -0700http://marctan.com/blog/2019/08/20/first-bad-version/<p>This easy LC <a href="https://leetcode.com/problems/first-bad-version/submissions/">problem</a> was asked in one of my past interviews (Facebook) which I think I didn’t really answered very well.</p>Maximum Depth of Binary Tree
http://marctan.com/blog/2019/08/20/maximum-depth-of-binary-tree/
Tue, 20 Aug 2019 21:16:58 -0700http://marctan.com/blog/2019/08/20/maximum-depth-of-binary-tree/<p>Another tree traversal easy LC <a href="https://leetcode.com/problems/maximum-depth-of-binary-tree/submissions/">problem</a>.</p>Smallest Range I
http://marctan.com/blog/2019/08/20/smallest-range-i/
Tue, 20 Aug 2019 20:38:17 -0700http://marctan.com/blog/2019/08/20/smallest-range-i/<p>Here’s another short answer for an easy LC <a href="https://leetcode.com/problems/smallest-range-i/submissions/">problem</a>.</p>Reverse Words in a String III
http://marctan.com/blog/2019/08/19/reverse-words-in-a-string-iii/
Mon, 19 Aug 2019 23:52:11 -0700http://marctan.com/blog/2019/08/19/reverse-words-in-a-string-iii/<p>I solved this easy LC <a href="https://leetcode.com/problems/reverse-words-in-a-string-iii/">problem</a> in less than 10 seconds :D</p>Middle of the Linked List
http://marctan.com/blog/2019/08/19/middle-of-the-linked-list/
Mon, 19 Aug 2019 23:29:45 -0700http://marctan.com/blog/2019/08/19/middle-of-the-linked-list/<p>My first solution for this easy LC <a href="https://leetcode.com/problems/middle-of-the-linked-list/submissions/">problem</a> involves traversing the whole linked list to find the total length. Then calculate the mid point and then use this to traverse the linked list again starting from root until mid point.</p>Increasing Order Search Tree
http://marctan.com/blog/2019/08/18/increasing-order-search-tree/
Sun, 18 Aug 2019 21:18:12 -0700http://marctan.com/blog/2019/08/18/increasing-order-search-tree/<p>Tree traversal problems are very common in LC and this easy-level LC <a href="https://leetcode.com/problems/increasing-order-search-tree/">problem</a> looks difficult at first but once you find out the pattern, implementing the solution in recursive way is very easy.</p>Available Captures for Rook
http://marctan.com/blog/2019/08/17/available-captures-for-rook/
Sat, 17 Aug 2019 10:02:33 -0700http://marctan.com/blog/2019/08/17/available-captures-for-rook/<p>I tried to simplify the solution for this easy LC <a href="https://leetcode.com/problems/available-captures-for-rook/">problem</a> but I guess this could’ve been the simplest I can get to. Not a beautiful code but this’ll do for now.</p>Projection Area of 3D Shapes
http://marctan.com/blog/2019/08/17/projection-area-of-3d-shapes/
Sat, 17 Aug 2019 09:05:33 -0700http://marctan.com/blog/2019/08/17/projection-area-of-3d-shapes/<p>At first, the <a href="https://leetcode.com/problems/projection-area-of-3d-shapes/">problem</a> looks very difficult as it involves multi-dimensional array and projections but the graph in the example really gives out the clue about how to solve this problem.</p>Maximum Depth of N-Ary Tree
http://marctan.com/blog/2019/08/15/maximum-depth-of-n-ary-tree/
Thu, 15 Aug 2019 21:56:33 -0700http://marctan.com/blog/2019/08/15/maximum-depth-of-n-ary-tree/<p>Easy LC <a href="https://leetcode.com/problems/maximum-depth-of-n-ary-tree/">problem</a> again but this time the problem doesn’t support Kotlin yet so my solution will be in Java.</p>Sort Array By Parity II
http://marctan.com/blog/2019/08/14/sort-array-by-parity-ii/
Wed, 14 Aug 2019 17:02:05 -0700http://marctan.com/blog/2019/08/14/sort-array-by-parity-ii/<p>Here’s another easy-level LC <a href="https://leetcode.com/problems/sort-array-by-parity-ii/submissions/">problem</a>. My initial solution uses two pointers: One to keep track of the index of the next even number and another for odd number.</p>Merge K-Sorted Lists
http://marctan.com/blog/2019/08/14/merge-k-sorted-lists/
Wed, 14 Aug 2019 07:04:47 -0700http://marctan.com/blog/2019/08/14/merge-k-sorted-lists/<p>This is a Hard-level Leetcode <a href="https://leetcode.com/problems/merge-k-sorted-lists/">problem</a> although the solution looks very trivial to me.</p>Squares of Sorted Array
http://marctan.com/blog/2019/08/13/squares-of-sorted-array/
Tue, 13 Aug 2019 22:59:17 -0700http://marctan.com/blog/2019/08/13/squares-of-sorted-array/<p>I solved this <a href="https://leetcode.com/problems/squares-of-a-sorted-array/">problem</a> in like, maybe 5 seconds haha.</p>Total Hamming Distance
http://marctan.com/blog/2019/08/13/total-hamming-distance/
Tue, 13 Aug 2019 22:44:21 -0700http://marctan.com/blog/2019/08/13/total-hamming-distance/<p>My initial solution to this medium leetcode <a href="https://leetcode.com/problems/total-hamming-distance/">problem</a> uses Kernighan’s way to calculate the number of 1’s in a binary:</p>Height Checker
http://marctan.com/blog/2019/08/13/height-checker/
Tue, 13 Aug 2019 22:35:53 -0700http://marctan.com/blog/2019/08/13/height-checker/<p>I really liked the solution to this <a href="https://leetcode.com/problems/height-checker/">problem</a> as the code is extremely short. Thanks to Kotlin’s built-in operators.</p>Defanging an IP Address
http://marctan.com/blog/2019/08/13/defanging-an-ip-address/
Tue, 13 Aug 2019 22:26:43 -0700http://marctan.com/blog/2019/08/13/defanging-an-ip-address/<p>Just take a look at how easy it is to solve this Easy-level Leetcode <a href="https://leetcode.com/problems/defanging-an-ip-address/">question</a> using Kotlin:</p>Candy Dispenser
http://marctan.com/blog/2017/06/14/candy-dispenser/
Wed, 14 Jun 2017 19:39:55 -0700http://marctan.com/blog/2017/06/14/candy-dispenser/<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<p>At Google I/O 2017, people who completed the IoT Codelabs were given an awesome reward: A Pico Maker Kit for Android Things. It’s basically another hardware development platform just like Raspberry Pi and Intel Edison.</p>Hello Android Things
http://marctan.com/blog/2017/01/12/hello-android-things/
Thu, 12 Jan 2017 14:54:22 -0800http://marctan.com/blog/2017/01/12/hello-android-things/<!-- raw HTML omitted -->Moving to Silicon Valley
http://marctan.com/blog/2015/09/18/moving-to-silicon-valley/
Fri, 18 Sep 2015 20:56:43 -0700http://marctan.com/blog/2015/09/18/moving-to-silicon-valley/<!-- raw HTML omitted -->
<p>Whoah, it’s been a while since I last blogged and all I can say is, now that I’m starting a new life in California, I think I will try to push myself to post more personal stories and technical articles.</p>GDG GeorgeTown Devfest Slides
http://marctan.com/blog/2014/11/17/gdg-georgetown-devfest-slides/
Mon, 17 Nov 2014 00:00:00 +0000http://marctan.com/blog/2014/11/17/gdg-georgetown-devfest-slides/<!-- raw HTML omitted -->
<p>Here are the slides for the Android Wear presentation that I presented in GDG GeorgeTown’s first ever Devfest + Gdays last November 15, 2014.</p>Reading Heart Rate Data from Samsung Gear Live
http://marctan.com/blog/2014/07/08/reading-heart-rate-data-from-samsung-gear-live/
Tue, 08 Jul 2014 00:00:00 +0000http://marctan.com/blog/2014/07/08/reading-heart-rate-data-from-samsung-gear-live/<!-- raw HTML omitted -->
<p>Here’s a quick tutorial on how to get data from the heart rate sensor in your Samsung Gear Live watch.</p>SAP Inside Track Singapore 2014
http://marctan.com/blog/2014/01/11/sap-inside-track-singapore-2014/
Sat, 11 Jan 2014 00:00:00 +0000http://marctan.com/blog/2014/01/11/sap-inside-track-singapore-2014/<!-- raw HTML omitted -->
<p>Here are the slides for my talk @ SAP Inside Track Singapore 2014 entitled: Rapid Prototyping with Grails on HANA Cloud Platform.</p>Instagram Network Analysis
http://marctan.com/blog/2013/12/01/instagram-network-analysis/
Sun, 01 Dec 2013 00:00:00 +0000http://marctan.com/blog/2013/12/01/instagram-network-analysis/<!-- raw HTML omitted -->
<h3 id="introduction">Introduction</h3>
<p>Social networking has become one of the most important topics in recent times because of the several social networking sites that have now become part of our day-to-day living. There’s a huge amount of information that we can gather from analyzing these social network.</p>GDG Kota Kinabalu Devfest Talk
http://marctan.com/blog/2013/11/29/gdg-kota-kinabalu-devfest-talk/
Fri, 29 Nov 2013 00:00:00 +0000http://marctan.com/blog/2013/11/29/gdg-kota-kinabalu-devfest-talk/<!-- raw HTML omitted -->
<p>I just want to share the slides that I’ve used during my talk in GDG Kota Kinabalu Devfest last November 16, 2013. My talk is all about Arduino and Android. In the presentation, I briefly discussed the overview of Arduino and presented simple demonstrations of using Google ADK.</p>Visualizing CrazyFlie Flight Data
http://marctan.com/blog/2013/10/19/visualizing-crazyflie-flight-data/
Sat, 19 Oct 2013 00:00:00 +0000http://marctan.com/blog/2013/10/19/visualizing-crazyflie-flight-data/<p>In this post, we are going to explore one of the smallest quadcopters that are available in the market: CrazyFlie and how we can use node.js, d3.js, socket.io and html5 to visualize the flight data. CrazyFlie is a nano quadcopter from <!-- raw HTML omitted -->Bitcraze<!-- raw HTML omitted -->, a swedish company, whose goal is to provide an open-source hardware design and firmware for developing small quadcopters.</p>WallpaperManager and OutOfMemory
http://marctan.com/blog/2013/10/16/wallpapermanager-and-outofmemory/
Wed, 16 Oct 2013 00:00:00 +0000http://marctan.com/blog/2013/10/16/wallpapermanager-and-outofmemory/<!-- raw HTML omitted -->
<p>While working on an app that sets the wallpaper in Android, I’ve encountered this weird issue with the WallpaperManager API. Initially I thought this will be a very easy and straighforward task because the <!-- raw HTML omitted -->WallpaperManager API<!-- raw HTML omitted --> looks simple. You just have to get an instance and call setStream() or setBitmap() depending on the type of your source.</p>Social Network Analysis and Online Courses
http://marctan.com/blog/2013/10/09/social-network-analysis-and-online-courses/
Wed, 09 Oct 2013 00:00:00 +0000http://marctan.com/blog/2013/10/09/social-network-analysis-and-online-courses/<!-- raw HTML omitted -->
<p>So it’s my first week in the Social Network Analysis and my 4th week in Programming in Scala by Martin Odersky which are both available as online courses in coursera. I’ve tried enrolling to several online courses before but I never finish a single one because of several factors: being so lazy to work on assignments, day job, personal projects. So hopefully, I can finish at least one of them :)</p>The DigiX Development Board
http://marctan.com/blog/2013/06/25/the-digix-development-board/
Tue, 25 Jun 2013 00:00:00 +0000http://marctan.com/blog/2013/06/25/the-digix-development-board/<!-- raw HTML omitted -->
<p>It’s my first time to back a Kickstarter project and it felt really good to be part of a community that helps small/budding companies launch their products. I’ve seen so many awesome Kickstarter projects before but it always felt like they are too expensive for me or I don’t have any use for them.</p>New Blog Title, new UI and Investments
http://marctan.com/blog/2013/06/19/new-blog-title-new-ui-and-investments/
Wed, 19 Jun 2013 00:00:00 +0000http://marctan.com/blog/2013/06/19/new-blog-title-new-ui-and-investments/<!-- raw HTML omitted -->
<p>I’ve decided to change the blog title to something more ‘generic’ because I’m thinking of shifting the type of my posts to a mix of technical stuff and lighter topics such as personal stories and other non-technical stuff. I’ve also changed the color theme so something ‘light’ just to give it a new look.</p>Leap Motion and Android: A Match Made In Heaven
http://marctan.com/blog/2013/05/26/leap-motion-and-android-a-match-made-in-heaven/
Sun, 26 May 2013 00:00:00 +0000http://marctan.com/blog/2013/05/26/leap-motion-and-android-a-match-made-in-heaven/<!-- raw HTML omitted -->
<p><a href="http://leapmotion.com/">Leap Motion</a> is cool and so is Android so in this post, I’ll explain how to put them together to control a very simple fighter plane in 3D space. The example 3D application was taken from Rajawali’s example and you can take a look at its source code <a href="https://github.com/MasDennis/RajawaliExamples">here</a>.</p>Fix the missing R.java on ADT 22
http://marctan.com/blog/2013/05/23/fix-the-missing-r.java-on-adt-22/
Thu, 23 May 2013 00:00:00 +0000http://marctan.com/blog/2013/05/23/fix-the-missing-r.java-on-adt-22/Connecting Android to Arduino using Bluetooth
http://marctan.com/blog/2012/07/17/connecting-android-to-arduino-using-bluetooth/
Tue, 17 Jul 2012 00:00:00 +0000http://marctan.com/blog/2012/07/17/connecting-android-to-arduino-using-bluetooth/<!-- raw HTML omitted -->
<p>There are multiple ways of how you can connect an Android device to an Arduino board. You can use wifi module, a usb cable or a bluetooth module. In this post, we will try to explore the connection between the two devices using bluetooth.</p>Geocoding and Accessing Google Doc using Python Script
http://marctan.com/blog/2012/05/16/geocoding-and-accessing-google-doc-using-python-script/
Wed, 16 May 2012 00:00:00 +0000http://marctan.com/blog/2012/05/16/geocoding-and-accessing-google-doc-using-python-script/I have a list of around 1000+ churches that contains the name of the church, simple address, the residing priest and some contains mass schedules. I thought it will be nice if we can get the latitude and longitude based on the given address.
The way I do it before is to manually search the address in Google Maps and get the latitude/location by centering the marker and executing the javascript below:Heart Rate Monitor using Android and Arduino
http://marctan.com/blog/2012/05/02/heart-rate-monitor-using-android-and-arduino/
Wed, 02 May 2012 00:00:00 +0000http://marctan.com/blog/2012/05/02/heart-rate-monitor-using-android-and-arduino/<!-- raw HTML omitted -->
<p>Last week I decided to buy some stuff from local reseller of Arduino. I bought a <!-- raw HTML omitted -->Kyto Heart Sensor<!-- raw HTML omitted --> that transmits heart pulses to a receiver via radio frequency. The RF receiver can then be interfaced to an arduino and then pass the results to an Android device for visualization.</p>Fixing the ADK Library to work with Arduino 1.0
http://marctan.com/blog/2012/04/06/fixing-the-adk-library-to-work-with-arduino-1.0/
Fri, 06 Apr 2012 00:00:00 +0000http://marctan.com/blog/2012/04/06/fixing-the-adk-library-to-work-with-arduino-1.0/If you’ll try to create a sketch using the Android ADK library on the latest version of Arduino (1.0 as of this writing), you will get several errors just like this:
Damn it I accidentally deleted the images!
This is because they renamed some header files and also changed the signature of some commonly used functions.How to use a Tricolor LED and a Mini Buzzer
http://marctan.com/blog/2012/04/03/how-to-use-a-tricolor-led-and-a-mini-buzzer/
Tue, 03 Apr 2012 00:00:00 +0000http://marctan.com/blog/2012/04/03/how-to-use-a-tricolor-led-and-a-mini-buzzer/<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->Controlling a Micro-Servo
http://marctan.com/blog/2012/03/29/controlling-a-micro-servo/
Thu, 29 Mar 2012 00:00:00 +0000http://marctan.com/blog/2012/03/29/controlling-a-micro-servo/<!-- raw HTML omitted -->
<!-- raw HTML omitted -->Getting Started with Android and Arduino
http://marctan.com/blog/2012/03/26/getting-started-with-android-and-arduino/
Mon, 26 Mar 2012 00:00:00 +0000http://marctan.com/blog/2012/03/26/getting-started-with-android-and-arduino/Writing applications on Android is cool but writing applications on Android that can talk to the physical world is totally awesome. I recently bought a Seeduino ADK Board, which is actually a clone of an Arduino board that has support for the Android Accessory Development Kit. You can find more information about Seeduino here.Sensing Light Variations using LDR
http://marctan.com/blog/2012/03/26/sensing-light-variations-using-ldr/
Mon, 26 Mar 2012 00:00:00 +0000http://marctan.com/blog/2012/03/26/sensing-light-variations-using-ldr/<!-- raw HTML omitted -->
<!-- raw HTML omitted -->Pixel Playground using Renderscript Compute API
http://marctan.com/blog/2012/02/22/pixel-playground-using-renderscript-compute-api/
Wed, 22 Feb 2012 00:00:00 +0000http://marctan.com/blog/2012/02/22/pixel-playground-using-renderscript-compute-api/<!-- raw HTML omitted -->ListView Row Highlight
http://marctan.com/blog/2012/02/13/listview-row-highlight/
Mon, 13 Feb 2012 00:00:00 +0000http://marctan.com/blog/2012/02/13/listview-row-highlight/<!-- raw HTML omitted -->
<p>Basically the idea behind this post is to show unobtrusive way of informing the user that something has changed in the data. When using ListView in Android and the backing data has changed, most of the time, I just call <!-- raw HTML omitted -->notifyDatasetChanged() <!-- raw HTML omitted -->and voila, ListView will automatically refresh the UI for me. But I noticed that this isn’t particularly good for the user as most of the time he has no idea that something has changed.</p>Sharing Apps on Android via Bluetooth
http://marctan.com/blog/2012/02/12/sharing-apps-on-android-via-bluetooth/
Sun, 12 Feb 2012 00:00:00 +0000http://marctan.com/blog/2012/02/12/sharing-apps-on-android-via-bluetooth/<p>There are times when you just want to share a particular application on your phone to a friend and as developer, I encountered this problem several times when I want to let my friend try out an application on his/her phone.</p>Phone Phreaking/Hacking
http://marctan.com/blog/2011/12/15/phone-phreaking/hacking/
Thu, 15 Dec 2011 00:00:00 +0000http://marctan.com/blog/2011/12/15/phone-phreaking/hacking/I suddenly missed all the phone phreaking/hacking I’ve done back in 1999.
It all started when someone introduced me to this group of teens calling themselves as “Liners”, most of the them are from Marikina and Pasig area. Basically these “liners” originated from cross-line party, a “bug” in the analog PSTN where multiple people can hear everyone simultaneously.Eircom SSID
http://marctan.com/blog/2011/10/11/eircom-ssid/
Tue, 11 Oct 2011 00:00:00 +0000http://marctan.com/blog/2011/10/11/eircom-ssid/<!-- raw HTML omitted -->Alphabet for Android Developers
http://marctan.com/blog/2011/08/21/alphabet-for-android-developers/
Sun, 21 Aug 2011 00:00:00 +0000http://marctan.com/blog/2011/08/21/alphabet-for-android-developers/<!-- raw HTML omitted -->
<p><!-- raw HTML omitted --></p>
<p>I just noticed that there are equivalent short URLs for Google’s android-related sites. I hope you’ll find this useful.</p>Android Development using Maven
http://marctan.com/blog/2011/08/21/android-development-using-maven/
Sun, 21 Aug 2011 00:00:00 +0000http://marctan.com/blog/2011/08/21/android-development-using-maven/<!-- raw HTML omitted -->Converting Bitmap to Grayscale
http://marctan.com/blog/2011/08/21/converting-bitmap-to-grayscale/
Sun, 21 Aug 2011 00:00:00 +0000http://marctan.com/blog/2011/08/21/converting-bitmap-to-grayscale/<p>I’m just going to share this simple snippet to convert your colored bitmap to grayscale. I’ve used this before because my application needs to communicate to a server which will just extract the image features using SURF. It doesn’t really need the color information so we decided that we can remove the color information so save up few kbps and eventually speed up the transfer.</p>Custom SeekBar Preference
http://marctan.com/blog/2011/08/17/custom-seekbar-preference/
Wed, 17 Aug 2011 00:00:00 +0000http://marctan.com/blog/2011/08/17/custom-seekbar-preference/<!-- raw HTML omitted -->
<p>I just would like to share the code that I’ve posted in the Google Devs mailing list when someone asked about the SeekBar Preference. This allows you to popup a seekbar that you can use to adjust some properties like volume, difficulty and other things where a slider will be useful.</p>AppEngine Tricks
http://marctan.com/blog/2010/08/30/appengine-tricks/
Mon, 30 Aug 2010 00:00:00 +0000http://marctan.com/blog/2010/08/30/appengine-tricks/Life Stories for iPhone
http://marctan.com/blog/2010/08/27/life-stories-for-iphone/
Fri, 27 Aug 2010 00:00:00 +0000http://marctan.com/blog/2010/08/27/life-stories-for-iphone/I just started playing around with Objective-C for the Life Stories version in iOS 4.Then as usual, for newbies, I encountered a problem when displaying adView. Basically the problem is that when your view changed, like you hit the back button or change to another view, while your adview is still loading, the call to - (void)bannerViewDidLoadAd:(ADBannerView *)banner and - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error which ever is called will fail.Complete List of ADC 2 Top 200 entries
http://marctan.com/blog/2009/11/07/complete-list-of-adc-2-top-200-entries/
Sat, 07 Nov 2009 00:00:00 +0000http://marctan.com/blog/2009/11/07/complete-list-of-adc-2-top-200-entries/Handy Poll made it into ADC 2 Top 200
http://marctan.com/blog/2009/11/06/handy-poll-made-it-into-adc-2-top-200/
Fri, 06 Nov 2009 00:00:00 +0000http://marctan.com/blog/2009/11/06/handy-poll-made-it-into-adc-2-top-200/Here’s the actual email I got from Google:"Congratulations! Your application ‘Handy Poll ADC’ was selected by Android users as one of the top 20 in the Productivity category! We’re excited that you chose to participate in the ADC 2 and wish you luck in the final round as your application is evaluated by users and a panel of judges.Certification
http://marctan.com/blog/2009/06/24/certification/
Wed, 24 Jun 2009 00:00:00 +0000http://marctan.com/blog/2009/06/24/certification/Yey, I just received my certification kit today.Trying out different ROMs
http://marctan.com/blog/2009/06/02/trying-out-different-roms/
Tue, 02 Jun 2009 00:00:00 +0000http://marctan.com/blog/2009/06/02/trying-out-different-roms/Despite several attempts of reinstalling / applying optimization patch to the Rosie ROM, it is still so slow and unusable so I decided to give the Rogers ROM a try. By the way Rogers ROM is the one included in the HTC Dream and HTC Magic phones that’s going to be released in Canada.FML Widget updates
http://marctan.com/blog/2009/05/26/fml-widget-updates/
Tue, 26 May 2009 00:00:00 +0000http://marctan.com/blog/2009/05/26/fml-widget-updates/I just released an update for the FML widget:
Version 1.3
new icon (yes, finally I was able to create a shiny button, whew!) changed widget size to 2x2 enhanced UI widget now displays the whole FML fixed other issues The shiny, apple-inspired icon!
The widget now occupies 2x2 space in your desktop and displays the full FML though I need to make the font size smaller.FML Widget
http://marctan.com/blog/2009/05/10/fml-widget/
Sun, 10 May 2009 00:00:00 +0000http://marctan.com/blog/2009/05/10/fml-widget/Today, I released my first widget for Android called FML Widget. It displays the latest entries from FMyLifeand allows you to share it via SMS or email. You can also view other people’s comments on the FML entry. The widget updates every hour to minimize battery consumption. It is now available in the market so go and try it out.