上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页
摘要: 1753题目链接 题目大意: 一个4乘4的棋盘,上面放满了正反两面分别为黑和白的棋子,翻转一个棋子会让这个棋子上下左右的棋子也翻转,给定一个初始状态,求使所有棋子颜色相同所需的最少翻转次数。 解题思路: 先检查翻转0个棋子时是否所有棋子颜色一致,若不一致则翻转1个棋子,依次类推,若翻转某n个棋子后成 阅读全文
posted @ 2019-03-07 14:01 bloglxc 阅读(139) 评论(0) 推荐(0)
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-03-06 13:47 bloglxc 阅读(153) 评论(0) 推荐(0)
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2019-03-06 13:38 bloglxc 阅读(110) 评论(0) 推荐(0)
摘要: Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,00 阅读全文
posted @ 2019-03-03 18:12 bloglxc 阅读(103) 评论(0) 推荐(0)
摘要: 1、binary search tree Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definitio 阅读全文
posted @ 2019-01-28 17:16 bloglxc 阅读(119) 评论(0) 推荐(0)
摘要: 一种方法是用set存储出现过的指针,重复出现时就是有环: 1 class Solution { 2 public: 3 bool hasCycle(ListNode *head) { 4 set<ListNode*> st; 5 ListNode *p = head; 6 while(p) { 7 阅读全文
posted @ 2019-01-16 09:50 bloglxc 阅读(78) 评论(0) 推荐(0)
摘要: Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti 阅读全文
posted @ 2019-01-14 17:56 bloglxc 阅读(86) 评论(0) 推荐(0)
摘要: 1、 输出:20 2、placeholder使用 可以先声明变量在定义: 输出:6 矩阵也可用上述方式声明。 或者: 3、创建一个矩阵: 4、矩阵运算 点乘: 相加:可以直接用加号 5、计算代价函数 阅读全文
posted @ 2019-01-08 20:39 bloglxc 阅读(106) 评论(0) 推荐(0)
摘要: 1、默认为大顶堆 运行结果: 2、小顶堆 运行结果: 3、自定义 运行结果: 阅读全文
posted @ 2019-01-05 19:58 bloglxc 阅读(136) 评论(0) 推荐(0)
摘要: 1、“/”为浮点数除,“//”为整数除。 2、字典 设置默认值: 方法1: 1 dic = {} 2 dic['A'] = dic.get('A', 0) + 1 当字典不包含键‘A’时,get函数返回默认值0. 方法2: 1 dic = {} 2 dic.setdefault('A', 0) 3 阅读全文
posted @ 2019-01-01 18:42 bloglxc 阅读(164) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 13 下一页