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 ...
随机推荐
- java上传文件,下载文件
1.上传文件 1 protected int doTask(BaseForm form) throws AppException, FatalException, NoExistsException, ...
- html_dom类读取
上传类文件以后,有三种方式调用这个类:从url中加载html文档从字符串中加载html文档从文件中加载html文档 复制代码 代码如下: <?php// 新建一个Dom实例$html = new ...
- sql语句查看库里有没有这张表,有就删除
查看库里有没有这张表,有就删除 DROP TABLE IF EXISTS 表名
- LeetCode:完全平方数【279】【DP】
LeetCode:完全平方数[279][DP] 题目描述 给定正整数 n,找到若干个完全平方数(比如 1, 4, 9, 16, ...)使得它们的和等于 n.你需要让组成和的完全平方数的个数最少. 示 ...
- linux 指令(经常更新)
添加一个服务 # sudo update-rc.d 服务名 defaults 99 删除一个服务 # sudo update-rc.d 服务名 remove 临时重启一个服务 # /etc/init. ...
- RTMP & HLS
一,直播云架构 2. RTMP 协议 RTMP(Real Time Messaging Protocol)是Adobe Systems公司为Flash播放器和服务器之间音频.视频和数据传输开发的开放协 ...
- Data Structure Binary Tree: Boundary Traversal of binary tree
http://www.geeksforgeeks.org/boundary-traversal-of-binary-tree/ #include <iostream> #include & ...
- [原创] hadoop学习笔记:重新格式化HDFS文件系统
所谓的重新格式化HDFS文件系统,实际意味着重新的创建一个HDFS文件系统.也就是说,必须将先前的已经有的文件系统配置删除.如下: 笔者采用的是最小化安装 这个是core-site.xml配置 这个是 ...
- debian下为stm32f429i-discovery编译uboot
交叉编译器:arm-uclinuxeabi-2010q1 交叉编译器下载下来后解压,然后将其中bin文件夹路径加入到PATH变量中. 先下载uboot和linux源码: git clone https ...
- POJ 之2386 Lake Counting
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20003 Accepted: 10063 D ...