在这篇文章中,我们将为您详细介绍71.SimplifyPath的内容。此外,我们还会涉及一些关于19.2.13[LeetCode71]SimplifyPath、Amplify.Auth.getCurr
在这篇文章中,我们将为您详细介绍71. Simplify Path的内容。此外,我们还会涉及一些关于19.2.13 [LeetCode 71] Simplify Path、Amplify.Auth.getCurrentUser() 升级到 iOS14.5 后始终为零(AWS Amplify iOS)、aws-amplify:在测试 @aws-amplify React 项目时如何正确验证?、com.intellij.psi.impl.java.stubs.impl.PsiAnnotationParameterListStubImpl的实例源码的知识,以帮助您更全面地了解这个主题。
本文目录一览:- 71. Simplify Path
- 19.2.13 [LeetCode 71] Simplify Path
- Amplify.Auth.getCurrentUser() 升级到 iOS14.5 后始终为零(AWS Amplify iOS)
- aws-amplify:在测试 @aws-amplify React 项目时如何正确验证?
- com.intellij.psi.impl.java.stubs.impl.PsiAnnotationParameterListStubImpl的实例源码
71. Simplify Path
Given an absolute path for a file (Unix-style),simplify it. Or in other words,convert it to the canonical path.
In a UNIX-style file system,a period .
refers to the current directory. Furthermore,a double period ..
moves the directory up a level. For more information,see: Absolute path vs relative path in Linux/Unix
Note that the returned canonical path must always begin with a slash /
,and there must be only a single slash /
between two directory names. The last directory name (if it exists) must not end with a trailing /
. Also,the canonical path must be the shortest string representing the absolute path.
Example 1:
Input: "/home/"
Output: "/home" Explanation: Note that there is no trailing slash after the last directory name.
Example 2:
Input: "/../"
Output: "/" Explanation: Going one level up from the root directory is a no-op,as the root level is the highest level you can go.
Example 3:
Input: "/home//foo/"
Output: "/home/foo" Explanation: In the canonical path,multiple consecutive slashes are replaced by a single one.
Example 4:
Input: "/a/./b/../../c/"
Output: "/c"
Example 5:
Input: "/a/../../b/../c//.//"
Output: "/c"
Example 6:
Input: "/a//b////c/d//././/.."
Output: "/a/b/c"
class Solution { public String simplifyPath(String path) { String[] strs = path.split("/"); ArrayList<String> list1 = new ArrayList<String>(); for(int i = 0; i < strs.length; i++){ //将空字符串(由类似这种"/a//c"的字符串产生)和 "." ("."代表当前目录不影响路径)去掉,保存到 list1 if (strs[i].isEmpty() || strs[i].equals(".")) { continue; } list1.add(strs[i]); } ArrayList<String> list2 = new ArrayList<String>(); for(int i = 0; i < list1.size(); i++){ if(list1.get(i).equals("..")){ if(!list2.isEmpty()){ list2.remove(list2.size() - 1); } } else list2.add(list1.get(i)); } String res = String.join("/",list2); res = "/" + res; return res; } }
这种题真是索然无味
https://leetcode.wang/leetCode-71-Simplify-Path.html
19.2.13 [LeetCode 71] Simplify Path
Given an absolute path for a file (Unix-style),simplify it. Or in other words,convert it to the canonical path.
In a UNIX-style file system,a period .
refers to the current directory. Furthermore,a double period ..
moves the directory up a level. For more information,see: Absolute path vs relative path in Linux/Unix
Note that the returned canonical path must always begin with a slash /
,and there must be only a single slash /
between two directory names. The last directory name (if it exists) must not end with a trailing /
. Also,the canonical path must be the shortest string representing the absolute path.
Example 1:
Input: "/home/" Output: "/home" Explanation: Note that there is no trailing slash after the last directory name.
Example 2:
Input: "/../" Output: "/" Explanation: Going one level up from the root directory is a no-op,as the root level is the highest level you can go.
Example 3:
Input: "/home//foo/" Output: "/home/foo" Explanation: In the canonical path,multiple consecutive slashes are replaced by a single one.
Example 4:
Input: "/a/./b/../../c/" Output: "/c"
Example 5:
Input: "/a/../../b/../c//.//" Output: "/c"
Example 6:
Input: "/a//b////c/d//././/.." Output: "/a/b/c"
题意
简化绝对路径,最后一个目录后不能有/
空路径写作"/",如果要求访问根目录的上一级目录则自动简化为根目录自己,如例2
题解
1 class Solution { 2 public: 3 string simplifyPath(string path) { 4 string ans = ""; 5 int p = 0,l = path.length(); 6 while (p < l) { 7 if (path[p] != ‘/‘) { 8 string menu = ""; 9 while (p < l&&path[p] != ‘/‘) 10 menu += path[p++]; 11 if (menu == ".") 12 continue; 13 else if (menu == "..") { 14 int idx = ans.rfind(‘/‘); 15 if (idx == string::npos)continue; 16 ans.erase(idx); 17 } 18 else 19 ans += "/" + menu; 20 } 21 p++; 22 } 23 if (ans.empty())return "/"; 24 return ans; 25 } 26 };
Amplify.Auth.getCurrentUser() 升级到 iOS14.5 后始终为零(AWS Amplify iOS)
如何解决Amplify.Auth.getCurrentUser() 升级到 iOS14.5 后始终为零(AWS Amplify iOS)?
我使用aws amplify-ios开发iOS应用,升级到iOS14.5后出现问题
升级到 iOS14.5 后 Amplify.Auth.getCurrentUser() 始终为零 (AWS Amplify iOS)
在iOS14.4.2上运行的相同源代码就好了。
macOS Big Sur11.3 + Xcode12.5 + iOS14.5 + Swift 5.4 版
请有任何想法。
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
aws-amplify:在测试 @aws-amplify React 项目时如何正确验证?
如何解决aws-amplify:在测试 @aws-amplify React 项目时如何正确验证??
我正在为使用 ReactJS
作为后端的 aws-amplify
项目编写测试。我选择的测试库是 react-testing-library
。
我可以照常测试组件的行为。不需要后端的测试成功运行。但是控制台仍然给我一个错误信息:
● Console
console.warn
[WARN] 08:18.759 GraphQLAPI - ensure credentials error No Cognito Identity pool provided for unauthenticated access
at ConsoleLogger.Object.<anonymous>.ConsoleLogger._log (node_modules/@aws-amplify/core/src/Logger/ConsoleLogger.ts:99:4)
at ConsoleLogger.Object.<anonymous>.ConsoleLogger.warn (node_modules/@aws-amplify/core/src/Logger/ConsoleLogger.ts:132:12)
at node_modules/@aws-amplify/api-graphql/src/GraphQLAPI.ts:391:12
console.error
fetchEvents error=> Error: No credentials
at GraphQLAPIClass.<anonymous> (C:\path-to-my-project\node_modules\@aws-amplify\api-graphql\src\GraphQLAPI.ts:138:12)
at step (C:\path-to-my-project\node_modules\@aws-amplify\api-graphql\lib\GraphQLAPI.js:44:23)
at Object.next (C:\path-to-my-project\node_modules\@aws-amplify\api-graphql\lib\GraphQLAPI.js:25:53)
at fulfilled (C:\path-to-my-project\node_modules\@aws-amplify\api-graphql\lib\GraphQLAPI.js:16:58)
at processticksAndRejections (internal/process/task_queues.js:93:5)
16 | console.log(rideEventList)
17 | } catch (error) {
> 18 | console.error("fetchEvents error=> ",error);
| ^
19 | }
20 | };
21 |
at fetchEvents (src/components/RideEventsList.js:18:21)
我的 RideEventsList
组件所做的就是从其 aws 后端获取事件列表。
正常运行应用程序 (npm start
) 工作正常,但测试 (npm test
) 它以某种方式要求我再次进行身份验证。如何做到这一点?
几乎没有关于测试 aws-amplify 项目的信息。我也想测试需要后端集成的功能。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
com.intellij.psi.impl.java.stubs.impl.PsiAnnotationParameterListStubImpl的实例源码
@Override public PsiAnnotationParameterListStub createStub(LighteraST tree,LighteraSTNode node,StubElement parentStub) { return new PsiAnnotationParameterListStubImpl(parentStub); }
@NotNull @Override public PsiAnnotationParameterListStub deserialize(@NotNull StubInputStream dataStream,StubElement parentStub) throws IOException { return new PsiAnnotationParameterListStubImpl(parentStub); }
@Override public PsiAnnotationParameterListStub createStub(LighteraST tree,StubElement parentStub) { return new PsiAnnotationParameterListStubImpl(parentStub); }
@NotNull @Override public PsiAnnotationParameterListStub deserialize(@NotNull StubInputStream dataStream,StubElement parentStub) throws IOException { return new PsiAnnotationParameterListStubImpl(parentStub); }
@Override public PsiAnnotationParameterListStub createStub(LighteraST tree,StubElement parentStub) { return new PsiAnnotationParameterListStubImpl(parentStub); }
@NotNull @Override public PsiAnnotationParameterListStub deserialize(@NotNull StubInputStream dataStream,StubElement parentStub) throws IOException { return new PsiAnnotationParameterListStubImpl(parentStub); }
关于71. Simplify Path的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于19.2.13 [LeetCode 71] Simplify Path、Amplify.Auth.getCurrentUser() 升级到 iOS14.5 后始终为零(AWS Amplify iOS)、aws-amplify:在测试 @aws-amplify React 项目时如何正确验证?、com.intellij.psi.impl.java.stubs.impl.PsiAnnotationParameterListStubImpl的实例源码的相关知识,请在本站寻找。
本文标签: