摘要:
Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota... 阅读全文
摘要:
Given a range [m, n] where 0 >1; n = n>>1; count++; } return m<<count; }} 阅读全文
摘要:
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
摘要:
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].大体思路:设置一个... 阅读全文
摘要:
step1:通过chkconfig --list命令查看mysqld是否在列表中;step2:如果列表中没有mysqld这个,需要先用这个命令添加:chkconfig --add mysqldstep3:然后用这个命令设置开机启动: chkconfig mysqld on 阅读全文
摘要:
一.算法流程Step1:初始化一群粒子(粒子个数为50个),包括随即位置和速度;Step2:计算每个粒子的适应度fitness;Step3:对每个粒子,将其适应度与其进过的最好位置(局部)pbest做比较,如果较好,则将其作为当前的最好位置pbest;Step4:对每个粒子,将其将其适应值与群体所经... 阅读全文
摘要:
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/** * Definition for a binary tree node... 阅读全文
摘要:
Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
摘要:
Given an array of integers and an integer k, return true if and only if there are two distinct indices i and j in the array such that nums[i] = nums[j... 阅读全文
摘要:
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文