Category: C++

Leetcode Roasting of the Day: Replace Words

Let’s roast! Today’s Leetcode challenge is: 648. Replace Words Given a list of dictionary words, replace all words in the given sentence that has the prefix of the word match to the dictionary word, into that prefix. So, if we have a dictionary word “cat” and a sentence “the cattle”, we replace “cattle” into “cat” since “cat” is a prefix of “cattle”, hence producing the resulting sentence “the cat”. It...

Another Roasting the Leetcode of the Day: Hand of Straights

Today’s Leetcode is: 846. Hand of Straights (https://leetcode.com/problems/hand-of-straights/) The general idea is extremely simple: given a list of numbers, divide the numbers equally into multiple lists with k size, where each elements are consecutive numbers. For example: List [1,2,3,6,2,3,4,7,8], divided into list of 3 elements will be: [1,2,3],[2,3,4],[6,7,8]. Make a function to check IF we can make such list or not. I am checking the provided solution by Leetcode, and...

Code Roasting the Leetcode Submission

Let’s do some code-roasting, shall we? 😛 Today’s Leetcode challenge is straightforward: “Longest Palindrome.” The problem statement is simple: given a string consisting of lowercase and uppercase characters, return the longest palindrome length that can be built with the supplied letters. This is a simple counting problem that can be solved by counting the appearance of the characters in the string. If a character appears as many as even times,...

Inspiring Chats with Bjarne Stroustrup

I was invited for students dinner at Cppcon. Technically speaking I am currently a student, so despite I’m older than many other students, I can join them for free pizza 😛 But my luck was not about the pizza. I got my chance to meet and talk with Bjarne Stroustrup, the father of C++ language! It was all began when all students joining the dinner had to meet up in...

Lesson learned: Do Not Store rvalue Reference Outlive its Declaration

I am building a custom operator overloading structures in C++, and was really seduced with what rvalue promises: the lifetime of rvalue reference is bound to the expression of its context. Rvalue references can be used to extend the lifetimes of temporary objects (cppreference.com) I was building a combination of operators which accepts a lot of literals and temporary objects including lambda. So for instance: auto res = ObjectA() *...

Tizen Studio on Other Than Ubuntu

It’s pain in the ass. Really. If you can stick to Ubuntu or its derivatives, please do that. I kinda hate how Tizen Studio is developed to only support Ubuntu out-of-the-box. A software should not dictate what Linux distro it should be installed on. Distro is just like a religion for some people, and some people are like me, who doesn’t like Ubuntu and its bloatware. Personally I use OpenSUSE...

Weird std::thread bug on GCC 4.9 on ARM target

I have been dealing with Tizen development since about last year, and since then I have been learning of utilizing C++11 features on my codes. Currently I am developing a some kind of component to help performing message pump in threading, so you can dispatch a function to a queue to be performed in separate thread. It is a simple components actually. You can take a look at GitHub. DispatchQueue...