码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
python基础 -- 自定义排序
最近需要自定义排序序列,一直一筹莫展。然后发现,利用 sort()?或 sorted()?的 key?即可实现。 ????示例如下: def?sort_key(obj): ????sorted_list?=?[4,?2,?5,?9,?7,?8,?1,?3,?...
分类:编程语言   时间:2014-11-30 18:51:12    阅读次数:165
LeetCode[Array]: Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row...
分类:其他好文   时间:2014-11-30 16:56:56    阅读次数:120
leetcode Convert Sorted List to Binary Search Tree
把一个有序链表构成成平衡二叉树。和上一题有一点像。思路一:将有序链表存在一个数组里。然后根据每次访问中间节点当做根节点递归左右子树节点即可。代码如下:/** * Definition for singly-linked list. * struct ListNode { * int val;...
分类:其他好文   时间:2014-11-29 22:53:04    阅读次数:271
leetcode Convert Sorted Array to Binary Search Tree
利用更有序数组,构造平衡二叉树。思路,递归,每次中间节点为根节点,然后递归获得左右子树。/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *...
分类:其他好文   时间:2014-11-29 22:52:43    阅读次数:239
【LeetCode】Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.这题思路参照Conve...
分类:其他好文   时间:2014-11-29 20:07:35    阅读次数:178
【Leetcode】Search a 2D Matrix in JAVA
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right.The first integer of each...
分类:编程语言   时间:2014-11-29 17:41:48    阅读次数:176
Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord...
分类:其他好文   时间:2014-11-29 11:38:36    阅读次数:128
LeetCode Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its inde...
分类:其他好文   时间:2014-11-29 07:07:11    阅读次数:194
Leetcode-Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Solution:...
分类:其他好文   时间:2014-11-29 07:03:53    阅读次数:194
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 space (size that is greater or equa...
分类:其他好文   时间:2014-11-29 07:00:12    阅读次数:193
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!