码迷,mamicode.com
首页 >  
搜索关键字:in-place    ( 1961个结果
leetcode || 48、Rotate Image
problem: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? Hide Tags  Array 题意:将一个矩阵顺时针旋...
分类:其他好文   时间:2015-03-30 18:51:18    阅读次数:86
LeetCode 27 Remove Element
题目描述: 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 matter what you leave beyond the new len...
分类:其他好文   时间:2015-03-30 16:28:15    阅读次数:157
Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:其他好文   时间:2015-03-30 10:52:04    阅读次数:106
Java 传参数时,传值和传引用的区别
转载请注明出处,原文地址:  中北大学 郑海鹏 最近在复习那九大排序算法时,意外的发现用冒泡排序、插入排序、选择排序等in-place sort时,sort(a);再把a输出,就是已经排好序的新数组了。 但是用归并排序等out-place sort时,sort(a); 之后,输出的还是原来的数组! 为什么呢?请看代码和里面的注释: package zhp.outplace...
分类:编程语言   时间:2015-03-30 09:27:23    阅读次数:195
151. Reverse Words in a String Leetcode Python
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". Update (2015-02-12): For C programmers: Try to solve it in-place in...
分类:编程语言   时间:2015-03-30 09:24:11    阅读次数:168
Flatten Binary Tree to Linked List
Flatten Binary Tree to Linked List问题:Given a binary tree, flatten it to a linked list in-place.思路: 前序pre-order遍历+prenode我的代码:public class Solution { ....
分类:其他好文   时间:2015-03-29 12:05:49    阅读次数:104
Leetcode解题-链表(2.2.2)ReverseLinkedList
题目:2.2.2 Reverse Linked List IIReverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->nullptr, m = 2 and n = 4,return 1->4->3->2->5->nullptr.Note: ...
分类:其他好文   时间:2015-03-28 11:33:15    阅读次数:154
一些Python知识点
0. 新与旧两种reverse>>> L = [1,2,3,4]>>> R = L[::-1] # new object>>> R[4, 3, 2, 1]>>> L.reverse() # in place>>> L[4, 3, 2, 1]>>>两种sort>>> sorted(r) # new o...
分类:编程语言   时间:2015-03-28 06:20:12    阅读次数:172
Q5: Remove Duplicates from Sorted Array
问题描述:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space ...
分类:其他好文   时间:2015-03-21 21:16:20    阅读次数:118
LeetCode --- 73. Set Matrix Zeroes
题目链接: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. Follow up: Did you use extra space? A straight forward solution using O(mn) spa...
分类:其他好文   时间:2015-03-20 22:00:08    阅读次数:135
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!