算法
linux_player_c
喜欢linux
展开
-
1.算法之冒泡排序
算法之冒泡排序冒泡排序的思想冒泡排序是一种比较容易接收的排序,它稳定而且易于实现,其主要思想如下: 给定一个随机序列array(这里我们为了突出算法认为array内的元素是int类型),再给定两个下标i,j分别用来指向两个要比较和交换的对象,设i的初始值为0(i的含义代表着排序的轮数),让j的初始值为1(即每次让j从第二个位置开始),每次比较array[j]和array[j - 1]的大小关系,如原创 2015-12-24 10:37:48 · 606 阅读 · 0 评论 -
1.leetcde:在一个正整数数组中找到和为某个值的两个整数下标集合
在一个正整数数组中找到和为某个值的两个整数下标集合这个问题描述如下:例如一个整数集合nums = [2, 11, 32, 18, 5], 给出一个目标整数target = 29,则返回结果[1, 3],因为29 = 11 + 18。假设这个处理函数为twoSum。给出函数的实现。class Solution: def twoSum(self, nums, target)...原创 2018-07-10 09:37:17 · 666 阅读 · 0 评论 -
Max Increase to Keep City Skyline
In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of any number of buildings, by any amount (the amounts can...原创 2019-01-03 21:39:50 · 407 阅读 · 0 评论 -
Unique Email Addresses
Unique Email Addresses原创 2019-01-05 11:31:51 · 855 阅读 · 0 评论 -
To Lower Case
To Lower CaseImplement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.Example 1:Input: "Hello"Output: "hello"Example 2:Input: "here"Output: "h...原创 2019-01-06 22:46:59 · 451 阅读 · 0 评论 -
Jewels and Stones(宝石和石头)
1 问题抛出You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of ...原创 2019-01-02 22:41:41 · 279 阅读 · 0 评论 -
Range Sum of BST
Range Sum of BSTGiven the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to have unique values....原创 2019-01-03 11:08:01 · 305 阅读 · 0 评论