随笔分类 -  算法&Leetcode

摘要:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = ... 阅读全文
posted @ 2015-11-12 17:18 0giant 阅读(184) 评论(0) 推荐(0) 编辑
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, give... 阅读全文
posted @ 2015-11-12 15:55 0giant 阅读(247) 评论(0) 推荐(0) 编辑
摘要:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文
posted @ 2015-11-11 15:59 0giant 阅读(182) 评论(0) 推荐(0) 编辑
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRang... 阅读全文
posted @ 2015-11-11 15:13 0giant 阅读(139) 评论(0) 推荐(0) 编辑
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1比较简单,二叉树里的题其实有点举一反三的意思,很多题会一道就差不多了。递归的反... 阅读全文
posted @ 2015-11-09 16:24 0giant 阅读(134) 评论(0) 推荐(0) 编辑
摘要:Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.+----+-----------... 阅读全文
posted @ 2015-11-09 16:08 0giant 阅读(250) 评论(0) 推荐(0) 编辑
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4], t... 阅读全文
posted @ 2015-11-09 15:12 0giant 阅读(180) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For exam... 阅读全文
posted @ 2015-11-06 14:32 0giant 阅读(195) 评论(0) 推荐(0) 编辑
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c... 阅读全文
posted @ 2015-11-04 19:18 0giant 阅读(184) 评论(0) 推荐(0) 编辑
摘要:Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A... 阅读全文
posted @ 2015-11-03 22:53 0giant 阅读(160) 评论(0) 推荐(0) 编辑
摘要:我发现最近做题,我总是被“阵势”唬住,不管什么题,就先觉得自己不会了,不想去思考,这种习惯比较可怕。其实任何难题,只要你学会分解它,并逐一击破,其实你发现你是可以解决的。就像这道题,一个是要“删去”非正常字符例如':空格呀什么的,最后要的只有数字和字符。所以要有一个函数判断是否有效isValid。还... 阅读全文
posted @ 2015-11-02 16:43 0giant 阅读(203) 评论(0) 推荐(0) 编辑
摘要:又一道二维数组上的题,昨天刚开始的时候leetcode上不去了,就去牛客上面随便瞅瞅,当时看着道题就觉得,有些难度,二维数组说实话我一看到就怂。题目描述在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组... 阅读全文
posted @ 2015-11-02 10:04 0giant 阅读(287) 评论(0) 推荐(1) 编辑
摘要:对于Vector的用法,实在是知道的太少,算法思想比较简单,核心也就一行代码,但是实现错误就显示平时代码的不熟悉。Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5... 阅读全文
posted @ 2015-11-01 16:41 0giant 阅读(277) 评论(0) 推荐(0) 编辑
摘要:这应该是我自己做出来的第一道题,所以刚开始的时候把我激动坏了。Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors... 阅读全文
posted @ 2015-10-16 15:36 0giant 阅读(243) 评论(0) 推荐(0) 编辑
摘要:刚注册了leetcode,推荐的第一题就是Nim Game。You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you ta... 阅读全文
posted @ 2015-10-16 14:05 0giant 阅读(312) 评论(0) 推荐(0) 编辑