原创 leetcode:Merge Sorted Array

Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough

原创 數組中只出現一次的數字升級版

/* 題目出處:《劍指offer——名企面試官精講典型題目》P211 題目:一個整型數組除了兩個數字之外,其它的數字都出現了兩次。請寫程序找出這兩個只出現一個的數字。要求時間複雜度是O(n),空間複雜度是O(1); */ /* 解題思路,

原创 和爲S的兩個數字 and 和爲s的連續正整數序列

/* 環境 winxp ,vc++6.0 題目:和爲S的兩個數字 and 和爲s的連續正整數序列 */ /* 題目出處:《劍指off——名企面試官精講典型編程題》P214 */ /* 題目1:輸入一個遞增排序的數組和一個數字 S ,在數組

原创 leetcode:Valid Palindrome 合法迴文

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For ex

原创 leetcode:Triangle 三角形

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row

原创 Leetcode:Reverse Integer ,整數反轉

想開始嘗試刷一下leetcode,挑了一題最簡單的開始,也算是給自己的刷題之路一個開門紅吧。 Reverse digits of an integer. Example1: x = 123, return 321Example2: 

原创 leetcode:Pow(x, n)

Implement pow(x, n). 沒有考慮INT_MIN 和 INT_MAX導致錯了兩次 貼上挫挫的代碼 class Solution { public: double pow(double x, int n) { i

原创 leetcode:Remove Duplicates from Sorted Array去掉排序數組中重複的元素

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new lengt

原创 leetcode:sort colors排序顏色

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, wi

原创 操作系統——文件管理,基於塊的索引分配和位表

/* 給出一個磁盤塊序列:1、2、3、……、500,初始狀態所有塊爲空的,每塊的大小爲2k。 選擇使用位表、鏈式空閒區、索引和空閒塊列表四種算法之一來管理空閒塊。 對於基於塊的索引分配執行以下步驟: 隨機生成2k-10k的文

原创 leetcode:Rotate Array旋轉數組

Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] i

原创 leetcode:Single Number單個數字

Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm s

原创 leetcode:Remove Element刪除元素

Given an array and a value, remove all instances of that value in place and return the new length. The order of eleme

原创 leetcode:Palindrome Number 迴文整數

Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Coul

原创 leetcode:ZigZag Conversion鋸行轉換

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to disp