Given a string S and a string T, count the number of distinct subsequences of S which equals T.
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, “ACE” is a subsequence of “ABCDE” while “AEC” is not).
一个简单的动态规划即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
classSolution { public: intnumDistinct(string s, string t){ int lens = s.size(), lent = t.size(); vector<vector<int>> dp(lens + 1, vector<int>(lent + 1, 0)); for (int i = 0; i <= lens; i++) { dp[i][0] = 1; } for (int i = 1; i <= lens; i++) { for (int j = 1; j <= i && j <= lent; j++) { dp[i][j] = (int)((longlong)(s[i - 1] == t[j - 1] ? dp[i - 1][j - 1] : 0) + dp[i - 1][j]); } } return dp[lens][lent]; } };
A binary tree is threaded by making all right child pointers that would normally be null point to the inorder successor of the node (if it exists), and all left child pointers that would normally be null point to the inorder predecessor of the node.
当 cur 不为空时 - 如果 cur 没有左子结点 a) 打印出 cur 的值 b) 将 cur 指针指向其右子节点 - 反之 将 pre 指针指向 cur 的左子树中的最右子节点 * 若 pre 不存在右子节点 a) 将其右子节点指回 cur b) cur 指向其左子节点 * 反之 a) 将 pre 的右子节点置空 b) 打印 cur 的值 c) 将 cur 指针指向其右子节点
select * from (select SQL_TEXT, FIRST_LOAD_TIME from v$sql order by FIRST_LOAD_TIME desc) where rownum<=10;
SQL> create user root IDENTIFIED BY root;
用户已创建。
SQL> grant connect, resource to root;
授权成功。
数据库database默认有一个orcl(最后一个是小写字母l,不是大写的I也不是1),可以通过select name from v$database;查看。
创建的用户默认就是这个数据库的,可以通过
1 2 3 4 5 6 7 8
SELECT a.TABLE_NAME,b.COMMENTS FROM user_tables a,user_tab_comments b WHERE a.TABLE_NAME=b.TABLE_NAME ORDER BY TABLE_NAME
查看所有的表。
之后可以drop table xxx来删除表,但是数据库不能这么删除。
cx_oracle版本问题导致: ··· The above exception was the direct cause of the following exception:
Traceback (most recent call last): File “manage.py”, line 22, in execute_from_command_line(sys.argv) File “G:\django_test_oracle\venv\lib\site-packages\django\core\management_init_.py”, line 364, in execute_from_command_line utility.execute() File “G:\django_test_oracle\venv\lib\site-packages\django\core\management_init_.py”, line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File “G:\django_test_oracle\venv\lib\site-packages\django\core\management\base.py”, line 283, in run_from_argv self.execute(*args, **cmd_options) File “G:\django_test_oracle\venv\lib\site-packages\django\core\management\base.py”, line 330, in execute output = self.handle(*args, **options) File “G:\django_test_oracle\venv\lib\site-packages\django\core\management\commands\migrate.py”, line 204, in handle fake_initial=fake_initial, File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\executor.py”, line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\executor.py”, line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\executor.py”, line 244, in apply_migration state = migration.apply(state, schema_editor) File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\migration.py”, line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\operations\models.py”, line 97, in database_forwards schema_editor.create_model(model) File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\base\schema.py”, line 319, in create_model self.execute(sql, params or None) File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\base\schema.py”, line 136, in execute cursor.execute(sql, params) File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\utils.py”, line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\utils.py”, line 64, in execute return self.cursor.execute(sql, params) File “G:\django_test_oracle\venv\lib\site-packages\django\db\utils.py”, line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File “G:\django_test_oracle\venv\lib\site-packages\django\utils\six.py”, line 685, in reraise raise value.with_traceback(tb) File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\utils.py”, line 62, in execute return self.cursor.execute(sql) File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\oracle\base.py”, line 497, in execute return self.cursor.execute(query, self._param_generator(params)) django.db.utils.DatabaseError: ORA-00955: name is already used by an existing object ···