摘要: There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you 阅读全文
posted @ 2013-10-08 23:33 懒猫欣 阅读(362) 评论(0) 推荐(0)
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did you consider the case where path = "/../"?In this case, you should r 阅读全文
posted @ 2013-10-08 20:56 懒猫欣 阅读(187) 评论(0) 推荐(0)
摘要: Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:boo 阅读全文
posted @ 2013-10-08 20:28 懒猫欣 阅读(336) 评论(0) 推荐(0)
摘要: Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region . For example,X X X XX O O XX X O XX O X XAfter running your function, the board should be:X X X XX X X 阅读全文
posted @ 2013-10-08 15:08 懒猫欣 阅读(194) 评论(0) 推荐(0)
摘要: '.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The function prototype should be:bool isMatch(const char *s, const char *p)Some examples:isMatch("aa","a") → falseisM 阅读全文
posted @ 2013-10-08 14:19 懒猫欣 阅读(204) 评论(0) 推荐(0)
摘要: Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut.首 阅读全文
posted @ 2013-10-08 00:32 懒猫欣 阅读(181) 评论(0) 推荐(0)