原创 聯合體問題

Question Given the definitions below, which of the follow statements are correct?union{     union{        int a;   

原创 刪除鏈表中一個位於中間位置的節點

Problem Delete a node in the middle of list, given only access list once Solution #include <iostream> using namespace

原创 計算變位詞

Problem Calc if two strings are anagrams. For example: hello and elloh are anagrams helo and hello are not anagrams Sol

原创 計算計算機字節順序

Problem Write a function that determines whether a computer is big-endian or little-endian Solution #include <iostream

原创 計算二項式係數

Problem Design an efficient algorithm for computing c(n, k) that has the property that it never overflows if c(n, k) ca

原创 機器字節順序

Problem Determine the endianess of a computer Solution using System; using System.Runtime.InteropServices; namespace E

原创 將一個方陣旋轉90度

Problem Rotate a matrix by 90 degrees anti-clockwise Solution #include <iostream> using namespace std; int** create_

原创 八皇后問題

Problem Place eight queens on an 8×8 chessboard so that no two queens attack each other. Solution // EightQueens.cpp

原创 漢諾塔

Problem Only one disk may be moved at a time.Each move consists of taking the upper disk from one of the rods and slidi

原创 全排列

Problem Print all permutations of n distinct elements. Solution class Permutation { public static void main(String[

原创 計算一個數是不是2的冪

Problem Given a number, determine whether it is a power of 2 Solution bool is_power_2(int n) { return ((n & (n-1))

原创 計算整數的奇偶性

Problem Compute the parity of a long integer. Solution - Erases the least significant bit of a number e.g 1111 -> 1111

原创 計算整數方根

Problem Implement a fast integer square root function that takes in a 32-bit unsigned integer and returns another 32-bi

原创 面試 改錯題-1

Problem Find as many issues as possible and correct them: malloc(n) allocates n bytes in the heap. int main(void) {

原创 使用1-5隨機數生成器產生1-7的隨機數(Google Technical Interview)

Problem Generate random between 1..7(Google Technical Interview).Write a method to generate a random number between 1 a