LeetCode – K Empty Slots (Java)

Given a garden with N slots. In each slot, there is a flower. Each of the N flowers will bloom one by one in N days. In each day, there will be exactly one flower blooming and it will stay blooming since then. Given an array of numbers from 1 to N. Each number in … Read more

LeetCode – My Calendar II (Java)

Implement a MyCalendarTwo class to store your events. A new event can be added if adding the event will not cause a triple booking. Your class will have one method, book(int start, int end). Formally, this represents a booking on the half open interval [start, end), the range of real numbers x such that start

Swing vs. SWT – Side-by-side comparison

In many articles, developers have compared Swing with SWT with a lot of details. However, there is not a side-by-side comparison by using a diagram which may give a direct impression of how they are different. In this post, I will compare Swing and SWT side by side and get a taste of the difference … Read more

LeetCode – Next Closest Time (Java)

Given a time represented in the format “HH:MM”, form the next closest time by reusing the current digits. There is no limit on how many times a digit can be reused. You may assume the given input string is always valid. For example, “01:34”, “12:09” are all valid. “1:34”, “12:9” are all invalid. Example 1: … Read more

Java vs. Python (1): Simple Code Examples

Some developers have claimed that Python is more productive than Java. It is dangerous to make such a claim, because it may take several days to prove that thoroughly. From a high level view, Java is statically typed, which means all variable names have to be explicitly declared. In contrast, Python is dynamically typed, which … Read more

Error message during installation of PyDev for Eclipse

Eclipse version: Indigo Platform: Ubuntu 11.10 Error message: An error occurred while collecting items to be installed session context was:(profile=epp.package.java, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=). No repository found containing: osgi.bundle,javax.mail.glassfish,1.4.1.v201005082020 This is possibly caused by in compatible eclipse version. If we use Help -> Eclipse MarketPlace to install PyDev, the problem is gone.

Why do we need Generic Types in Java?

Generic types are extensively used in Java collections. Why do we need Generic types in Java? Understanding this question can help us better understand a lot of related concepts. In this article, I will use a very short example to illustrate why Generic is useful. 1. Overview of Generics The goal of implementing Generics is … Read more

Python “Hello World” web application in Ubuntu

This post shows how to setup a python web development environment under Ubuntu and make a hello world example. So Python has become a hot word in recent years. But before you can do anything about it, you need a “hello world” sample application. In this post, I will build a hello world Python web … Read more

Github: add local directory/files to remote repository of Github

Github is a more popular and social code repository. It is the trend to be a user, at least it is true for now. There are a lot of problems we may meet, most of them can be solved by reading the documentation. But that is not fast or something we like to do. Problem … Read more