上一页 1 2 3 4 5 6 7 8 9 10 ··· 28 下一页
摘要: Source Write a function that add two numbers A and B. You should not use + or any arithmetic operators. Example Given a=1 and b=2 return 3 Note There 阅读全文
posted @ 2021-06-06 16:14 凌雨尘 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 前言 C语言中,结构体内存对齐问题算是比较常见的问题,虽然理解起来不难,但很多时候一不小心就会算错。比如给你一个 struct,让你 sizeof 计算一下需要占用多少字节,往往得到的结果比等于 struct 里面数据成员所占用的字节之和。 例: #include <stdio.h> struct 阅读全文
posted @ 2021-05-23 11:38 凌雨尘 阅读(261) 评论(0) 推荐(0) 编辑
摘要: Source Find the Nth number in Fibonacci sequence. A Fibonacci sequence is defined as follow: The first two numbers are 0 and 1. The i th number is the 阅读全文
posted @ 2021-05-09 12:09 凌雨尘 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Source Count how many 1 in binary representation of a 32-bit integer. Example Given 32, return 1 Given 5, return 2 Given 1023, return 9 Challenge If t 阅读全文
posted @ 2021-04-11 12:10 凌雨尘 阅读(52) 评论(0) 推荐(0) 编辑
摘要: Source In data structure Hash, hash function is used to convert a string(or any other type) into an integer smaller than hash size and bigger or equal 阅读全文
posted @ 2021-04-05 20:37 凌雨尘 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Source 计算 a^n % b,其中a,b和n都是32位的非负整数 题解 数学题,考察整数求模的一些特性,不知道这个特性的话此题一时半会解不出来,本题中利用的关键特性为: (a * b) % p = ((a % p) * (b % p)) % p 即 a 与 b 的乘积模 p 的值等于 a, b 阅读全文
posted @ 2021-03-28 12:50 凌雨尘 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Source 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 beco 阅读全文
posted @ 2021-03-07 13:05 凌雨尘 阅读(103) 评论(0) 推荐(0) 编辑
摘要: Source Given n, how many structurally unique BSTs (binary search trees) that store values 1...n? Example Given n = 3, there are a total of 5 unique BS 阅读全文
posted @ 2021-02-28 14:23 凌雨尘 阅读(77) 评论(0) 推荐(0) 编辑
摘要: Source 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 阅读全文
posted @ 2021-02-17 13:58 凌雨尘 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Source Determine the number of bits required to convert integer A to integer B Example Given n = 31, m = 14,return 2 (31)10=(11111)2 (14)10=(01110)2 题 阅读全文
posted @ 2021-01-31 13:10 凌雨尘 阅读(103) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 28 下一页