随笔分类 -  Data Structure

摘要:Design and implement an iterator to flatten a 2d vector. It should support the following operations: next and hasNext. Example: Vector2D iterator = ne 阅读全文
posted @ 2022-11-13 06:55 苗妙苗 阅读(24) 评论(0) 推荐(0)
摘要:Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ 阅读全文
posted @ 2020-10-25 23:05 苗妙苗 阅读(72) 评论(0) 推荐(0)
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2020-09-30 00:43 苗妙苗 阅读(74) 评论(0) 推荐(0)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2020-09-27 11:07 苗妙苗 阅读(134) 评论(0) 推荐(0)
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. Example: Input: v1 = [1,2] v2 = [3,4,5,6] Output: [1,3,2,4,5,6] Expl 阅读全文
posted @ 2020-09-27 09:26 苗妙苗 阅读(143) 评论(0) 推荐(0)
摘要:Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it e 阅读全文
posted @ 2020-09-27 06:00 苗妙苗 阅读(90) 评论(0) 推荐(0)
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer or a list -- wh 阅读全文
posted @ 2020-09-26 22:35 苗妙苗 阅读(112) 评论(0) 推荐(0)
摘要:Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer or a list -- whose elements may also be intege 阅读全文
posted @ 2020-09-26 11:09 苗妙苗 阅读(100) 评论(0) 推荐(0)
摘要:Design and implement an iterator to flatten a 2d vector. It should support the following operations: next and hasNext. Example: Vector2D iterator = ne 阅读全文
posted @ 2020-09-26 00:46 苗妙苗 阅读(142) 评论(0) 推荐(0)
摘要:Implement the RandomizedSet class: bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, fal 阅读全文
posted @ 2020-09-17 11:00 苗妙苗 阅读(204) 评论(0) 推荐(0)
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2020-09-16 10:19 苗妙苗 阅读(104) 评论(0) 推荐(0)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2020-09-14 10:29 苗妙苗 阅读(118) 评论(0) 推荐(0)
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. Example: Input: v1 = [1,2] v2 = [3,4,5,6] Output: [1,3,2,4,5,6] Expl 阅读全文
posted @ 2020-09-14 00:07 苗妙苗 阅读(111) 评论(0) 推荐(0)
摘要:Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it e 阅读全文
posted @ 2020-09-13 06:24 苗妙苗 阅读(133) 评论(0) 推荐(0)
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer or a list -- wh 阅读全文
posted @ 2020-09-12 11:05 苗妙苗 阅读(106) 评论(0) 推荐(0)
摘要:Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list -- whose elements may also be integ 阅读全文
posted @ 2020-09-12 08:45 苗妙苗 阅读(107) 评论(0) 推荐(0)
摘要:Design and implement an iterator to flatten a 2d vector. It should support the following operations: next and hasNext. Example:Vector2D iterator = new 阅读全文
posted @ 2020-09-11 22:45 苗妙苗 阅读(166) 评论(0) 推荐(0)
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w 阅读全文
posted @ 2020-08-04 10:46 苗妙苗 阅读(117) 评论(0) 推荐(0)
摘要:Implement an iterator to flatten a 2d vector. Example: Input: 2d vector = [ [1,2], [3], [4,5,6] ] Output: [1,2,3,4,5,6] Explanation: By calling next r 阅读全文
posted @ 2020-08-04 07:49 苗妙苗 阅读(104) 评论(0) 推荐(0)
摘要:[抄题]: There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of t 阅读全文
posted @ 2018-08-23 09:04 苗妙苗 阅读(159) 评论(0) 推荐(0)