Interview Practice 25 - Longest Consecutive Digits

Question Given a function prototype: int continumax(char *output_string,char *input_string). Implement it to find the longest consecutive digits. This function must return the length of the longest digits. The found longest digits should be written to the memory location that output_string is pointing. For example, if…

Interview Practice 02 - Stack with Minimum Function

Question Define a stack structure with “min” function — a function to get the minimum value within the stack. The time complexity of min, push and pop functions must be O(1). Solution 結合鍊錶一起做。首先我做插入以下數字: 10, 7, 3, 3, 8, 5, 2, 6 0: 10 -> NULL (MIN=10, POS=…

How to rotate gizmos to fit a game object in Unity

While you are making a cube in unity which is transparent in gameplay, you would probably want to make it visible only in editor mode with gizmos. However, gizmos doesn’t rotate with the object transform. So you can use the following tricks to rotate the gizmos to fit your…

Animated sprites in Cocos2D

I have been working with Cocos2D for a while and I am still a newbie. The way to deal with animations in Cocos2D 1.0.0 – the stable version currently – is different from the way before using CCSpriteSheet. Now Cocos2D adapts animations as cache shared in the project using CCSpriteFrameCache.…