随笔分类 -  LintCode

摘要: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 l 阅读全文
posted @ 2016-07-10 09:59 Grandyang 阅读(1578) 评论(0) 推荐(0) 编辑
摘要:Design a parking lot. see CC150 OO Design for details.1) n levels, each level has m rows of spots and each row has k spots.So each level has m x k spo 阅读全文
posted @ 2016-07-09 23:37 Grandyang 阅读(3864) 评论(3) 推荐(0) 编辑
摘要:Given a linked list, swap every two adjacent nodes and return its head. Given a linked list, swap every two adjacent nodes and return its head. Exampl 阅读全文
posted @ 2016-07-06 23:12 Grandyang 阅读(629) 评论(0) 推荐(0) 编辑
摘要:Remove all elements from a linked list of integers that have value val. Remove all elements from a linked list of integers that have value val. Have y 阅读全文
posted @ 2016-07-05 22:53 Grandyang 阅读(604) 评论(0) 推荐(0) 编辑
摘要:Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the right pointer in TreeNode as the next pointer in ListNode. Notic 阅读全文
posted @ 2016-07-04 23:44 Grandyang 阅读(1070) 评论(0) 推荐(0) 编辑
摘要:Given an integer array, sort it in ascending order. Use quick sort, merge sort, heap sort or any O(nlogn) algorithm. Given an integer array, sort it i 阅读全文
posted @ 2016-07-03 12:46 Grandyang 阅读(2334) 评论(0) 推荐(0) 编辑
摘要:Given an integer array, sort it in ascending order. Use selection sort, bubble sort, insertion sort or any O(n2) algorithm. Given an integer array, so 阅读全文
posted @ 2016-07-02 12:32 Grandyang 阅读(2248) 评论(0) 推荐(0) 编辑
摘要:Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value. 阅读全文
posted @ 2016-06-20 13:24 Grandyang 阅读(945) 评论(0) 推荐(0) 编辑
摘要:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th 阅读全文
posted @ 2016-06-16 23:31 Grandyang 阅读(1554) 评论(0) 推荐(0) 编辑
摘要:Design a data structure that supports the following two operations: addWord(word) and search(word)search(word) can search a literal word or a regular 阅读全文
posted @ 2016-06-11 01:19 Grandyang 阅读(1195) 评论(0) 推荐(0) 编辑
摘要:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O''s into 'X''s in that surrounde 阅读全文
posted @ 2016-06-10 00:07 Grandyang 阅读(825) 评论(0) 推荐(0) 编辑
摘要:Given two arrays, write a function to compute their intersection.Notice Each element in the result should appear as many times as it shows in both arr 阅读全文
posted @ 2016-06-09 00:08 Grandyang 阅读(923) 评论(0) 推荐(0) 编辑
摘要:Given two arrays, write a function to compute their intersection.Notice Each element in the result must be unique. The result can be in any order.Have 阅读全文
posted @ 2016-06-07 00:18 Grandyang 阅读(1141) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return all root-to-leaf paths.ExampleGiven the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:[ "1->2->5", "1->3"] 阅读全文
posted @ 2016-06-06 01:26 Grandyang 阅读(1019) 评论(0) 推荐(0) 编辑
摘要:Write an algorithm to determine if a number is happy. A happy number is a number defined by the following process: Starting with any positive integer, 阅读全文
posted @ 2016-06-05 07:21 Grandyang 阅读(2074) 评论(0) 推荐(0) 编辑
摘要:Factory is a design pattern in common usage. Please implement a ToyFactory which can generate proper toy based on the given type.ExampleToyFactory tf 阅读全文
posted @ 2016-06-02 00:32 Grandyang 阅读(2440) 评论(0) 推荐(0) 编辑
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Notice You must 阅读全文
posted @ 2016-05-31 00:07 Grandyang 阅读(824) 评论(0) 推荐(0) 编辑
摘要:Factory is a design pattern in common usage. Implement a ShapeFactory that can generate correct shape. You can assume that we have only tree different 阅读全文
posted @ 2016-05-20 15:03 Grandyang 阅读(3230) 评论(0) 推荐(0) 编辑
摘要:Implement a simple twitter. Support the following method: postTweet(user_id, tweet_text). Post a tweet.getTimeline(user_id). Get the given user's most 阅读全文
posted @ 2016-05-19 07:41 Grandyang 阅读(2343) 评论(0) 推荐(0) 编辑
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Notice You may assume all input has valid answer. Example 阅读全文
posted @ 2016-05-17 13:04 Grandyang 阅读(976) 评论(0) 推荐(0) 编辑

Fork me on GitHub