首页 > 数据库 >[Oracle] LeetCode 205 Isomorphic Strings

[Oracle] LeetCode 205 Isomorphic Strings

时间:2022-10-08 15:56:21浏览次数:50  
标签:map 205 int character two characters Oracle Strings size

Given two strings s and t, determine if they are isomorphic.

Two strings s and t are isomorphic if the characters in s can be replaced to get t.

All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.

Solution

直接用 \(map\) 进行双向的映射即可

点击查看代码
class Solution {
public:
    bool isIsomorphic(string s, string t) {
        map<char,char> mp1, mp2;
        int n1 = s.size(), n2 = t.size();
        if(n1!=n2)return false;
        else{
            for(int i=0;i<n1;i++){
                if(mp1.find(s[i])==mp1.end() && mp2.find(t[i])==mp2.end()){
                    mp1[s[i]]=t[i];
                    mp2[t[i]]=s[i];
                }
                else if(mp1.find(s[i])==mp1.end())return false;
                else if(mp2.find(t[i])==mp2.end())return false;
                else if(mp1.find(s[i])!=mp1.end() && mp2.find(t[i])!=mp2.end()){
                    //cout<<mp1[s[i]]<<" "<<mp2[t[i]]<<endl;
                    if(mp1[s[i]]==t[i] && mp2[t[i]]==s[i])continue;
                    else return false;
                }
            }
        }
        return true;
    }
};

标签:map,205,int,character,two,characters,Oracle,Strings,size
From: https://www.cnblogs.com/xinyu04/p/16769182.html

相关文章

  • Oracle
    数据库体系结构数据库逻辑存储结构重做日志文件一个数据库至少包含两个重做日志文件组。每一个重做日志文件成员对应一个物理文件。.LOG结尾数据块......
  • Codeforces.1305B Kuroni and Simple Strings[模拟]
    题面NowthatKuronihasreached10yearsold,heisabigboyanddoesn'tlikearraysofintegersaspresentsanymore.ThisyearhewantsaBracketsequencea......
  • Red Hat 64位安装oracle 客户端sqlplus
    1.首先下载以下两个安装包:oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpmoracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm下载路径:https://www.ora......
  • 表的唯一约束的作用 KingbaseES VS Oracle
    背景演示唯一约束怎样创建、删除、禁用和使用唯一性约束,已经多种数据库的差异。什么是唯一约束唯一性约束指表中一个字段或者多个字段联合起来可以唯一标识一条记录的约......
  • Oracle多实例的配置方法
     SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=PLSExtProc)(ORACLE_HOME=/oracleapp/oracle/product/11.2.0/dbhome_2)(PROGRAM=ext......
  • Oracle函数
    Oracle函数一、日期函数  TO_DATE格式(以时间:2007-11-02  13:45:25为例)       Year:             yytwodigits两位年       ......
  • Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace
    Oracle使用正则表达式离不开这4个函数:1、regexp_like2、regexp_substr3、regexp_instr4、regexp_replace看函数名称大概就能猜到有什么用了。regexp_like只能用于条件表达......
  • 修改Oracle限制某个用户的连接数
    --为oracle增加processes第一步:查看现有值SELECT*FROMv$resource_limit;sysdba权限登录:sqlplusDRG/DRG@orclassysdba第二步:修改processes和sessions(158上最大......
  • ORA-19505: failed to identify file "/u01/app/oracle/product/11.2.0/db_1/dbs/orap
    系统:centos7.964位数据库:oracle11.2.0.464位环境:rac(双节点)+dg问题描述:搭建dg时报错ORA-19505,如下所示.[oracle@hisdbdg~]$rmantargetsys/********@orclauxiliary......
  • Oracle编程艺术
    第二章-体系结构1.绑定变量,不写死常量:1)绑定变量的话,因为SQL语句是不变的,数据库只解析一次语句(软解析),但是如果绑定的是常量的话,则会多次解析(硬解析),效率就会变慢,差一......