common

Common Lisp学习笔记

老子叫甜甜 提交于 2021-02-07 22:47:47
全局变量以*号包裹 ------------------------------------------------------------- 列表:(list 元素1 元素2 元素3 ...) 属性表:(list 符号1 元素1 符号2 元素2 ...) 从属性表取值:(getf 属性表 符号) 遍历列表:(dolist 元素 列表),用PHP表述就相当于foreach(列表 as 元素) 压入元素:(push 元素 变量) ------------------------------------------------------------- 定义函数:(defun 函数名 (参数表) 函数体) 定义变量:(defvar 变量名 变量值) 变量赋值:(setf 变量名 变量值) ------------------------------------------------------------- format格式化参数的含义 # ~{ ... ~}:拆分一个属性表的键值对 # ~a:占位符 # ~t:制表符 # ~%:换行符 来源: oschina 链接: https://my.oschina.net/u/103341/blog/121425

leetcode

南楼画角 提交于 2020-04-25 08:15:28
找最长公共前缀,Longest Common Prefix,自己写的小算法,并吸取他人的精华进行改进,直接上代码,第一次写难免会有疏漏,还望大家指正 #include<iostream> #include<string> #include<vector> using namespace std; //第10题:找最长公共前缀,Longest Common Prefix //abcd //ab //abjklg //输出:ab //自己的思路:从第一个串的第一个字符开始匹配,后面的串与第一串进行匹配。如果都能匹配,则第一个串即为最长前缀,若不行,则从不行的那个字符直接推出循环 //原始版本:设置flag和flag1,flag用于确定哪个字符可以加入到最长匹配字符串中,flag1用于当遇到不能匹配的串时来结束外层循环 string longestCommonPrefixpre(vector<string>& strs) { int i,j,flag=0,flag1=0; string com; if(strs.size()==0) //一开始没有通过就是因为没有这行,当strs为空的时候没有考虑进去 return com; for(i=0;i<strs[0].size();i++) { flag=0; for(j=0;j<strs.size();j++) { if(strs[j][i]

Leetcode 235. Lowest Common Ancestor of a Binary Search Tree

℡╲_俬逩灬. 提交于 2020-04-07 07:15:09
235. Lowest Common Ancestor of a Binary Search Tree Total Accepted: 77021 Total Submissions: 205265 Difficulty: Easy Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia : “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of itself).” _______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 5 For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6 . Another example is

#Leetcode# 235. Lowest Common Ancestor of a Binary Search Tree

六眼飞鱼酱① 提交于 2020-04-07 05:35:16
https://leetcode.com/problems/lowest-common-ancestor-of-a-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 definition of LCA on Wikipedia : “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” Given binary search tree: root = [6,2,8,0,4,7,9,null,null,3,5] Example 1: Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8 Output: 6 Explanation: The LCA of nodes 2 and 8 is 6.

Leetcode 235. Lowest Common Ancestor of a Binary Search Tree

*爱你&永不变心* 提交于 2020-04-07 05:22:13
题目链接 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/description/ 题目描述 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself ).” Given binary search tree: root = [6,2,8,0,4,7,9,null,null,3,5] _______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 5 Example 1: Input: root = [6,2,8,0,4,7,9,null

LeetCode 235. Lowest Common Ancestor of a Binary Search Tree

南笙酒味 提交于 2020-04-07 04:00:44
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/description/ Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia : “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of itself).” _______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 5 For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6 . Another example is LCA of nodes 2 and 4 is 2 ,

letecode [235] - Lowest Common Ancestor of a Binary Search Tree

泪湿孤枕 提交于 2020-04-07 03:01:36
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia : “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” Given binary search tree: root = [6,2,8,0,4,7,9,null,null,3,5] Example 1: Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8 Output: 6 Explanation: The LCA of nodes 2 and 8 is 6. Example 2: Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4 Output: 2

235_Lowest Common Ancestor of a Binary Search Tree

风格不统一 提交于 2020-04-07 02:57:45
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia : “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of itself).” _______6______ / \ ___2__ ___8__ / \ / \ 0 _4 7 9 / \ 3 5 For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6 . Another example is LCA of nodes 2 and 4 is 2 , since a node can be a descendant of itself according to the LCA definition. 给定一个二叉搜索树

css 不规整元素的宽高等比例

拟墨画扇 提交于 2020-04-05 19:44:17
不规整元素的宽高等比例 在不同屏幕情况中不同宽高的元素都以相同等比例、等宽和等高方式展示。 需求 设计师希望页面的图片区域,以宽高为2:1比例且所有图片的等宽和等高的方式展示。小加同学觉得设计师这需求太容易,分分钟搞定,拿到图片后便开始刷刷的撸代码。原型设计稿大致如下: bootstrap 栅格系统 思路 每个图片区域宽度为父元素宽度的25%,图片的宽度设置100%,其高度根据宽度等比例自动缩放(小加以为图片的宽高应该是同比例的),这样就可以适应屏幕达到要求咯~ HTML <div class="section"> <h1 class="section__title">初版</h1> <div class="section__images row"> <div class="section__image-wrap col-xs-3"> <img class="section__image" src="../../img/common/common-1.jpg"> </div> <div class="section__image-wrap col-xs-3"> <img class="section__image" src="../../img/common/common-2.jpg"> </div> <div class="section__image-wrap col-xs-3

刷题236. Lowest Common Ancestor of a Binary Tree

浪尽此生 提交于 2020-04-05 17:27:49
一、题目说明 题目236. Lowest Common Ancestor of a Binary Tree,在一个二叉树中找两个节点的最近公共祖先。难度是Medium! 二、我的解答 这个用二叉树的递归遍历,稍加改造即可: class Solution{ public: TreeNode* lowestCommonAncestor(TreeNode* root,TreeNode*p,TreeNode*q){ if(root == NULL) return root; if(root == p || root==q) return root; TreeNode* left,*right; left = lowestCommonAncestor(root->left,p,q); right = lowestCommonAncestor(root->right,p,q); if(left !=NULL && right!=NULL){ return root; }else if(left != NULL){ return left; }else if(right != NULL){ return right; }else{ return NULL; } } }; 性能如下: Runtime: 16 ms, faster than 94.88% of C++ online