`
bcyy
  • 浏览: 1824677 次
文章分类
社区版块
存档分类
最新评论
文章列表
1D people lived in a 1D country. Everything in the country was one-dimensional, and everything was simple and clear: just one axis and two directions — forward and backward. Even a 1D world has problems, though; for instance, finding an exit from a maze. An idea of a 1D maze might seem weird to ...
It was an ordinary grim October morning. The sky was covered by heavy gray clouds. It was a little rainy. The rain drops fell on the windows with quiet bangs. Ilya was sitting at the computer and gloomy looking out of the window at the bleak scenery. Suddenly, a note caught his attention from t ...
The blonde Angela has a new whim: internet chats. Of course, as any blonde, she writes her messages using the upper case. You are the moderator of Angela's favorite chat and you're fed up with her upper-case messages. The problem is that Angela does not respond to your warnings. You decided to ...
Two Nikifors play a funny game. There is a heap ofNstones in front of them. Both Nikifors in turns take some stones from the heap. One may take any number of stones with the only condition that this number is a nonnegative integer power of 2 (e.g. 1, 2, 4, 8 etc.). Nikifor who takes the last st ...
On a sunny Sunday, a group of children headed by their teacher came to an amusement park. Aunt Frosya, who was a very kind and quiet person, worked at the ticket window on that day. The teacher gave her the money but didn't say how many tickets she wanted to buy. Could Aunt Frosya determine it ...
原题链接:http://oj.leetcode.com/problems/reverse-linked-list-ii/这道题是比较常见的链表反转操作,不过不是反转整个链表,而是从m到n的一部分。分为两个步骤,第一步是找到m结点所在位置,第二步就是进行反转直到n结点。反转的方法就是每读到一个结点,把它插入到m结点前面位置,然后m结点接到读到结点的下一个。总共只需要一次扫描,所以时间是O(n),只需要几个辅助指针,空间是O(1)。代码如下:public ListNode reverseBetween(ListNode head, int m, int n) { if(head == nul ...
原题链接:http://oj.leetcode.com/problems/subsets-ii/ 这道题跟Subsets一样是经典的NP问题--求子集。比Subsets稍微复杂一些的是这里的集合中可能出现重复元素,因此我们在求子集的时候要避免出现重复的子集。在
Nikita, a schoolboy, is currently taking part in one of programming contests. He is really upset because all the problem statements are so long and unclear. So he took the statement of the first problem and cut it into pieces in such a way that each piece contained exactly one letter. After tha ...
When Vito Maretti writes an important letter he encrypts it. His method is not very reliable but it’s enough to make any detective understand nothing in that letter. Sheriff doesn’t like such state of affairs. He wants to hack the cipher of Vito Maretti and he promises to forget about all of yo ...
There is no involute formulation concerning factitiously activity of SKB Kontur in this problem. Moreover, there is no formulation at all. Input There is the only numberN, 1 ≤N≤ 109. Output Your program is to output two positive integersAandPseparated with a space such that: N= ...
The blocks in the city of Fishburg are of square form.Navenues running south to north andMstreets running east to west bound them. A helicopter took off in the most southwestern crossroads and flew along the straight line to the most northeastern crossroads. How many blocks did it fly above? ...
The clock shows 11:30 PM. The sports programmers of the institute of maths and computer science have just finished their training. The exhausted students gloomily leave their computers. But there’s something that cheers them up: Misha, the kind coach is ready to give all of them a lift home in ...
Our program committee uses different tools for problem development: a mailing list, a version control system, an administration system of theTimus Online Judgewebsite, and many others. Chairman of the program committee must constantly keep the passwords for these systems in his head. Of course, ...
Old Captain Jack Sparrow’s friend Tia Dalma, the fortuneteller and prophetess, often makes potions. She has an outstanding collection of the rarest ingredients such as rat tails, fingers of drowned, tears of virgins and so on. And all these ingredients require special care. Recently Tia Da ...
原题链接:http://oj.leetcode.com/problems/decode-ways/这道题要求解一个数字串按照字符串编码方式可解析方式的数量。看到这种求数量的,我们很容易想到动态规划来存储前面信息,然后迭代得到最后结果。我们维护的量res[i]是表示前i个 ...
Global site tag (gtag.js) - Google Analytics