2014年10月9日

Searching an Element in a Rotated Sorted Array

摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). How do you find an elemen... 阅读全文

posted @ 2014-10-09 06:25 brave_bo 阅读(267) 评论(0) 推荐(0)

Rotating an array in place

摘要: April 13, 2010inUncategorizedRotate a one-dimensional array of n elements to the right by k steps.For instance, with n=7 and k=3, the array {a, b, c, ... 阅读全文

posted @ 2014-10-09 05:53 brave_bo 阅读(198) 评论(0) 推荐(0)

Print matrix spiral

摘要: ProblemPrint a matrix in spiral fashion.SolutionWe will first print the periphery of the matrix by the help of 4 for loops. Then recursively call this... 阅读全文

posted @ 2014-10-09 05:00 brave_bo 阅读(296) 评论(0) 推荐(0)

Finding intersection of two sorted arrays

摘要: Find the intersection of two sorted arrays.Let’s called array1 as A and array2 as B, each with size m and n.The obvious brute-force solution is to sca... 阅读全文

posted @ 2014-10-09 03:12 brave_bo 阅读(209) 评论(0) 推荐(0)

导航