摘要: Q:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return 0.Note:A word is defined as a character sequence consists of non-space characters only.For example,Givens="Hello Wo 阅读全文
posted @ 2013-06-16 17:37 summer_zhou 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Q:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.For example,Givenboard=[ [ 阅读全文
posted @ 2013-06-16 17:01 summer_zhou 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Q:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.A: 要注意k=0,k>=n等这些特殊情况。为了防止k>>n的情况,先计算链表的长度n,然后对k取余数 ListNode *rotateRight(ListNode *head, int k) { // Start typing 阅读全文
posted @ 2013-06-16 14:40 summer_zhou 阅读(114) 评论(0) 推荐(0) 编辑