杨帆博客

你想开发游戏还是改变世界?


  • 首页

  • 标签

  • 归档

  • 搜索

House-Robber-III

发表于 2017-12-28 | 更新于: 2018-08-22

LeetCode# House Robber III

  The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that “all houses in this place forms a binary tree”. It will automatically contact the police if two directly-linked houses were broken into on the same night.

Determine the maximum amount of money the thief can rob tonight without alerting the police.

阅读全文 »

Odd-Even-Linked-List

发表于 2017-12-26 | 更新于: 2018-08-22

LeetCode#328 Odd Even Linked List

  Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.

阅读全文 »

Student-Attendance-Record-I

发表于 2017-12-24 | 更新于: 2018-08-22

LeetCode#551 Student Attendance Record I

  You are given a string representing an attendance record for a student. The record only contains the following three characters:

  1. ‘A’ : Absent.
  2. ‘L’ : Late.
  3. ‘P’ : Present.

A student could be rewarded if his attendance record doesn’t contain more than one ‘A’ (absent) or more than two continuous ‘L’ (late).

阅读全文 »

Delete-Operation-for-Two-Strings

发表于 2017-12-23 | 更新于: 2018-08-22

LeetCode#583 Delete Operation for Two Strings

  Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.

阅读全文 »

Missing-Number

发表于 2017-12-22 | 更新于: 2018-08-22

LeetCode#268 Missing Number

  Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.

Example 1

1
2
Input: [3,0,1]
Output: 2

Example 2

1
2
Input: [9,6,4,2,3,5,7,0,1]
Output: 8
阅读全文 »
1…404142…46
KsGin

KsGin

游戏程序员/计算机图形学/Unity/西山居搬砖

226 日志
16 标签
GitHub E-Mail Google Twitter
© 2018 KsGin @ 2018
0%