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 ...
随机推荐
- [转]Mysql命令
1.连接Mysql 格式: mysql -h主机地址 -u用户名 -p用户密码 1.连接到本机上的MYSQL.首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u root ...
- 【leetcode刷题笔记】Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A map ...
- 使用 Apache poi 导入Excel
本文主要记录Excel导入及模板下载,遇到的问题及注意事项. 第一节:Excel导入 1.如何获取Excel中的最大行,也就是最后一行? 2.如何获取有效行?有效行的定义是每一行记录中每一列中值都 ...
- wget 实现web监控脚本
#!/bin/sbin timeout= times= url=https://1.1.1.1 while true;do wget --no-check-certificate --timeout= ...
- SDUT 1048 Digital Roots
Digital Roots Time Limit: 1000ms Memory limit: 65536K 题目描述 The digital root of a positive integer ...
- java客户端文件的上传和下载
java客户端文件的上传和下载 //上传 public JTable upload(String id){ JTable table=new JTable(); System.out.println( ...
- 代码题(2)— 统计所有小于非负整数 n 的质数的数量
质数也叫素数,只能被1和它本身整除的. 利用筛选法. class Solution { public: int countPrimes(int n) { ) ; ; vector<); ;i&l ...
- Python Panda - 学习笔记
#Group by Function df.groupby('Date')[['Date']].count() df.groupby('Date')[['Date']].sum() # if it c ...
- hbase_异常_02_hbase无法访问16010端口
一.异常现象 上一个异常解决了之后,已经能正常启动hbase了,也能正常使用hbase shell ,但是无法通过浏览器访问 16010端口. 二.异常原因 1.原因一 hbase 1.0 以后的版 ...
- Java企业微信开发_01_接收消息服务器配置
一.准备阶段 需要准备事项: 1.一个能在公网上访问的项目: 见:Java微信公众平台开发_01_本地服务器映射外网 2.一个企业微信账号: 去注册:(https://work.weixin.qq.c ...