2013年10月15日

Reverse Nodes in k-Group

摘要: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文

posted @ 2013-10-15 14:02 Step-BY-Step 阅读(189) 评论(0) 推荐(0) 编辑

Remove Duplicates from Sorted Array

摘要: Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given input array A =[1,1,2],Your function should return length =2, and A is 阅读全文

posted @ 2013-10-15 14:01 Step-BY-Step 阅读(127) 评论(0) 推荐(0) 编辑

Remove Element

摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length. 1 public class Solution { 2 public int removeElement(int[] A, int elem) { 3 // Note: The Solutio... 阅读全文

posted @ 2013-10-15 13:38 Step-BY-Step 阅读(108) 评论(0) 推荐(0) 编辑

Implement strStr()

摘要: Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.如果当前不是子串则回溯。时间复杂度是O(mn)。 1 public class Solut... 阅读全文

posted @ 2013-10-15 12:59 Step-BY-Step 阅读(410) 评论(0) 推荐(0) 编辑

Divide Two Integers

摘要: Divide two integers without using multiplication, division and mod operator.如果可以用乘的话,二分搜索倒是不错的解法。否则,只能寄希望于位符操作了。基本思想就是把除数向左移位(×2)然后与被除数比较,直到发现仅次于被除数的那... 阅读全文

posted @ 2013-10-15 07:15 Step-BY-Step 阅读(747) 评论(0) 推荐(0) 编辑

导航