插入排序(Insertion Sort)是一种简单直观的排序算法。它的工作原理是通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应位置并插入。插入排序在实现上,通常采用in-place排序(即只需用到O(1)的额外空间的排序),因而在从后向前扫描过程中,需要反复把已排序元素逐步向...
分类:
编程语言 时间:
2015-01-26 14:59:48
阅读次数:
186
// Playground - noun: a place where people can playimport UIKitvar str = "Hello, playground"//------------------------- 类和结构体的相同与不同 ------------------...
分类:
编程语言 时间:
2015-01-26 01:18:10
阅读次数:
291
// Playground - noun: a place where people can playimport UIKitvar str = "Hello, playground"print("A"); print("A") // 如果同一行有有段代码用 ';'隔开// 默认自带换行符print...
分类:
编程语言 时间:
2015-01-26 01:11:52
阅读次数:
197
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat...
分类:
其他好文 时间:
2015-01-25 22:33:24
阅读次数:
150
题目:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?...
分类:
编程语言 时间:
2015-01-24 21:12:54
阅读次数:
192
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2015-01-23 21:17:22
阅读次数:
252
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:
其他好文 时间:
2015-01-22 19:42:54
阅读次数:
112
随笔一记,留做重温!Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 ...
分类:
其他好文 时间:
2015-01-22 19:38:34
阅读次数:
219
题目链接:https://oj.leetcode.com/problems/set-matrix-zeroes/
题目内容:
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
click to show follow up.
Follow u...
分类:
其他好文 时间:
2015-01-22 09:32:37
阅读次数:
193
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?可以找规律 得出映射关系,(i,j)=...
分类:
其他好文 时间:
2015-01-21 23:52:48
阅读次数:
133