随笔分类 -  RP

摘要:Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all 阅读全文
posted @ 2019-05-06 00:31 北叶青藤 阅读(414) 评论(0) 推荐(0)
摘要:Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both 阅读全文
posted @ 2019-05-06 00:11 北叶青藤 阅读(300) 评论(0) 推荐(0)
摘要:Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the 阅读全文
posted @ 2019-02-19 06:51 北叶青藤 阅读(138) 评论(0) 推荐(0)
摘要:Basic Calculator I Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parenthes 阅读全文
posted @ 2019-02-18 02:42 北叶青藤 阅读(373) 评论(0) 推荐(0)
摘要:Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 阅读全文
posted @ 2016-12-28 06:19 北叶青藤 阅读(199) 评论(0) 推荐(0)
摘要:Given two Binary Search Trees, find common nodes in them. In other words, find intersection of two BSTs. Example: from: http://www.geeksforgeeks.org/p 阅读全文
posted @ 2016-12-19 14:17 北叶青藤 阅读(369) 评论(0) 推荐(0)
摘要:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th 阅读全文
posted @ 2016-12-17 23:56 北叶青藤 阅读(203) 评论(0) 推荐(0)
摘要:Design a data structure that supports all following operations in O(1) time. insert(val): Inserts an item val to the set if not already present.remove 阅读全文
posted @ 2016-12-08 10:51 北叶青藤 阅读(254) 评论(0) 推荐(0)
摘要:Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. You can think of the left and right pointers as synonymous to the prede 阅读全文
posted @ 2016-11-11 07:54 北叶青藤 阅读(588) 评论(0) 推荐(0)
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文
posted @ 2016-11-04 22:09 北叶青藤 阅读(452) 评论(0) 推荐(0)
摘要:Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or do 阅读全文
posted @ 2016-10-29 06:27 北叶青藤 阅读(244) 评论(0) 推荐(0)
摘要:Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or *between the di 阅读全文
posted @ 2016-10-23 23:07 北叶青藤 阅读(235) 评论(0) 推荐(0)
摘要:You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle. 0 - A gate. INF - Infinity means an empty room 阅读全文
posted @ 2016-10-10 07:37 北叶青藤 阅读(194) 评论(0) 推荐(0)
摘要:There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of words from the 阅读全文
posted @ 2016-09-01 23:07 北叶青藤 阅读(286) 评论(0) 推荐(0)
摘要:Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. Not 阅读全文
posted @ 2016-08-09 10:18 北叶青藤 阅读(271) 评论(0) 推荐(0)
摘要: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 the maximum profit. You may comple 阅读全文
posted @ 2016-08-09 03:59 北叶青藤 阅读(293) 评论(0) 推荐(0)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文
posted @ 2016-08-08 11:39 北叶青藤 阅读(331) 评论(0) 推荐(0)
摘要:The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu 阅读全文
posted @ 2016-08-08 10:11 北叶青藤 阅读(267) 评论(0) 推荐(0)
摘要:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example:Given n = 13,Return 阅读全文
posted @ 2016-08-07 11:48 北叶青藤 阅读(234) 评论(0) 推荐(0)
摘要:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th 阅读全文
posted @ 2016-08-07 05:21 北叶青藤 阅读(283) 评论(0) 推荐(0)