- 博客(671)
- 资源 (5)
- 收藏
- 关注
原创 Triangle Count
Given an array of integers, how many three numbers can be found in the array, so that we can build an triangle whose three edges length is the three numbers that we find? Have you met this quest
2018-01-11 21:21:17 295
原创 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. NoticeYou may assume that each input w
2018-01-11 20:31:50 191
原创 Partition Array II
Partition an unsorted integer array into three parts:The front part lowThe middle part >= low & highThe tail part > highReturn any of the possible solutions. Noticelow Have y
2018-01-11 19:11:04 265
原创 Two Sum - Difference equals to target
Given an array of integers, find two numbers that their difference equals to a target value.where index1 must be less than index2. Please note that your returned answers (both index1 and index2) a
2018-01-11 14:16:07 780
原创 Two Sum - Unique pairs
Given an array of integers, find how many unique pairs in the array such that their sum is equal to a specific target number. Please return the number of pairs.Have you met this question in a
2018-01-11 11:02:25 579
原创 Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. NoticeHave you consider that the string might be empty? This is a good question
2018-01-11 09:05:16 221
原创 Two Sum - Data structure design
Design and implement a TwoSum class. It should support the following operations: add and find.add - Add the number to an internal data structure.find - Find if there exists any pair of numbers w
2018-01-10 21:50:26 248
原创 Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
2018-01-10 20:33:23 184
原创 Subarray Sum Closest
Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.Have you met this question in a real interview? YesExample
2018-01-10 20:01:35 248
原创 152. Maximum Product Subarray
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],the contiguous subarray [2,3] has the largest
2018-01-10 16:18:39 177
原创 Insert into a Cyclic Sorted List
Given a node from a cyclic linked list which has been sorted, write a function to insert a value into the list such that it remains a cyclic sorted list. The given node can be any single node in the
2018-01-10 14:20:28 312
原创 leetcode常考题目 subset i 和subset ii
Given two strings, write a method to decide if one is a permutation of the other.javapublic class Solution { public boolean Permutation(String A, String B) { if (A == null && B == null
2018-01-08 19:11:59 388
原创 Palindrome Partitioning II
Given a string s, cut s into some substrings such that every substring is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.Have you met this question in a real i
2018-01-08 16:24:51 159
原创 Course Schedule II
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a
2018-01-07 15:57:51 150
原创 Course Schedule
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a
2018-01-07 15:25:24 257
原创 Six Degrees
Six degrees of separation is the theory that everyone and everything is six or fewer steps away, by way of introduction, from any other person in the world, so that a chain of "a friend of a friend" s
2018-01-06 16:05:59 278
原创 Remove Substrings
Given a string s and a set of n substrings. You are supposed to remove every instance of those n substrings from s so that s is of the minimum length and output this minimum length. Have you m
2018-01-06 15:40:35 412
原创 Zombie in Matrix
Given a 2D grid, each cell is either a wall 2, a zombie 1 or people 0 (the number zero, one, two).Zombies can turn the nearest people(up/down/left/right) into zombies every day, but can not throug
2018-01-06 14:32:48 227
原创 Binary Tree Serialization
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back from the file to reconstruct the exact same binary
2018-01-05 20:17:57 226
原创 Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.How we serialize an undirected graph:Nodes are labeled uniquely.We use # as a separator for each
2018-01-05 14:39:18 198
原创 Graph Valid Tree
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. NoticeYou can a
2018-01-05 14:17:23 309
原创 Binary Tree Longest Consecutive Sequence
Given a binary tree, find the length of the longest consecutive sequence path.The path could be start and end at any node in the treeHave you met this question in a real interview? Yes
2018-01-04 19:15:09 166
原创 Inorder Successor in Binary Search Tree
Given a binary search tree (See Definition) and a node in it, find the in-order successor of that node in the BST.If the given node has no in-order successor in the tree, return null.使用中序遍历的
2018-01-04 14:24:33 382
原创 LeetCode LCA问题
//**************** 12. Lowest Common Ancestor II ***************/*Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ancestor
2018-01-04 14:16:14 601
原创 Binary Tree Path Sum II
Your are given a binary tree in which each node contains a value. Design an algorithm to get all paths which sum to a given value. The path does not need to start or end at the root or a leaf, but it
2018-01-03 20:56:55 340
原创 Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Have you met this question in a re
2018-01-03 19:28:53 199
原创 Coursera Deep Learning 4 卷积神经网络 第一周习题
The basics of ConvNets1What do you think applying this filter to a grayscale image will do?Detect horizontal edgesDetect vertical edgesDetect 45 degree edgesDetect image contrast
2018-01-03 11:11:34 2986 2
原创 Smallest Rectangle Enclosing Black Pixels
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally a
2018-01-02 21:49:28 288
原创 K Closest Numbers In Sorted Array
Given a target number, a non-negative integer k and an integer array A sorted in ascending order, find the k closest numbers to target in A, sorted in ascending order by the difference between the n
2018-01-02 19:39:01 400
原创 剑指offer --- 矩阵中的路径
请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。 例如 a b c e s f c s a d e e 矩阵中包含一条字符串"bcced"的路径,但是矩阵中不包含"abcb"路径,因为字符串的第一个字符b占据了矩阵
2017-12-25 14:52:52 299
原创 Binary Tree Serialization
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back from the file to reconstruct the exact same binary
2017-12-25 07:56:55 228
原创 剑指offer — 把字符串转换成整数
将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数。 数值为0或者字符串不是一个合法的数值则返回0javapublic class Solution { public int StrToInt(String str) { str = str.trim(); if (str == null || str.length() == 0) {
2017-12-22 20:07:32 292
原创 Permutations && Permutations ii
Permutations 中不带有重复元素Permutations II 中带有重复元素Permutationsjavapublic class Solution { /* * @param nums: A list of integers. * @return: A list of permutations. */ p
2017-12-20 19:56:54 180
原创 剑指offer — 调整数组顺序使奇数位于偶数前面
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变(1) 该题目要求保持相对的顺序,因此可以使用一个额外的存储空间javaimport java.util.*;public class Solution { public void reOrderArray(
2017-12-19 18:52:06 165
原创 剑指offer--- 二进制中一的个数
输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。解题思路:该问题如果使用的是,第一反应中想到的向右移,然后判断target是否为0的方法,会因为负数造成oom。因此,使用n & (n - 1) 的方式;将一个数减去1,再与原来的数做与运算会将原来的数的最后一位变成0,因此,有多少个1就可以进行多少次这样的运算。javapublic class
2017-12-19 14:35:46 255
原创 剑指offer — 变态跳台阶
一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。java1public class Solution { public int JumpFloorII(int target) { if (target == 0) { return 0; } if (
2017-12-19 13:53:26 187
原创 qrt(x) II
Implement double sqrt(double x) and x >= 0.Compute and return the square root of x. NoticeYou do not care about the accuracy of the result, we will help you to output results.H
2017-12-18 19:32:49 291
原创 K Closest Numbers In Sorted Array
Given a target number, a non-negative integer k and an integer array A sorted in ascending order, find the k closest numbers to target in A, sorted in ascending order by the difference between the n
2017-12-18 18:30:18 352
原创 matlab处理字符串(空格替换)
举个简单的例子来说比较方便,比如我新建一个txt文档内容是Find the starting indices of the pattern string.我把它放在Matlab的当前工作路径上,文件名字为001.txt,我想把其中的空格变成逗号.那么可以仿照如下的方式来进行:12str=importdata('001.txt');a=st
2017-12-18 09:50:22 8172
原创 剑指offer — 机器人的运动路径
地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为3+5+3+8 = 19。请问该机器人能够达到多少个格子解题思路:使用dfs得方法进行处理javapu
2017-12-15 22:14:01 384 1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人