# -*- 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. IE下获取不到Response添加的cookie的解决方法

    原博客地址: http://blog.csdn.net/wjdd1/article/details/16341189 在百度上查询了好久也没有查询到结果,于是自己用ie的开发者工具进行跟踪,JSESS ...

  2. linux查看当前文件夹下每个文件大小

    查看当前文件夹下每个文件大小 并会给出当前文件大小总和,后面加具体的文件名会显示具体的文件大小 ls -lht 把*换成具体的文件名会显示具体的文件大小 du -sh *

  3. Data Structure Array: Find the two numbers with odd occurrences in an unsorted array

    http://www.geeksforgeeks.org/find-the-two-numbers-with-odd-occurences-in-an-unsorted-array/ #include ...

  4. Android系统篇之—-编写系统服务并且将其编译到系统源码中【转】

    本文转载自:http://www.wjdiankong.cn/android%E7%B3%BB%E7%BB%9F%E7%AF%87%E4%B9%8B-%E7%BC%96%E5%86%99%E7%B3% ...

  5. 利用etcd及confd实现配置自动管理

    ETCD etcd 架设etcd集群 静态启动etcd集群需要每个成员在集群中知道另一个成员.在许多情况下,集群成员的IP可能提前未知.在这种情况下,可以使用etcd集群的自动发现服务.一旦etcd集 ...

  6. EntityFramework 学习 一 Change Tracking in Entity Framework

    EntityFramework自动跟踪上下文中已经加载的实体,DbChangeTracker类给你关于当前实体的所有跟踪信息 注意,每个实体都要有EntityKey(主键)的属性,EntityFram ...

  7. 大话设计模式--策略模式 strategy -- C++实现实例

    1. 策略模式: 它定义了算法家族, 分别封装起来,使他们之间可以相互替换,此模式让算法变化, 不会影响到使用算法的客户. 用相同的方法调用不同的算法,减少各种算法类与使用算法类之间的耦合. 实例中策 ...

  8. java原生数据类型和引用类型

    java 中String 是个对象,是引用类型基础类型与引用类型的区别是,基础类型只表示简单的字符或数字,引用类型可以是任何复杂的数据结构基本类型仅表示简单的数据类型,引用类型可以表示复杂的数据类型, ...

  9. 前端框架之VUE

    vue学习[第1篇]:vue之指令 vue学习[第2篇]:es6简单介绍 vue学习[第3篇]:vue之node.js的简单介绍 vue学习[第4篇]:vue 之webpack打包工具的使用 vue学 ...

  10. Python入门经典练习题

    [程序1] 题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? num_list=[]cou=0for i in range(1,5): for j in range( ...