# -*- coding: utf-8 -*-
#!/bin/env python
# Python2.7 nums = [2, 4, 7, 0, 12, 6] print sorted(range(len(nums))) # ind是 列表nums 排序后值的索引
ind = sorted(range(len(nums)), key=lambda x: nums[x]) print ind L = [('b',2),('a',1),('e',3),('d',4)]
print sorted(L)
# 按照列表中的第二项来进行排序
print sorted(L, key=lambda x:x[1]) print sorted(L, key=lambda x:x[0])

关键字:sorted two sum

leetcode笔记-1 twosum的更多相关文章

  1. leetcode笔记--1 two-sum

    my answer: ​​​​出现的问题:倒数第二行and i !=s这种情况没有考虑进去,以后要思考全面些

  2. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  3. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  4. Leetcode 笔记 110 - Balanced Binary Tree

    题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...

  5. Leetcode 笔记 100 - Same Tree

    题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...

  6. Leetcode 笔记 99 - Recover Binary Search Tree

    题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...

  7. Leetcode 笔记 98 - Validate Binary Search Tree

    题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...

  8. Leetcode 笔记 101 - Symmetric Tree

    题目链接:Symmetric Tree | LeetCode OJ Given a binary tree, check whether it is a mirror of itself (ie, s ...

  9. Leetcode 笔记 36 - Sudoku Solver

    题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...

随机推荐

  1. 我的Android进阶之旅------>Android自定义窗口标题实例

    该实例的功能比较简单,但是通过该实例的扩展可以在自定义标题中做出菜单导航等实用的功能,为了实现自定义窗口标题,需要做以下几个步骤: 1.给自定义标题提供一个界面 2.将自定义标题应用给Activity ...

  2. hibernate 查询方式

    1.对象导航查询 2.OID查询 3.hql查询 4.QBC查询 5.本地sql查询 一.对象导航查询 示例: 查询id=6的user对象的所有角色: 二.OID查询 实例查询id=6的user对象 ...

  3. 如何在官网下载java JDK的历史版本

    如何在官网下载java JDK的历史版本 http://jingyan.baidu.com/article/9989c746064d46f648ecfe9a.html 如何在官网下载java JDK的 ...

  4. http keep-alive简解

    http协议中,客户端发送请求,服务端在接收到请求后,返回所需要的数据后可以关闭连接,这样客户端读取完数据时会返回EOF(-1),表明数据已接受完全 备注:EOF end of file 什么是kee ...

  5. Delphi中 为DBNavigator的按钮加中文

    Delphi中 为DBNavigator的按钮加中文 /*Delphi中数据库控件DBNavigator使用起来不错,但是按钮上“+”.“-”等含义对于中国的用户不习惯,甚至不知道是什么含义.改成相应 ...

  6. java深入探究07-jsp

    RequestDispatcher是web资源包装类<jsp:include>只能实现固定jsp文件名他可以翻译为:RequestDispatcher(filename).include( ...

  7. Spark操作算子本质-RDD的容错

    Spark操作算子本质-RDD的容错spark模式1.standalone master 资源调度 worker2.yarn resourcemanager 资源调度 nodemanager在一个集群 ...

  8. Shiro身份认证-JdbcRealm

    Subject 认证主体 Subject认证主体包含两个信息 Principals : 身份,可以是用户名.邮箱.手机号等,用来标识一个登录主体身份. Credentials : 凭证,常见有密码,数 ...

  9. BioNLP概述

    BioNLP概述 工具: GENIA Tagger:GENIA Tagger是一个主要应用于生物医学文本领域的词性标注和浅层语法分析工具,GENIA Tagger在GENIA语料上的词性标记性能F-s ...

  10. php一维数组的创建

    php一维数组的创建 (1)通过array函数声明数组 使用array 函数定义数组,该函数返回通过所接受接收的参数建立的数组.array 函数使用的格式如下. $arry_name = array( ...