随笔分类 -  Leetcode

摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati 阅读全文
posted @ 2018-10-26 21:24 Veritas_des_Liberty 阅读(185) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2018-10-25 18:50 Veritas_des_Liberty 阅读(171) 评论(0) 推荐(0) 编辑
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example: AC code: Runtime: 12 ms 阅读全文
posted @ 2018-10-25 16:31 Veritas_des_Liberty 阅读(153) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2018-10-25 12:20 Veritas_des_Liberty 阅读(169) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Example 2: my code: Runtime: 12 ms, faster than  阅读全文
posted @ 2018-10-25 10:52 Veritas_des_Liberty 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Example 2: 阅读全文
posted @ 2018-10-24 18:07 Veritas_des_Liberty 阅读(195) 评论(0) 推荐(0) 编辑
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). Y 阅读全文
posted @ 2018-10-24 17:36 Veritas_des_Liberty 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra 阅读全文
posted @ 2018-10-24 16:39 Veritas_des_Liberty 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文
posted @ 2018-10-24 15:47 Veritas_des_Liberty 阅读(223) 评论(0) 推荐(0) 编辑
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文
posted @ 2018-10-24 12:02 Veritas_des_Liberty 阅读(164) 评论(0) 推荐(0) 编辑
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: AC code: Runtime: 88 ms, faster than 42.24% of C++  阅读全文
posted @ 2018-10-24 11:03 Veritas_des_Liberty 阅读(276) 评论(0) 推荐(0) 编辑
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOB 阅读全文
posted @ 2018-10-23 22:17 Veritas_des_Liberty 阅读(231) 评论(0) 推荐(0) 编辑
摘要:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文
posted @ 2018-10-23 21:20 Veritas_des_Liberty 阅读(167) 评论(0) 推荐(0) 编辑
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2018-10-23 21:09 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: 阅读全文
posted @ 2018-10-23 20:39 Veritas_des_Liberty 阅读(175) 评论(0) 推荐(0) 编辑
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2018-10-22 22:23 Veritas_des_Liberty 阅读(166) 评论(0) 推荐(0) 编辑
摘要:Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"path = "/a/../../ 阅读全文
posted @ 2018-10-22 21:37 Veritas_des_Liberty 阅读(203) 评论(0) 推荐(0) 编辑
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2018-10-22 18:47 Veritas_des_Liberty 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an in 阅读全文
posted @ 2018-10-22 18:30 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Given an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justif 阅读全文
posted @ 2018-10-22 18:10 Veritas_des_Liberty 阅读(151) 评论(0) 推荐(0) 编辑