null

Leetcode 100. 相同的树

删除回忆录丶 提交于 2019-12-29 21:25:32
1.题目描述 给定两个二叉树,编写一个函数来检验它们是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例 1: 输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] 输出: true 示例 2: 输入: 1 1 / \ 2 2 [1,2], [1,null,2] 输出: false 示例 3: 输入: 1 1 / \ / \ 2 1 1 2 [1,2,1], [1,1,2] 输出: false    2.解法一:递归 class Solution { public: bool isSameTree(TreeNode* p, TreeNode* q) { //先序遍历-递归 if((p==NULL && q) || (p && q==NULL)) return false; if(p && q && p->val!= q->val) return false; //两颗子树同时为真才真 if(p && q) return isSameTree(p->left,q->left) && isSameTree(p->right,q->right); return true; } }; 3.解法二:非递归--栈(先序遍历) 3.1 使用2个栈 我的粗糙代码 /** * Definition for a binary tree

What is the best way to indicate that a double value has not been initialized?

戏子无情 提交于 2019-12-29 09:32:31
问题 I have a class CS which is to represent the co-ordinate system in 3D i.e.(x, y, z) class CS { private: double x; double y; double z; } CS::CS() { x = NULL;//this causes x = 0//i want the address of x to be 0x000000 & not x = 0 y = NULL; z = NULL: } I want that the user can create a CS (0, 0, 0). In the constructor i want to initialise the address of x, y & z to NULL. this is to differentiate between the user defined (0, 0, 0) & the default value. I am creating the objects of CS dynamically,

What is the best way to indicate that a double value has not been initialized?

我是研究僧i 提交于 2019-12-29 09:32:29
问题 I have a class CS which is to represent the co-ordinate system in 3D i.e.(x, y, z) class CS { private: double x; double y; double z; } CS::CS() { x = NULL;//this causes x = 0//i want the address of x to be 0x000000 & not x = 0 y = NULL; z = NULL: } I want that the user can create a CS (0, 0, 0). In the constructor i want to initialise the address of x, y & z to NULL. this is to differentiate between the user defined (0, 0, 0) & the default value. I am creating the objects of CS dynamically,

fatal error: unexpectedly found nil while unwrapping an Optional value - why?

情到浓时终转凉″ 提交于 2019-12-29 09:32:27
问题 I'm pretty new to coding in Swift and I'm not too sure what's happening here - can anyone help? Thanks import UIKit class SecondViewController: UIViewController { var toDoItems:[String] = [] @IBOutlet weak var toDoItem: UITextField! @IBAction func addItem(sender: AnyObject) { toDoItems.append(toDoItem.text) fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) println(toDoItems) } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after

fatal error: unexpectedly found nil while unwrapping an Optional value - why?

对着背影说爱祢 提交于 2019-12-29 09:31:11
问题 I'm pretty new to coding in Swift and I'm not too sure what's happening here - can anyone help? Thanks import UIKit class SecondViewController: UIViewController { var toDoItems:[String] = [] @IBOutlet weak var toDoItem: UITextField! @IBAction func addItem(sender: AnyObject) { toDoItems.append(toDoItem.text) fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) println(toDoItems) } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after

Expressing “is null” in Relational algebra

北战南征 提交于 2019-12-29 09:25:10
问题 In SQL, if I want to know whether an expression is NULL, I can use is null . But I don't understand how I can express is null in relational algebra. Can I use δ Field_Name=NULL(Table_Name) ? 回答1: There is no NULL in relational algebra. In SQL the operators treat the value NULL specially, syntactically and semantically, differently than other values, usually by returning NULL when comparing two values when one of them is NULL. So "=" in a WHERE is not equality, it is an operator like equality

About the non-nullable types debate

允我心安 提交于 2019-12-29 08:35:39
问题 I keep hearing people talk about how non-nullable reference types would solve so many bugs and make programming so much easier. Even the creator of null calls it his billion dollar mistake, and Spec# has introduced non-nullable types to combat this problem. EDIT: Ignore my comment about Spec#. I misunderstood how it works. EDIT 2: I must be talking to the wrong people, I was really hoping for somebody to argue with :-) So I would guess, being in the minority, that I'm wrong, but I can't

Blank value in web service for Int64 type

一世执手 提交于 2019-12-29 07:41:37
问题 I consume a web service that has a numeric element. The Delphi wsdl importer sets it up as Int64. The web service allows this element to be blank. However, because it is defined as Int64, when I consume the web service in Delphi without setting a value for it, it defaults to 0 because it's an Int64. But I need it to be blank and the web service will not accept a value of 0 (0 is defined as invalid and returns an error by the web service). How can I pass a blank value if the type is Int64? 回答1

Blank value in web service for Int64 type

て烟熏妆下的殇ゞ 提交于 2019-12-29 07:41:28
问题 I consume a web service that has a numeric element. The Delphi wsdl importer sets it up as Int64. The web service allows this element to be blank. However, because it is defined as Int64, when I consume the web service in Delphi without setting a value for it, it defaults to 0 because it's an Int64. But I need it to be blank and the web service will not accept a value of 0 (0 is defined as invalid and returns an error by the web service). How can I pass a blank value if the type is Int64? 回答1

How to convert empty to null in PostgreSQL?

孤街醉人 提交于 2019-12-29 07:40:13
问题 I have some columns type int, but value is empty. So I want to convert empty to null when I insert to database. I use code: function toDB($string) { if ($string == '' || $string == "''") { return 'null'; } else { return "'$string'"; } } //age,month,year is type integer. $name="Veo ve"; $age='10'; $month=''; $year=''; $query="Insert Into tr_view(name,age,month,year) values ({toDB($name)},{toDB($age)},{toDB($month)},{toDB($year)}) $db->setQuery($query); $result= $db->query(); But it show error: