leetcode笔记-1 twosum
# -*- 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的更多相关文章
- leetcode笔记--1 two-sum
my answer: 出现的问题:倒数第二行and i !=s这种情况没有考虑进去,以后要思考全面些
- 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 ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
- Leetcode 笔记 110 - Balanced Binary Tree
题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...
- Leetcode 笔记 100 - Same Tree
题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...
- Leetcode 笔记 99 - Recover Binary Search Tree
题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...
- Leetcode 笔记 98 - Validate Binary Search Tree
题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...
- Leetcode 笔记 101 - Symmetric Tree
题目链接:Symmetric Tree | LeetCode OJ Given a binary tree, check whether it is a mirror of itself (ie, s ...
- Leetcode 笔记 36 - Sudoku Solver
题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...
随机推荐
- sin6_addr打印:string to sockaddr_in6 and sockaddr_in6 to string
函式原型: #include <arpa/inet.h> const char *inet_ntop(int af, const void *src, char *dst, socklen ...
- LeetCode:救生艇【881】
LeetCode:救生艇[881] 题目描述 第 i 个人的体重为 people[i],每艘船可以承载的最大重量为 limit. 每艘船最多可同时载两人,但条件是这些人的重量之和最多为 limit. ...
- [原创]java WEB学习笔记30:Cookie Demo 之显示最近浏览的记录
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- NFS指定端口,NFS缓存
nfs服务端: #编辑/etc/nfsmount.conf,在末尾添加: #RQUOTAD_PORT=30001#LOCKD_TCPPORT=30002#LOCKD_UDPPORT=30002#MOU ...
- SpringBoot2.0之整合RabbitMQ
案例: Springboot 对RabbitMQ的支持 公共的pom: <project xmlns="http://maven.apache.org/POM/4.0.0" ...
- 关于mysql使用索引的一个问题
mysql一直号称是免维护的,但是我发现它往往连最表基本索引都不能自动维护,情景如下: 1.我用mysqldump导出一个大表longformh; 2.用mysql.exe导入到一个新库中: 3.查看 ...
- Memory Layout of C Programs
Memory Layout of C Programs A typical memory representation of C program consists of following sec ...
- HDU 1255 覆盖的面积 (线段树扫描线+面积交)
自己YY了一个的写法,不过时间复杂度太高了,网上的想法太6了 题意:给你一些矩阵,求出矩阵的面积并 首先按照x轴离散化线段到线段树上(因为是找连续区间,所以段建树更加好做). 然后我们可以想一下怎样 ...
- node 渲染html模板配置
node 渲染html模板配置 安装swig模块 npm install swig--save - dev 加载swig模块 var swig = require('swig'); 模板配置 //第一 ...
- html怎样可是使文本框内容不可修改
html怎样可是使文本框内容不可修改 <input type="text" readonly="readonly" onfocus="alert ...