摘要: https://www.hackerrank.com/challenges/minimum-swaps-2/problem Minimum Swaps II You are given an unordered array consisting of consecutive integers [1, 阅读全文
posted @ 2018-09-15 13:50 轻风舞动 阅读(1198) 评论(0) 推荐(0) 编辑
摘要: 外排序 通常来说,外排序处理的数据不能一次装入内存,只能放在读写较慢的外存储器(通常是硬盘)上。外排序通常采用的是一种“排序-归并”的策略。在排序阶段,先读入能放在内存中的数据量,将其排序输出到一个临时文件,依此进行,将待排序数据组织为多个有序的临时文件。之后在归并阶段将这些临时文件组合为一个大的有 阅读全文
posted @ 2018-09-15 13:34 轻风舞动 阅读(3699) 评论(0) 推荐(0) 编辑
摘要: How would you remove duplicate lines from a file that is much too large to fit in memory? The duplicate lines are not necessarily adjacent, and say th 阅读全文
posted @ 2018-09-15 13:22 轻风舞动 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 有编号1~100个灯泡,起初所有的灯都是灭的。有100个同学来按灯泡开关,如果灯是亮的,那么按过开关之后,灯会灭掉。如果灯是灭的,按过开关之后灯会亮。 现在开始按开关。 第1个同学,把所有的灯泡开关都按一次(按开关灯的编号: 1,2,3,......100)。第2个同学,隔一个灯按一次(按开关灯的编 阅读全文
posted @ 2018-09-15 13:05 轻风舞动 阅读(1352) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significan 阅读全文
posted @ 2018-09-15 07:14 轻风舞动 阅读(507) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina 阅读全文
posted @ 2018-09-15 06:54 轻风舞动 阅读(719) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is d 阅读全文
posted @ 2018-09-15 06:46 轻风舞动 阅读(509) 评论(0) 推荐(0) 编辑
摘要: Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at leas 阅读全文
posted @ 2018-09-15 06:23 轻风舞动 阅读(791) 评论(0) 推荐(0) 编辑
摘要: Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A move is guaranteed to be valid and 阅读全文
posted @ 2018-09-15 04:35 轻风舞动 阅读(1091) 评论(0) 推荐(0) 编辑