starrotation

Interview Practice 26 – String Right-rotation

Question Write a program to right-rotate a string by m characters. Right-rotating a string means moving m characters at the left of string to the right. Is it required the time complexity is O(n) and helper memory size is O(1). For example, right-rotate “abcdefghi” by 3 characters gives “defghiabc”. Solution There are 2 ways to…

1924_KY_Consecutive_plates

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 input_string is “abcd12345ed125ss123456789”, function returns 9 and output_string becomes “123456789”. Solution This…

InstaMusic Version 1.0.1

Version 1.0.1 Changelog Fixed music pausing bug Fixed bug to open now playing with no song Fixed bug such that music should stop after playing the last song Fixed minor bug that now playing screen will be opened when notification is clicked Fixed bug that the app crashed when back is pressed during song playing

Convert character encoding in PHP

Usually while we extract information from other websites, character encoding might not correct. For example, j-jis.com is encoded with Shift-JIS. Therefore if your MySQL charset is UTF-8, it causes incorrect information. To handle the changing of character encoding, we can use iconv in PHP. [sourcecode language=”php”] $url = "http://j-jis.com/"; $html = file_get_contents($url); $html = preg_replace("/rn|n|t/",…

Handle unwanted character changes in Json for unicodes encoding in PHP

Json has been an efficient way to handle information and message exchanges in web programming. For example, I usually use PHP to connect MySQL and retrieve information, then display as Json. So a webpage can “AJAX” the displayed Json to create a dynamic view on itself. However, while the information involves unicode characters, PHP turn…

Mail Checker: Nicholas Workshop

Mail Checker: Nicholas Workshop Thank you if you are using my extension. I am happy that so many people like my program. This is one of the most satisfying program I ever made. And also thank you those people on the internet who help me debug and give me suggestions. I like coding and I am also…