Coder Social home page Coder Social logo

Comments (3)

Oliverwqcwrw avatar Oliverwqcwrw commented on August 14, 2024 1

public static List symmetryArr(int n ) {
List list = new ArrayList<>();
for (int i = 11;i<n;i++) {
char[] chars = (i + "").toCharArray();

        boolean flag = true;
        for(int j = 0;j < chars.length / 2;j++) {
            if (chars[j] != chars[chars.length - 1 - j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            list.add(i);
        }
    }
    return list;
}

from interviewsummary.

x906674935 avatar x906674935 commented on August 14, 2024 1

findNumber= (e,start=1,end=1000) =>{
let res = [];
// console.log(start,end)
for (let index = start; index <= end; index++) {
let str = JSON.stringify(index);
let arr = str.split("");
let key = true;
for (let index = 0,length = arr.length ; index < length; index++) {
if(arr[index]!== arr[length-index-1]){
key = false
}
}
if(key&&arr.length>1){
res.push(index)
}
}
console.log(res)
return res;
}

from interviewsummary.

guyuezhai avatar guyuezhai commented on August 14, 2024

一行代码就是这么帅

    [...Array(1000).keys()].filter(o=>o.toString().length>1 && o==Number(o.toString().split('').reverse().join('')))

运行结果如下

[11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616, 626, 636, 646, 656, 666, 676, 686, 696, 707, 717, 727, 737, 747, 757, 767, 777, 787, 797, 808, 818, 828, 838, 848, 858, 868, 878, 888, 898, 909, 919, 929, 939, 949, 959, 969, 979, 989, 999]

from interviewsummary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.