Cracking CI
文章平均质量分 73
YMHH
Enjoy the coding, enjoy the life together
展开
-
CCI: Find in Matrix
Given a matrix in which each row and each column is sorted, write a method to find an element in it.第一反应是取矩阵中间元素折半,可以去掉1/4的区域,不过这样一来剩下的就是两个矩阵了。虽然也可以解决问题,有些复杂。简单一些,O(m+n)的方案吧。注意二维数组做参数的用法,折腾了好几次,有时原创 2014-01-23 00:17:03 · 961 阅读 · 0 评论 -
CCI: Representing N cents
Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n cents.简单的DFS可以解决,书中的理解起来感觉有些复杂原创 2014-01-26 23:37:07 · 853 阅读 · 0 评论 -
CCI: my2DAlloc
Write a function called my2DAlloc which allocates a two dimensional array. Minimize the number of calls to malloc and make sure that the memory is accessible by the notation arr[i][j].可以把malloc返回的地址原创 2014-01-27 19:35:04 · 741 阅读 · 0 评论 -
CCI: Sort a stack
Write a program to sort a stack in ascending order. You should not make any assumptions about how the stack is implemented. The following are the only functions that should be used to write this progr原创 2014-01-18 21:20:02 · 896 阅读 · 0 评论 -
CCI: Count negative numbers in matrix
Given a matrix in which each row and each column is sorted, write a method to find the number of negative element in it.原创 2014-04-15 23:45:10 · 729 阅读 · 0 评论 -
CCI: Find maximum subsquare
Imagine you have a square matrix, where each cell is filled with either black or white. Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels.原创 2014-04-26 22:23:18 · 934 阅读 · 0 评论 -
Leetcode: Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers原创 2015-08-12 22:42:47 · 411 阅读 · 0 评论