news 2026/10/30 4:28:20

LeetCode //C - 1309. Decrypt String from Alphabet to Integer Mapping

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
LeetCode //C - 1309. Decrypt String from Alphabet to Integer Mapping

1309. Decrypt String from Alphabet to Integer Mapping

You are given a string s formed by digits and ‘#’. We want to map s to English lowercase characters as follows:

  • Characters (‘a’ to ‘i’) are represented by (‘1’ to ‘9’) respectively.
  • Characters (‘j’ to ‘z’) are represented by (‘10#’ to ‘26#’) respectively.

Returnthe string formed after mapping.

The test cases are generated so that a unique mapping will always exist.

Example 1:

Input:s = “10#11#12”
Output:“jkab”
Explanation:“j” -> “10#” , “k” -> “11#” , “a” -> “1” , “b” -> “2”.

Example 2:

Input:s = “1326#”
Output:“acz”

Constraints:
  • 1 <= s.length <= 1000
  • s consists of digits and the ‘#’ letter.
  • s will be a valid string such that mapping is always possible.

From: LeetCode
Link: 1309. Decrypt String from Alphabet to Integer Mapping


Solution:

Ideas:

Scan from left to right; when the character two positions ahead is ‘#’, decode two digits, otherwise decode one digit.

Code:
#include<stdlib.h>#include<string.h>char*freqAlphabets(char*s){intn=strlen(s);char*result=(char*)malloc((n+1)*sizeof(char));inti=0;intindex=0;while(i<n){intvalue;if(i+2<n&&s[i+2]=='#'){value=(s[i]-'0')*10+(s[i+1]-'0');i+=3;}else{value=s[i]-'0';i++;}result[index++]='a'+value-1;}result[index]='\0';returnresult;}
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/10/30 4:25:22

沐曦股份曦云C系列GPU Day 0 适配智谱GLM-5.2旗舰模型

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/10/30 4:24:41

YOLO26涨点改进 | 全网独家复现 CVPR2025 RLAB残差线性注意力块创新改进,多尺度特征自适应融合与关键权重增强、助力小目标检测、遥感检测、图像分类、实例分割有效涨点

目录 一、深度剖析:YOLO26原生Neck特征融合核心缺陷 1.1 多尺度特征错位失配,高低层特征冲突严重 1.2 融合冗余信息堆积,关键有效特征被稀释 1.3 浅层细节融合丢失,小目标检测短板突出 1.4 无全局上下文建模,长距离依赖缺失 1.5 多任务适配性差,分割分类增益微弱 …

作者头像 李华
网站建设 2026/10/30 4:23:38

【RHCA+】影响Linux系统性能的因素

“ 目录&#xff1a;RHCA -> 12 系统监控 -> 1 影响Linux系统性能的因素 ”总体原则&#xff1a;完成任务的有效性、稳定性以及响应速度等系统默认设置通常是中庸的&#xff0c;适合大多数场景&#xff1b;在系统专用于某些特定业务场景时&#xff0c;就可以牺牲某方面的…

作者头像 李华
网站建设 2026/10/30 4:22:32

6-Platform总线

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/10/30 4:21:54

传感器融合实战:从卡尔曼滤波到HyperFrame超帧框架

第一次在自动驾驶项目里预研传感器融合方案时&#xff0c;我看到了 HyperFrame 这个名字。坦白说&#xff0c;最初我以为这只是又一个卡尔曼滤波的封装库&#xff0c;随手 clone 下来准备跑个 demo 交差。真正把它用起来之后才发现&#xff0c;这个框架对“传感器融合”这件事的…

作者头像 李华