03 2017 档案
摘要:110. Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a bin
阅读全文
摘要:415. Add Strings Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: java代码:
阅读全文
摘要:401. Binary Watch java代码:
阅读全文
摘要:189. Rotate Array Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5
阅读全文
摘要:100. Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structura
阅读全文
摘要:404. Sum of Left Leaves Find the sum of all left leaves in a given binary tree. Example:
阅读全文
摘要:建议不要安装3.0以上版本,但是2.4.10版本又不支持gpu,真TM坑爹,应该可以用2.4.12版本。我装的是cuda8.0+opencv2.4.13 1、首先下载opencv2.4.12版本 http://opencv.org/downloads.html 2、安装依赖包 3、build ope
阅读全文
摘要:14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. 要求一个字符串数组里面最长公共前缀字符串(数组里面所有字符串) 一开始求成
阅读全文
摘要:476. Number Complement Example 1: Example 2: 求一个数的补码。 另一种解法: 举个例子:100110, 它的补码是 011001, 和是 111111. 所以我们先求和num的二进制长度相同全为一的数,然后做减法
阅读全文
摘要:344. Reverse String Write a function that takes a string as input and returns the string reversed. 反转string字符串 java代码: 第二种解法,更加快速 java代码:
阅读全文
摘要:461. Hamming Distance 求两个数之间的汉明距离,两个等长字符串之间的汉明距离是两个字符串对应位置的不同字符的个数。换句话说,它就是将一个字符串变换成另外一个字符串所需要替换的字符个数。这里将书转化为二进制然后比较相同位置不同的数有几个。 java代码: 第二种方法,x,y两个数可
阅读全文
摘要:257. Binary Tree Paths Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are:
阅读全文
摘要:27. Remove Element Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for
阅读全文
摘要:441. Arranging Coins You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n,
阅读全文
摘要:20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brack
阅读全文
摘要:1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input wo
阅读全文
摘要:7. Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 此题题意为反转一个整数个各个数字,比如123,翻转后为321 java代码: 但
阅读全文
摘要:13. Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 给定一个罗马数字s,( I<=s<=MMM
阅读全文
摘要:Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding colu
阅读全文
摘要:Fizz Buzz Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of
阅读全文
摘要:Add Binary Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 求两个二进制数的和 java代码:
阅读全文
摘要:String 字符串常量StringBuffer 字符串变量(线程安全)StringBuilder 字符串变量(非线程安全) 简要的说, String 类型和 StringBuffer 类型的主要性能区别其实在于 String 是不可变的对象, 因此在每次对 String 类型进行改变的时候其实都等
阅读全文
摘要:Implement Queue using Stacks Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Remo
阅读全文
摘要:Assign Cookies Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each
阅读全文
摘要:Construct the Rectangle For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s
阅读全文
摘要:Palindrome Number Determine whether an integer is a palindrome. Do this without extra space.
阅读全文
摘要:Tenth Line shell编程 从file.txt中读数据,echo输出到控制台 while...do...done是bash中的语法结构
阅读全文
摘要:中文屋子与图灵测试谁对? 图灵测试(The Turing test)所描述的是这样一个实验,有两间屋子,一间屋子里面是一个真实的人类,另一间屋子里面是人类所发明的机器人,屋子里面的人或者机器与屋子外的人只能通过发文字信息进行交流,如果有大多数屋子外的人分不清楚哪一间屋子里面是人,哪一间屋子里面是机器
阅读全文
摘要:Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find
阅读全文
摘要:Largest Palindrome Product Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should
阅读全文
摘要:Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if
阅读全文
摘要:Reverse Linked List Reverse a singly linked list. 此题不难,附上java代码:
阅读全文
摘要:Linked List Cycle Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 此题并不难,声明2个指针一个步长1,一个步长
阅读全文
摘要:1.knn是分类算法 2.监督学习 3.给它的数据是有label的,是已经事先分类好了的, 类别数不变。 1.kmeans是聚类算法 2.非监督学习 3.给它的数据是没有label,是没有事先分类好的, 以“物以类聚”原理进行聚集成簇。 K的含义:来了一个样本x,要给它分类,即求出它的类别,就从数据
阅读全文
摘要:kmeans算法思想: 1.从数据集中随机选取k个初始点作为质心。 2.遍历数据集中所有的点,求出每个点到每个质心的距离,找出距离改点最近的质心,并改变此点类型为此质点的类型。 3.重新为每个类别更新其质心。 4.重复2,3,步直到最后两次质心位置相同退出while循环。 补充用python实现的代
阅读全文
摘要:K最近邻(k-Nearest Neighbor,KNN)分类算法可以说是最简单的机器学习算法了。它采用测量不同特征值之间的距离方法进行分类。它的思想很简单:如果一个样本在特征空间中的k个最相似(即特征空间中最邻近)的样本中的大多数属于某一个类别,则该样本也属于这个类别。 其算法描述如下: 1)计算已
阅读全文
浙公网安备 33010602011771号