- 博客(9)
- 资源 (10)
- 收藏
- 关注
原创 lintcode:Update Bits
Given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e g , M becomes a substring of N located at i and starting at j)
2016-01-31 23:21:53 1106
原创 lintcode:Trailing Zeros
15:00 Start Write an algorithm which computes the number of trailing zeros in n factorial. Example 11! = 39916800, so the out should be 2 Challenge O(log N) time阶乘末尾一个零表示一个进位,则相当于乘以10 而
2016-01-30 23:09:57 1068
原创 lintcode: Unique Paths
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach
2016-01-30 22:56:51 465
原创 lintcode: O(1) Check Power of 2
Using O(1) time to check whether an integer n is a power of 2. Example For n=4, return true; For n=5, return false; Challenge O(1) time思路:如果n是2的幂,则n的二进制表示中只有一个1. 用n&(n-1),如果结果是0则表示只有一个1.
2016-01-27 22:04:22 785
原创 lintcode: Flip Bits
Determine the number of bits required to flip if you want to convert integer n to integer m. Example Given n = 31 (11111), m = 14 (01110), return 2. Note Both n and m are 32-bit integers.
2016-01-26 23:03:17 901
原创 lintcode:Wood Cut
Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the same length. What is the longest length you ca
2016-01-26 16:21:28 1284
原创 lintcode:Search for a Range
Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1, -1]. Example Given [5, 7, 7, 8, 8
2016-01-26 13:58:07 460
原创 二分查找上界和下界
详细见详细见《算法竞赛入门》P229这里用的是左闭右开空间[left , right)upper_bound返回的是target应该插入的位置或者最后一次出现位置的下一个位置这里的实现就跟STL中的这两个函数功能类似STL源码学习—-lower_bound和upper_bound算法#include<vector>#include<iostream>using namespace st
2016-01-26 13:49:04 2075
原创 Search in 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).You are given a target value to search. If found in the array return its index
2016-01-07 22:57:42 400
Win7平台VS2010安装Visual Assist X
2015-03-20
合工大操作系统课程设计:基于内存的文件系统
2013-07-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人