Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. public Map<String, String> pairs(String[] strings) {
  2.  
  3. Map<String, String> map = new HashMap<String, String>();
  4.  
  5. if (strings != null){
  6. for (String s:strings) {
  7. int n = s.length();
  8. if (!map.containsKey(s)) { // first time we've seen this string
  9. map.put(s.substring(0,1), s.substring(n-1, n));
  10. }
  11. }
  12.  
  13.  
  14. }
  15.  
  16.  
  17. return map;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement