1. 程式人生 > >leetcode筆記-1 twosum

leetcode筆記-1 twosum

int Coding spa pan env range blog odi lambda

# -*- 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])

leetcode筆記-1 twosum