[LeetCode] Gas Station (Java)

There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. Return the starting gas station’s index … Read more

[LeetCode] Sort Colors (Java)

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Follow up: A rather straight forward … Read more

[LeetCode] Longest Valid Parentheses

Got stuck in this problem for one hour. I was trying to use a variable left to count the left parentheses. However, we should not only count the number of them, but also the position of them. Then we need to use stack. There is a very elegant solution here (In Java): http://rleetcode.blogspot.com/2014/01/longest-valid-parentheses.html This problem really cost … Read more

Java Problem: java.lang.NoSuchMethodError

I was doing a project to implement TCP over UDP. I used makefile to compile these java files easily. After editing and compiling several times, the Server became unavailable in terminal. It shows just like below.

However, it works well in Eclipse. I tried it in ubuntu and it also works. I have no … Read more

Hello world!

When I want to learn a programming language, most tutorials and books often let me start with “Hello world” programs.

So I start this blog with “Hello world”, which is also a new start of graduate student life.