Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Map<String, String> pairs(String[] strings) {
- Map<String, String> map = new HashMap<String, String>();
- if (strings != null){
- for (String s:strings) {
- int n = s.length();
- if (!map.containsKey(s)) { // first time we've seen this string
- map.put(s.substring(0,1), s.substring(n-1, n));
- }
- }
- }
- return map;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement