自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

u010570643的专栏

程序员技术面试(Technical Interview)

  • 博客(39)
  • 收藏
  • 关注

原创 Compute the maximum of two integers without if-else

using System;namespace JamesChen{    class Program    {        static int MaximumWithoutIf(int a, int b)        {            int m = a - b;            m = a + (a - b) * ((a - b

2013-07-04 11:46:08 428

原创 Compute how many bits to require convert one integer to another

ProblemWrite a function to determine the number of bits required to convert integer A to integer B.Input: 31, 14Output: 2Solution/*=========================================

2013-07-04 11:32:19 547

原创 Print the numbers of form 2^i.5^j in increasing order -- Google

ProblemPrint the numbers of form 2^i.5^j in increasing order. For eg: 1, 2, 4, 5, 8, 10, 16, 20Solution/* ==================================================================

2013-07-04 11:30:27 526

原创 Print an array in spiral order -- Microsoft

ProblemGiven an mxn matrix, design a function that will print out the contents of the matrix in spiral format. Spiral format means for a 5x5 matrix given below:[ 1 2 3 4 5 ][ 6 7

2013-07-04 10:56:44 517

转载 Swap kth element from the beginning and kth element from the end of linked list -- Amazon

转载自:https://sites.google.com/site/spaceofjameschen/homeProblemSwap kth element from the beginning and kth element from the end of linked list.Solution/* ===========================

2013-06-22 13:04:56 634

原创 Find the maximum contiguous subsequence product -- InMobi

ProblemSuppose you have an array of +ve numbers, -ve numbers and zeroes. Devise an algorithm to find the maximum contiguous subsequence product. For 7 -3 -1 2 -40 0 3 6, the max subsequence prod

2013-06-19 12:55:40 705

原创 Find pairs equal zero -- Paypal

ProblemGiven 2 equal-length arrays of integers, find pairs, one from each array, that sum to 0. -- note that one wrinkle of this problem over the more usual form, which is to do this in a si

2013-06-19 12:53:28 565

原创 Detect whether two rectangles have common area or not -- Amazon

ProblemWrite a function to check if two rectangles defined as below, have common area or not. The functions take the top left and bottom right coordinate as input and return 1 if the

2013-06-19 12:50:38 703

原创 查找数组中的缺失的2个数字

ProblemTwo numbers are missing from the first hundred numbers. They are NOT sorted. How to find them? You can't sort.. and can't iterate one by one.. has to be less than O(N)? Can't use stack , se

2013-06-03 08:46:29 2139

原创 数组排序,无须二次扫描

ProblemGiven an array containing (0..n-1) but in random order, you can only loop through the array once and use swap operation, please sort the array.Solutionimport randomdef sort_array_wi

2013-05-28 06:40:38 457

原创 内存分配中的对齐操作

ProblemMemory operation with alignmentSolution#include using namespace std;int aligned_malloc(void **memptr, size_t alignment, size_t size){    size_t len = size + al

2013-05-27 05:32:42 782

原创 输出集合中所有数据项组合

ProblemPrint all combination of a specified list items.Solutionpublic class Combination{ public static void main(String[] arguments){ int[] list = {1, 2, 3, 4}; int[] prece

2013-05-24 06:24:18 1491

原创 将矩阵中含零的行和列置零

ProblemIf an element in an MxN matrix is 0, set its entire row and column to 0Solutionpublic class ZeroRowAndCol{ public static void main(String...strings){ int[][] matrix = new int[

2013-05-23 19:47:47 936

原创 转置整数方阵

ProblemTranspose an integer arraySolution#include using namespace std;int** create_matrix(int row, int col){ int **m = new int* [row]; for(int i = 0; i < row; i++){ m[i] =

2013-05-22 06:09:09 893 1

原创 计算两个字符串链表中的共同数据项,需要考虑重复选项的情况

Problem/*// Given two lists of strings build a new list that has all strings that appear in both the original lists. If the same string appears more than once output it as many times as it appea

2013-05-22 06:03:55 823 2

原创 计算N阶乘中结尾有多少零

ProblemWrite an algorithm which computes the number of trailing zeros in n factorial.Solution#include using namespace std;int main(int argc, char* argv[]){ int n = 100; int m =

2013-05-17 09:34:41 817

原创 找出数列中不存在的数据项

ProblemFind the missing number from the list of 99 distinct numbers which are from 1-100SolutionCompute sum of the list. Compute desirable sum without missing number.The missing number is

2013-05-16 13:08:40 918

原创 字符串中的字符是否都是唯一的,未重复的

ProblemDetermine if a string has all unique characters.Solutionpublic class UniqueCharInString{ public static void main(String[] arguments){ String[] testCases= {"hello", "wolrd",

2013-05-16 10:37:08 714

原创 删除链表中重复项

ProblemRemove duplicates in a listSolutionSort the list.Loop through the list. If the elements is not equal to last elements, that means a new elementusing System;using System.Colle

2013-05-16 09:05:07 825

原创 面试 改错题-2

ProblemFind as many issues as possible and correct them:char *GenerateRandomString(void){ int i; char RandomString[10]; for(i = 0; i <= 10; i++) { RandomString[i] = ra

2013-05-15 12:17:11 1089 1

原创 面试 改错题-1

ProblemFind as many issues as possible and correct them:malloc(n) allocates n bytes in the heap.int main(void){ int *ptr = (int *) malloc(10); for(int i =0; i <10; i++) {

2013-05-15 11:29:39 1052 1

原创 翻转字符串

ProblemCheck if a string is a rotation of another. For example:Hello and loHel are a rotation pair.Tony and Julia are not a rotation pair. Solutionpublic class RotationOfString{ public

2013-05-15 09:17:25 637

原创 如何使用堆栈实现队列

ProblemHow to use two stacks to implement a queueSolutionIt is simple, just serialize two stacks #include #include using namespace std;stack s1;stack s2;bool que_add(int value){

2013-05-15 08:32:07 837 1

原创 使用1-5随机数生成器产生1-7的随机数(Google Technical Interview)

ProblemGenerate random between 1..7(Google Technical Interview).Write a method to generate a random number between 1 and 7, given a method that generates a random number between 1 and 5 (i. e. , imp

2013-05-15 08:20:44 1528 1

原创 机器字节顺序

ProblemDetermine the endianess of a computerSolutionusing System;using System.Runtime.InteropServices;namespace Endianess{ [StructLayout(LayoutKind.Explicit)] struct Union {

2013-05-14 20:14:51 739 1

原创 计算整数方根

ProblemImplement a fast integer square root function that takes in a 32-bit unsigned integer and returns another 32-bit unsigned integer that is the floor of the square root of the input.Solutio

2013-05-14 17:27:01 588

原创 计算变位词

ProblemCalc if two strings are anagrams. For example:hello and elloh are anagramshelo and hello are not anagramsSolution1. Sort the elements in the lists2. Compare if two lists are

2013-05-14 17:16:35 569

原创 全排列

ProblemPrint all permutations of n distinct elements.Solutionclass Permutation { public static void main(String[] argument) { int[] list = { 1, 2, 3, 4 }; Permutation.Perm(

2013-05-14 17:03:22 495

原创 全排列

ProblemPrint all permutations of n distinct elements.Solution// Permutaion.cpp : Defines the entry point for the console application.//#include #include #include using namespace std;v

2013-05-14 16:58:12 495 1

原创 删除链表中一个位于中间位置的节点

ProblemDelete a node in the middle of list, given only access list onceSolution#include using namespace std;typedef struct linked_list{ int data; struct linked_list *next;}Linked_

2013-05-14 13:51:20 685 3

原创 联合体问题

QuestionGiven the definitions below, which of the follow statements are correct?union{    union{        int a;        int b;        int c;    }abc, xyz;}first, second;A. &sec

2013-05-14 13:43:10 747 1

原创 汉诺塔

ProblemOnly one disk may be moved at a time.Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present

2013-05-14 13:37:19 481

原创 将一个方阵旋转90度

ProblemRotate a matrix by 90 degrees anti-clockwiseSolution#include using namespace std;int** create_matrix(int row, int col){ int **m = new int* [row]; for(int i = 0; i < row;

2013-05-14 13:30:27 712

原创 计算二项式系数

ProblemDesign an efficient algorithm for computing c(n, k) that has the property that it never overflows if c(n, k) can be represented as an integer assume n and k are both integers.Solution

2013-05-14 13:19:41 1052

原创 计算一个数是不是2的幂

ProblemGiven a number, determine whether it is a power of 2Solutionbool is_power_2(int n){ return ((n & (n-1)) == 0)? true : false;}int main(int argc, char *argv[]){ for(int i = 0

2013-05-14 13:12:15 534

原创 计算计算机字节顺序

ProblemWrite a function that determines whether a computer is big-endian or little-endianSolution#include using namespace std;int is_little_endian(){ int num = 0x1; char *p = (c

2013-05-14 12:53:09 690

原创 计算整数的奇偶性

ProblemCompute the parity of a long integer.Solution- Erases the least significant bit of a numbere.g 1111 -> 1111 & 1110 = 1110      1110 -> 1110 & 1101 = 1100      1101 -> 1101 &

2013-05-14 12:38:22 658

原创 寻找字典中变位词

问题Given a dictionary of English words, return the set of all words grouped into subsets of words that all anagrams of each other.方案// FindAnagrams.cpp : Defines the entry point for the conso

2013-05-14 12:17:06 573

原创 八皇后问题

ProblemPlace eight queens on an 8×8 chessboard so that no two queens attack each other.Solution// EightQueens.cpp : Defines the entry point for the console application.//#include #include

2013-05-14 11:31:04 491

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除