Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 1.4 KB

leetcode_357.md

File metadata and controls

64 lines (44 loc) · 1.4 KB

a

https://leetcode.cn/problems/faulty-keyboard/

class Solution {
    public String finalString(String s) {
        int n = s.length();

        StringBuilder res = new StringBuilder();
        for (int i = 0; i < n; i ++) {
            if (s.charAt(i) != 'i') {
                res.append(s.charAt(i));
            } else {
                res.reverse();
            }
        }
        return res.toString();
    }
}

b

https://leetcode.cn/problems/check-if-it-is-possible-to-split-array/description/

class Solution {
    public boolean canSplitArray(List<Integer> nums, int m) {
        int n = nums.size();
        
        if (n <= 2) return true;
        for (int i = 1; i < n ; i ++) {
            if (nums.get(i) + nums.get(i - 1) >= m ) return true;;
        }
        return false;
    }
}

c

https://leetcode.cn/problems/find-the-safest-path-in-a-grid/

d

https://leetcode.cn/problems/maximum-elegance-of-a-k-length-subsequence/