LintCode
foradawn
这个作者很懒,什么都没留下…
展开
-
1. A + B Problem
1. A + B Problem Description Write a function that add two numbers A and B. You should not use + or any arithmetic operators. Clarification Are a and b both 32-bit integers? Yes. Can I use bi...原创 2018-04-08 22:53:13 · 242 阅读 · 0 评论 -
5. Kth Largest Element
5. Kth Largest Element Description Find K-th largest element in an array. Example In array [9,3,2,4,8], the 3rd largest element is 4. In array [1,2,3,4,5], the 1st largest element is 5, 2nd large...原创 2018-04-13 23:12:00 · 335 阅读 · 0 评论 -
4. Ugly Number II
4. Ugly Number II Description Ugly number is a number that only have factors 2, 3 and 5. Design an algorithm to find the nth ugly number. The first 10 ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 1...原创 2018-04-13 22:37:00 · 231 阅读 · 0 评论 -
68. Binary Tree Postorder Traversal
68. Binary Tree Postorder Traversal Description Given a binary tree, return the postorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [...原创 2018-04-11 22:44:02 · 191 阅读 · 0 评论 -
67. Binary Tree Inorder Traversal
67. Binary Tree Inorder Traversal Description Given a binary tree, return the inorder traversal of its nodes' values. Example Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,...原创 2018-04-11 22:40:44 · 205 阅读 · 0 评论 -
66. Binary Tree Preorder Traversal
66. Binary Tree Preorder Traversal Description Given a binary tree, return the preorder traversal of its nodes' values. Example Given: 1 / \ 2 3 / \ 4 5 return [1,2,4,5,3]. Solution...原创 2018-04-11 22:35:10 · 254 阅读 · 0 评论 -
155. Minimum Depth of Binary Tree
155. Minimum Depth of Binary Tree Description 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 le...原创 2018-04-11 22:23:28 · 204 阅读 · 0 评论 -
97. Maximum Depth of Binary Tree
97. Maximum Depth of Binary Tree Description Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest lea...原创 2018-04-11 22:01:40 · 140 阅读 · 0 评论 -
3. Digit Counts
3. Digit Counts Description Count the number of k's between 0 and n. k can be 0 - 9. Example if n = 12, k = 1 in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] we have FIVE 1's (1, 10, 11, 12) Soluti...原创 2018-04-10 22:55:10 · 239 阅读 · 0 评论 -
41. Maximum Subarray
41. Maximum Subarray Description Given an array of integers, find a contiguous subarray which has the largest sum. The subarray should contain at least one number. Example Given the array [−2,...原创 2018-04-10 12:43:21 · 175 阅读 · 0 评论 -
12. Min Stack
12. Min Stack Description Implement a stack with min() function, which will return the smallest number in the stack. It should support push, pop and min operation all in O(1) cost. Example push(...原创 2018-04-15 14:24:28 · 206 阅读 · 0 评论 -
11. Search Range in Binary Search Tree
11. Search Range in Binary Search Tree Description Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print ...原创 2018-04-15 13:54:12 · 348 阅读 · 0 评论 -
9. Fizz Buzz
9. Fizz Buzz Description Given number n. Print number from 1 to n. But: when number is divided by 3, print "fizz". when number is divided by 5, print "buzz". when number is divided by both 3 and 5,...原创 2018-04-15 13:44:18 · 254 阅读 · 0 评论 -
8. Rotate String
8. Rotate String Description Given a string and an offset, rotate string by offset. (rotate from left to right) Example Given "abcdefg". offset=0 => "abcdefg" offset=1 => "gabcdef" offset=2...原创 2018-04-15 13:32:40 · 228 阅读 · 0 评论 -
2. Trailing Zeros
2. Trailing Zeros Description Write an algorithm which computes the number of trailing zeros in n factorial. Example 11! = 39916800, so the out should be 2 Solution public class Solution { /...原创 2018-04-14 23:41:20 · 251 阅读 · 0 评论 -
7. Serialize and Deserialize Binary Tree
7. Serialize and Deserialize Binary Tree Description Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading ...原创 2018-04-14 20:26:15 · 171 阅读 · 0 评论 -
6. Merge Two Sorted Arrays
6. Merge Two Sorted Arrays Description Merge two given sorted integer array A and B into a new sorted integer array. Example A=[1,2,3,4] B=[2,4,5,6] return [1,2,2,3,4,4,5,6] Solution public clas...原创 2018-04-13 23:22:43 · 204 阅读 · 0 评论