Given a binary tree, flatten it to a linked list in-place.
- Mar 22 Thu 2018 04:20
-
Leetcode Tree,Linkedlist 114 @ Java
114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.
Given a binary tree, flatten it to a linked list in-place.
- Mar 06 Tue 2018 02:24
-
Leetcode DP 764 @ Java
764. Largest Plus Sign
In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given list mines which are 0. What is the largest axis-aligned plus sign of 1s contained in the grid? Return the order of the plus sign. If there is none, return 0.
In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given list mines which are 0. What is the largest axis-aligned plus sign of 1s contained in the grid? Return the order of the plus sign. If there is none, return 0.
- Feb 27 Tue 2018 12:56
-
Leetcode Greedy 316 @ Java
316. Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.
- Feb 27 Tue 2018 10:13
-
Leetcode DP 140 @Java
140. Word Break II
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. You may assume the dictionary does not contain duplicate words.
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. You may assume the dictionary does not contain duplicate words.
- Feb 21 Wed 2018 12:45
-
Google CodeJam I/O for women 2/17- Graph-Centrist
題目落落長 https://codejam.withgoogle.com/codejam/contest/dashboard?c=8384486#s=p2
簡化來說就是要判斷如果是任意 字母排序,判斷某word 是否可以在中間
簡化來說就是要判斷如果是任意 字母排序,判斷某word 是否可以在中間
- Feb 19 Mon 2018 01:26
-
Leetcode contest-2/17- BFS 785 @ Java
- Feb 10 Sat 2018 03:38
-
Leetcode Math 670 @Java
670. Maximum Swap
Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.
Example 1:
Input: 2736
Output: 7236
Explanation: Swap the number 2 and the number 7.
Example 2:
Input: 9973
Output: 9973
Explanation: No swap.
Note:
- The given number is in the range [0, 108]
這邊的思維是loop from MSB到LSB,然後每位要用往後找是否有比自己更大的
(不能用往前看,找比自己小的最大位,因為無法確定目前的數字換完就是最大的
ex. 98368 --> 98863,如果用往前找小的,會變成98638,但是其實最佳的換法是8跟3 換)
所以要用小的數往後找最大值來看(因為9一定會讓值是最大,不管在哪位)
一但找到就可以swap 後return
- Feb 09 Fri 2018 16:01
-
Leetcode Graph 269 @Java
- Feb 09 Fri 2018 01:37
-
Leetcode BFS 127 @ Java
127. Word Ladder
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:
- Feb 06 Tue 2018 03:55
-
Leetcode UnionFind 261 @Java
261. 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.
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.
- Feb 01 Thu 2018 12:44
-
Leetcode DP 337 @ Java
337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.
- Jan 30 Tue 2018 09:52
-
Leetcode Heap 23 @ Java
23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.